mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Fix mysensors ir switch overwriting devices (#4612)
This commit is contained in:
parent
86388f5af2
commit
71da9d2f50
@ -38,6 +38,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
if not gateways:
|
if not gateways:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
platform_devices = []
|
||||||
|
|
||||||
for gateway in gateways:
|
for gateway in gateways:
|
||||||
# Define the S_TYPES and V_TYPES that the platform should handle as
|
# Define the S_TYPES and V_TYPES that the platform should handle as
|
||||||
# states. Map them in a dict of lists.
|
# states. Map them in a dict of lists.
|
||||||
@ -88,6 +90,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
devices = {}
|
devices = {}
|
||||||
gateway.platform_callbacks.append(mysensors.pf_callback_factory(
|
gateway.platform_callbacks.append(mysensors.pf_callback_factory(
|
||||||
map_sv_types, devices, add_devices, device_class_map))
|
map_sv_types, devices, add_devices, device_class_map))
|
||||||
|
platform_devices.append(devices)
|
||||||
|
|
||||||
def send_ir_code_service(service):
|
def send_ir_code_service(service):
|
||||||
"""Set IR code as device state attribute."""
|
"""Set IR code as device state attribute."""
|
||||||
@ -95,11 +98,13 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
ir_code = service.data.get(ATTR_IR_CODE)
|
ir_code = service.data.get(ATTR_IR_CODE)
|
||||||
|
|
||||||
if entity_ids:
|
if entity_ids:
|
||||||
_devices = [device for device in devices.values()
|
_devices = [device for gw_devs in platform_devices
|
||||||
|
for device in gw_devs.values()
|
||||||
if isinstance(device, MySensorsIRSwitch) and
|
if isinstance(device, MySensorsIRSwitch) and
|
||||||
device.entity_id in entity_ids]
|
device.entity_id in entity_ids]
|
||||||
else:
|
else:
|
||||||
_devices = [device for device in devices.values()
|
_devices = [device for gw_devs in platform_devices
|
||||||
|
for device in gw_devs.values()
|
||||||
if isinstance(device, MySensorsIRSwitch)]
|
if isinstance(device, MySensorsIRSwitch)]
|
||||||
|
|
||||||
kwargs = {ATTR_IR_CODE: ir_code}
|
kwargs = {ATTR_IR_CODE: ir_code}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user