diff --git a/homeassistant/components/rfxtrx/__init__.py b/homeassistant/components/rfxtrx/__init__.py index 0fdab9f1bf5..edae34d7e37 100644 --- a/homeassistant/components/rfxtrx/__init__.py +++ b/homeassistant/components/rfxtrx/__init__.py @@ -229,7 +229,7 @@ def setup_internal(hass, config): "sub_type": event.device.subtype, "type_string": event.device.type_string, "id_string": event.device.id_string, - "data": "".join(f"{x:02x}" for x in event.data), + "data": binascii.hexlify(event.data).decode("ASCII"), "values": getattr(event, "values", None), } @@ -375,7 +375,7 @@ def get_device_id(device, data_bits=None): if data_bits and device.packettype == DEVICE_PACKET_TYPE_LIGHTING4: masked_id = get_pt2262_deviceid(id_string, data_bits) if masked_id: - id_string = str(masked_id) + id_string = masked_id.decode("ASCII") return (f"{device.packettype:x}", f"{device.subtype:x}", id_string) diff --git a/homeassistant/components/rfxtrx/cover.py b/homeassistant/components/rfxtrx/cover.py index 047f7c67a21..58bc27d95bb 100644 --- a/homeassistant/components/rfxtrx/cover.py +++ b/homeassistant/components/rfxtrx/cover.py @@ -7,6 +7,7 @@ from homeassistant.core import callback from . import ( CONF_AUTOMATIC_ADD, + CONF_DATA_BITS, CONF_SIGNAL_REPETITIONS, DEFAULT_SIGNAL_REPETITIONS, SIGNAL_EVENT, @@ -38,7 +39,9 @@ async def async_setup_entry( if not supported(event): continue - device_id = get_device_id(event.device) + device_id = get_device_id( + event.device, data_bits=entity_info.get(CONF_DATA_BITS) + ) if device_id in device_ids: continue device_ids.add(device_id) diff --git a/homeassistant/components/rfxtrx/light.py b/homeassistant/components/rfxtrx/light.py index 376e8b515be..ab24520e485 100644 --- a/homeassistant/components/rfxtrx/light.py +++ b/homeassistant/components/rfxtrx/light.py @@ -13,6 +13,7 @@ from homeassistant.core import callback from . import ( CONF_AUTOMATIC_ADD, + CONF_DATA_BITS, CONF_SIGNAL_REPETITIONS, DEFAULT_SIGNAL_REPETITIONS, SIGNAL_EVENT, @@ -50,7 +51,9 @@ async def async_setup_entry( if not supported(event): continue - device_id = get_device_id(event.device) + device_id = get_device_id( + event.device, data_bits=entity_info.get(CONF_DATA_BITS) + ) if device_id in device_ids: continue device_ids.add(device_id) diff --git a/homeassistant/components/rfxtrx/sensor.py b/homeassistant/components/rfxtrx/sensor.py index 34e6dc1b310..490885bec7a 100644 --- a/homeassistant/components/rfxtrx/sensor.py +++ b/homeassistant/components/rfxtrx/sensor.py @@ -14,6 +14,7 @@ from homeassistant.core import callback from . import ( CONF_AUTOMATIC_ADD, + CONF_DATA_BITS, DATA_TYPES, SIGNAL_EVENT, RfxtrxEntity, @@ -64,7 +65,7 @@ async def async_setup_entry( return isinstance(event, (ControlEvent, SensorEvent)) entities = [] - for packet_id in discovery_info[CONF_DEVICES]: + for packet_id, entity in discovery_info[CONF_DEVICES].items(): event = get_rfx_object(packet_id) if event is None: _LOGGER.error("Invalid device: %s", packet_id) @@ -72,7 +73,7 @@ async def async_setup_entry( if not supported(event): continue - device_id = get_device_id(event.device) + device_id = get_device_id(event.device, data_bits=entity.get(CONF_DATA_BITS)) for data_type in set(event.values) & set(DATA_TYPES): data_id = (*device_id, data_type) if data_id in data_ids: diff --git a/homeassistant/components/rfxtrx/switch.py b/homeassistant/components/rfxtrx/switch.py index cf8c26edecb..5f99c0761f0 100644 --- a/homeassistant/components/rfxtrx/switch.py +++ b/homeassistant/components/rfxtrx/switch.py @@ -9,6 +9,7 @@ from homeassistant.core import callback from . import ( CONF_AUTOMATIC_ADD, + CONF_DATA_BITS, CONF_SIGNAL_REPETITIONS, DEFAULT_SIGNAL_REPETITIONS, DOMAIN, @@ -48,7 +49,9 @@ async def async_setup_entry( if not supported(event): continue - device_id = get_device_id(event.device) + device_id = get_device_id( + event.device, data_bits=entity_info.get(CONF_DATA_BITS) + ) if device_id in device_ids: continue device_ids.add(device_id)