Fix issue with creation of PT2262 devices in rfxtrx integration (#38074)
parent
b15dad8c4b
commit
83a27f4855
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue