mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 08:47:10 +00:00
Fix issue with creation of PT2262 devices in rfxtrx integration (#38074)
This commit is contained in:
parent
b15dad8c4b
commit
83a27f4855
@ -229,7 +229,7 @@ def setup_internal(hass, config):
|
|||||||
"sub_type": event.device.subtype,
|
"sub_type": event.device.subtype,
|
||||||
"type_string": event.device.type_string,
|
"type_string": event.device.type_string,
|
||||||
"id_string": event.device.id_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),
|
"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:
|
if data_bits and device.packettype == DEVICE_PACKET_TYPE_LIGHTING4:
|
||||||
masked_id = get_pt2262_deviceid(id_string, data_bits)
|
masked_id = get_pt2262_deviceid(id_string, data_bits)
|
||||||
if masked_id:
|
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)
|
return (f"{device.packettype:x}", f"{device.subtype:x}", id_string)
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ from homeassistant.core import callback
|
|||||||
|
|
||||||
from . import (
|
from . import (
|
||||||
CONF_AUTOMATIC_ADD,
|
CONF_AUTOMATIC_ADD,
|
||||||
|
CONF_DATA_BITS,
|
||||||
CONF_SIGNAL_REPETITIONS,
|
CONF_SIGNAL_REPETITIONS,
|
||||||
DEFAULT_SIGNAL_REPETITIONS,
|
DEFAULT_SIGNAL_REPETITIONS,
|
||||||
SIGNAL_EVENT,
|
SIGNAL_EVENT,
|
||||||
@ -38,7 +39,9 @@ async def async_setup_entry(
|
|||||||
if not supported(event):
|
if not supported(event):
|
||||||
continue
|
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:
|
if device_id in device_ids:
|
||||||
continue
|
continue
|
||||||
device_ids.add(device_id)
|
device_ids.add(device_id)
|
||||||
|
@ -13,6 +13,7 @@ from homeassistant.core import callback
|
|||||||
|
|
||||||
from . import (
|
from . import (
|
||||||
CONF_AUTOMATIC_ADD,
|
CONF_AUTOMATIC_ADD,
|
||||||
|
CONF_DATA_BITS,
|
||||||
CONF_SIGNAL_REPETITIONS,
|
CONF_SIGNAL_REPETITIONS,
|
||||||
DEFAULT_SIGNAL_REPETITIONS,
|
DEFAULT_SIGNAL_REPETITIONS,
|
||||||
SIGNAL_EVENT,
|
SIGNAL_EVENT,
|
||||||
@ -50,7 +51,9 @@ async def async_setup_entry(
|
|||||||
if not supported(event):
|
if not supported(event):
|
||||||
continue
|
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:
|
if device_id in device_ids:
|
||||||
continue
|
continue
|
||||||
device_ids.add(device_id)
|
device_ids.add(device_id)
|
||||||
|
@ -14,6 +14,7 @@ from homeassistant.core import callback
|
|||||||
|
|
||||||
from . import (
|
from . import (
|
||||||
CONF_AUTOMATIC_ADD,
|
CONF_AUTOMATIC_ADD,
|
||||||
|
CONF_DATA_BITS,
|
||||||
DATA_TYPES,
|
DATA_TYPES,
|
||||||
SIGNAL_EVENT,
|
SIGNAL_EVENT,
|
||||||
RfxtrxEntity,
|
RfxtrxEntity,
|
||||||
@ -64,7 +65,7 @@ async def async_setup_entry(
|
|||||||
return isinstance(event, (ControlEvent, SensorEvent))
|
return isinstance(event, (ControlEvent, SensorEvent))
|
||||||
|
|
||||||
entities = []
|
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)
|
event = get_rfx_object(packet_id)
|
||||||
if event is None:
|
if event is None:
|
||||||
_LOGGER.error("Invalid device: %s", packet_id)
|
_LOGGER.error("Invalid device: %s", packet_id)
|
||||||
@ -72,7 +73,7 @@ async def async_setup_entry(
|
|||||||
if not supported(event):
|
if not supported(event):
|
||||||
continue
|
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):
|
for data_type in set(event.values) & set(DATA_TYPES):
|
||||||
data_id = (*device_id, data_type)
|
data_id = (*device_id, data_type)
|
||||||
if data_id in data_ids:
|
if data_id in data_ids:
|
||||||
|
@ -9,6 +9,7 @@ from homeassistant.core import callback
|
|||||||
|
|
||||||
from . import (
|
from . import (
|
||||||
CONF_AUTOMATIC_ADD,
|
CONF_AUTOMATIC_ADD,
|
||||||
|
CONF_DATA_BITS,
|
||||||
CONF_SIGNAL_REPETITIONS,
|
CONF_SIGNAL_REPETITIONS,
|
||||||
DEFAULT_SIGNAL_REPETITIONS,
|
DEFAULT_SIGNAL_REPETITIONS,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
@ -48,7 +49,9 @@ async def async_setup_entry(
|
|||||||
if not supported(event):
|
if not supported(event):
|
||||||
continue
|
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:
|
if device_id in device_ids:
|
||||||
continue
|
continue
|
||||||
device_ids.add(device_id)
|
device_ids.add(device_id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user