1 """Support for RFXtrx sensors."""
3 from __future__
import annotations
8 from RFXtrx
import ControlEvent, RFXtrxDevice, RFXtrxEvent, SensorEvent
17 from .
import DeviceTuple, async_setup_platform_entry
18 from .const
import DEVICE_PACKET_TYPE_LIGHTING4
19 from .entity
import RfxtrxEntity
21 _LOGGER = logging.getLogger(__name__)
26 config_entry: ConfigEntry,
27 async_add_entities: AddEntitiesCallback,
29 """Set up config entry."""
31 def _supported(event: RFXtrxEvent) -> bool:
33 isinstance(event, (ControlEvent, SensorEvent))
34 and event.device.packettype != DEVICE_PACKET_TYPE_LIGHTING4
39 auto: RFXtrxEvent |
None,
40 device_id: DeviceTuple,
41 entity_info: dict[str, Any],
43 entities: list[Entity] = []
45 if hasattr(event.device,
"COMMANDS"):
48 event.device, device_id,
"COMMANDS",
"Command",
"command"
52 if hasattr(event.device,
"STATUS"):
55 event.device, device_id,
"STATUS",
"Sensor Status",
"status"
62 hass, config_entry, async_add_entities, _supported, _constructor
67 """Representation of a RFXtrx event."""
72 device_id: DeviceTuple,
73 device_attribute: str,
77 """Initialize the sensor."""
79 commands: dict[int, str] = getattr(device, device_attribute)
87 def _handle_event(self, event: RFXtrxEvent, device_id: DeviceTuple) ->
None:
88 """Check if event applies to me and update."""
92 assert isinstance(event, (ControlEvent, SensorEvent))
96 _LOGGER.warning(
"Event type %s is not known", event_type)
None _trigger_event(self, str event_type, dict[str, Any]|None event_attributes=None)
bool _event_applies(self, rfxtrxmod.RFXtrxEvent event, DeviceTuple device_id)
None _handle_event(self, RFXtrxEvent event, DeviceTuple device_id)
None __init__(self, RFXtrxDevice device, DeviceTuple device_id, str device_attribute, str value_attribute, str translation_key)
None async_write_ha_state(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
None async_setup_platform_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities, Callable[[rfxtrxmod.RFXtrxEvent], bool] supported, Callable[[rfxtrxmod.RFXtrxEvent, rfxtrxmod.RFXtrxEvent|None, DeviceTuple, dict[str, Any],], list[Entity],] constructor)