Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Any

from rf_protocols import RadioFrequencyCommand
from rf_protocols.codes.honeywell.string_lights import CODES
import voluptuous as vol

from homeassistant.components.radio_frequency import async_get_transmitters
Expand All @@ -11,7 +12,6 @@
from homeassistant.helpers import entity_registry as er, selector

from .const import CONF_TRANSMITTER, DOMAIN
from .light import COMMANDS


class HoneywellStringLightsConfigFlow(ConfigFlow, domain=DOMAIN):
Expand All @@ -24,7 +24,7 @@ async def async_step_user(
) -> ConfigFlowResult:
"""Handle the initial step."""
sample_command: RadioFrequencyCommand = await self.hass.async_add_executor_job(
COMMANDS.load_command, "turn_on"
CODES.load_command, "turn_on"
)
try:
transmitters = async_get_transmitters(
Expand Down
6 changes: 2 additions & 4 deletions homeassistant/components/honeywell_string_lights/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import Any

from rf_protocols import get_codes
from rf_protocols.codes.honeywell.string_lights import CODES

from homeassistant.components.light import ColorMode, LightEntity
from homeassistant.components.radio_frequency import async_send_command
Expand All @@ -16,8 +16,6 @@

PARALLEL_UPDATES = 1

COMMANDS = get_codes("honeywell/string_lights")


async def async_setup_entry(
hass: HomeAssistant,
Expand Down Expand Up @@ -57,7 +55,7 @@ async def async_turn_off(self, **kwargs: Any) -> None:

async def _async_send_command(self, name: str) -> None:
"""Load the named command and send it via the configured transmitter."""
command = await COMMANDS.async_load_command(name)
command = await CODES.async_load_command(name)
await async_send_command(
self.hass, self._transmitter, command, context=self._context
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"integration_type": "device",
"iot_class": "assumed_state",
"quality_scale": "bronze",
"requirements": ["rf-protocols==2.2.0"]
"requirements": ["rf-protocols==3.0.0"]
}
9 changes: 1 addition & 8 deletions homeassistant/components/novy_cooker_hood/commands.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
"""Helpers for loading Novy cooker-hood RF commands."""
"""Command names for the Novy Cooker Hood RF codes."""

from typing import Final

from rf_protocols import CodeCollection, get_codes

COMMAND_LIGHT: Final = "light"
COMMAND_PLUS: Final = "plus"
COMMAND_MINUS: Final = "minus"


def get_codes_for_code(code: int) -> CodeCollection:
"""Return the bundled `rf-protocols` collection for a Novy cooker-hood code."""
return get_codes(f"novy/cooker_hood/code_{code}")
3 changes: 2 additions & 1 deletion homeassistant/components/novy_cooker_hood/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import asyncio
from typing import Any

from rf_protocols.codes.novy.cooker_hood import get_codes_for_code
import voluptuous as vol

from homeassistant.components.radio_frequency import (
Expand All @@ -17,7 +18,7 @@
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import entity_registry as er, selector

from .commands import COMMAND_LIGHT, get_codes_for_code
from .commands import COMMAND_LIGHT
from .const import (
CODE_MAX,
CODE_MIN,
Expand Down
4 changes: 3 additions & 1 deletion homeassistant/components/novy_cooker_hood/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import math
from typing import Any

from rf_protocols.codes.novy.cooker_hood import get_codes_for_code

from homeassistant.components.fan import ATTR_PERCENTAGE, FanEntity, FanEntityFeature
from homeassistant.components.radio_frequency import async_send_command
from homeassistant.config_entries import ConfigEntry
Expand All @@ -14,7 +16,7 @@
ranged_value_to_percentage,
)

from .commands import COMMAND_MINUS, COMMAND_PLUS, get_codes_for_code
from .commands import COMMAND_MINUS, COMMAND_PLUS
from .const import CONF_CODE, SPEED_COUNT
from .entity import NovyCookerHoodEntity

Expand Down
4 changes: 3 additions & 1 deletion homeassistant/components/novy_cooker_hood/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from typing import Any

from rf_protocols.codes.novy.cooker_hood import get_codes_for_code

from homeassistant.components.light import ColorMode, LightEntity
from homeassistant.components.radio_frequency import async_send_command
from homeassistant.config_entries import ConfigEntry
Expand All @@ -10,7 +12,7 @@
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
from homeassistant.helpers.restore_state import RestoreEntity

from .commands import COMMAND_LIGHT, get_codes_for_code
from .commands import COMMAND_LIGHT
from .const import CONF_CODE
from .entity import NovyCookerHoodEntity

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/novy_cooker_hood/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"integration_type": "device",
"iot_class": "assumed_state",
"quality_scale": "bronze",
"requirements": ["rf-protocols==2.2.0"]
"requirements": ["rf-protocols==3.0.0"]
}
2 changes: 1 addition & 1 deletion homeassistant/components/radio_frequency/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"documentation": "https://www.home-assistant.io/integrations/radio_frequency",
"integration_type": "entity",
"quality_scale": "internal",
"requirements": ["rf-protocols==2.2.0"]
"requirements": ["rf-protocols==3.0.0"]
}
2 changes: 1 addition & 1 deletion requirements.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion requirements_all.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion requirements_test_all.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/components/broadlink/test_radio_frequency.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from broadlink.exceptions import BroadlinkException
import pytest
from rf_protocols import OOKCommand
from rf_protocols.commands.ook import OOKCommand

from homeassistant.components import radio_frequency
from homeassistant.components.broadlink.const import DOMAIN
Expand Down
3 changes: 2 additions & 1 deletion tests/components/esphome/test_radio_frequency.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
RadioFrequencyModulation,
)
import pytest
from rf_protocols import ModulationType, OOKCommand
from rf_protocols import ModulationType
from rf_protocols.commands.ook import OOKCommand

