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
14 changes: 8 additions & 6 deletions homeassistant/components/rfxtrx/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
BinarySensorEntity,
BinarySensorEntityDescription,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_COMMAND_OFF, CONF_COMMAND_ON, STATE_ON
from homeassistant.core import CALLBACK_TYPE, callback
from homeassistant.core import CALLBACK_TYPE, HomeAssistant, callback
from homeassistant.helpers import event as evt
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import DeviceTuple, RfxtrxEntity, async_setup_platform_entry, get_pt2262_cmd
from .const import (
Expand Down Expand Up @@ -83,10 +85,10 @@ def supported(event: rfxtrxmod.RFXtrxEvent):


async def async_setup_entry(
hass,
config_entry,
async_add_entities,
):
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up config entry."""

def get_sensor_description(type_string: str):
Expand All @@ -96,7 +98,7 @@ def get_sensor_description(type_string: str):

def _constructor(
event: rfxtrxmod.RFXtrxEvent,
auto: bool,
auto: rfxtrxmod.RFXtrxEvent | None,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This did not correspond to the hint defined in __init__.py
I think the __init__.py method should be adjusted to pass a bool, but that would be a code change and it seemed safer to adjust the type hint instead to match the current arguments.

constructor: Callable[
[rfxtrxmod.RFXtrxEvent, rfxtrxmod.RFXtrxEvent | None, DeviceTuple, dict],
list[Entity],
],

and
async_add_entities(constructor(event, event, device_id, {}))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second event is a auto detected event. So this change is correct. A refactor for auto might be in order later.

device_id: DeviceTuple,
entity_info: dict,
):
Expand Down
14 changes: 8 additions & 6 deletions homeassistant/components/rfxtrx/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
SUPPORT_STOP_TILT,
CoverEntity,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import STATE_OPEN
from homeassistant.core import callback
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import (
DEFAULT_SIGNAL_REPETITIONS,
Expand All @@ -41,15 +43,15 @@ def supported(event: rfxtrxmod.RFXtrxEvent):


async def async_setup_entry(
hass,
config_entry,
async_add_entities,
):
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up config entry."""

def _constructor(
event: rfxtrxmod.RFXtrxEvent,
auto: bool,
auto: rfxtrxmod.RFXtrxEvent | None,
device_id: DeviceTuple,
entity_info: dict,
):
Expand Down
14 changes: 8 additions & 6 deletions homeassistant/components/rfxtrx/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
SUPPORT_BRIGHTNESS,
LightEntity,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import STATE_ON
from homeassistant.core import callback
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import (
DEFAULT_SIGNAL_REPETITIONS,
Expand All @@ -35,15 +37,15 @@ def supported(event: rfxtrxmod.RFXtrxEvent):


async def async_setup_entry(
hass,
config_entry,
async_add_entities,
):
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up config entry."""

def _constructor(
event: rfxtrxmod.RFXtrxEvent,
auto: bool,
auto: rfxtrxmod.RFXtrxEvent | None,
device_id: DeviceTuple,
entity_info: dict,
):
Expand Down
14 changes: 8 additions & 6 deletions homeassistant/components/rfxtrx/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
SensorEntityDescription,
SensorStateClass,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
DEGREE,
ELECTRIC_CURRENT_AMPERE,
Expand All @@ -28,8 +29,9 @@
TEMP_CELSIUS,
UV_INDEX,
)
from homeassistant.core import callback
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity import EntityCategory
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import DeviceTuple, RfxtrxEntity, async_setup_platform_entry, get_rfx_object
from .const import ATTR_EVENT
Expand Down Expand Up @@ -208,18 +210,18 @@ class RfxtrxSensorEntityDescription(SensorEntityDescription):


async def async_setup_entry(
hass,
config_entry,
async_add_entities,
):
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up config entry."""

def _supported(event):
return isinstance(event, (ControlEvent, SensorEvent))

def _constructor(
event: RFXtrxEvent,
auto: bool,
auto: RFXtrxEvent | None,
device_id: DeviceTuple,
entity_info: dict,
):
Expand Down
14 changes: 8 additions & 6 deletions homeassistant/components/rfxtrx/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
import RFXtrx as rfxtrxmod

from homeassistant.components.switch import SwitchEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import STATE_ON
from homeassistant.core import callback
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import (
DEFAULT_SIGNAL_REPETITIONS,
Expand All @@ -34,15 +36,15 @@ def supported(event):


async def async_setup_entry(
hass,
config_entry,
async_add_entities,
):
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up config entry."""

def _constructor(
event: rfxtrxmod.RFXtrxEvent,
auto: bool,
auto: rfxtrxmod.RFXtrxEvent | None,
device_id: DeviceTuple,
entity_info: dict,
):
Expand Down