from homeassistant.components import radio_frequency
from homeassistant.const import STATE_UNAVAILABLE
Expand Down
7 changes: 4 additions & 3 deletions tests/components/honeywell_string_lights/test_light.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Tests for the Honeywell String Lights light platform."""

from homeassistant.components.honeywell_string_lights.light import COMMANDS
from rf_protocols.codes.honeywell.string_lights import CODES

from homeassistant.components.light import (
DOMAIN as LIGHT_DOMAIN,
SERVICE_TURN_OFF,
Expand Down Expand Up @@ -49,7 +50,7 @@ async def test_turn_on_off_sends_commands(
assert state.context is context
assert len(mock_rf_entity.send_command_calls) == 1
command = mock_rf_entity.send_command_calls[0]
assert command.command is COMMANDS.load_command("turn_on")
assert command.command is CODES.load_command("turn_on")
assert command.context is context

await hass.services.async_call(
Expand All @@ -66,7 +67,7 @@ async def test_turn_on_off_sends_commands(
assert state.context is context
assert len(mock_rf_entity.send_command_calls) == 2
command = mock_rf_entity.send_command_calls[1]
assert command.command is COMMANDS.load_command("turn_off")
assert command.command is CODES.load_command("turn_off")
assert command.context is context


Expand Down
2 changes: 1 addition & 1 deletion tests/components/kitchen_sink/test_radio_frequency.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from freezegun.api import FrozenDateTimeFactory
import pytest
from rf_protocols import OOKCommand
from rf_protocols.commands.ook import OOKCommand

from homeassistant.components.kitchen_sink import DOMAIN
from homeassistant.components.radio_frequency import async_send_command
Expand Down
18 changes: 14 additions & 4 deletions tests/components/novy_cooker_hood/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from unittest.mock import AsyncMock, MagicMock, patch

import pytest
from rf_protocols import CodeCollection
from rf_protocols.loader import CodeCollection

from homeassistant.components.novy_cooker_hood.const import (
CONF_CODE,
Expand All @@ -30,9 +30,19 @@ def mock_get_codes() -> Iterator[MagicMock]:
fake_collection.async_load_command = AsyncMock(
side_effect=lambda name: MockRadioFrequencyCommand()
)
with patch(
"homeassistant.components.novy_cooker_hood.commands.get_codes",
return_value=fake_collection,
with (
patch(
"homeassistant.components.novy_cooker_hood.light.get_codes_for_code",
return_value=fake_collection,
),
patch(
"homeassistant.components.novy_cooker_hood.fan.get_codes_for_code",
return_value=fake_collection,
),
patch(
"homeassistant.components.novy_cooker_hood.config_flow.get_codes_for_code",
return_value=fake_collection,
),
):
yield fake_collection

Expand Down