mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 11:47:06 +00:00
Refactoring test instance type
This commit is contained in:
parent
496e4cf784
commit
46f5ef54a1
@ -53,10 +53,11 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
|||||||
|
|
||||||
def light_update(event):
|
def light_update(event):
|
||||||
""" Callback for sensor updates from the RFXtrx gateway. """
|
""" Callback for sensor updates from the RFXtrx gateway. """
|
||||||
if isinstance(event.device, rfxtrxmod.LightingDevice):
|
if not isinstance(event.device, rfxtrxmod.LightingDevice):
|
||||||
entity_id = slugify(event.device.id_string.lower())
|
return
|
||||||
|
|
||||||
# Add entity if not exist and the automatic_add is True
|
# Add entity if not exist and the automatic_add is True
|
||||||
|
entity_id = slugify(event.device.id_string.lower())
|
||||||
if entity_id not in rfxtrx.RFX_DEVICES:
|
if entity_id not in rfxtrx.RFX_DEVICES:
|
||||||
automatic_add = config.get('automatic_add', False)
|
automatic_add = config.get('automatic_add', False)
|
||||||
if automatic_add:
|
if automatic_add:
|
||||||
@ -81,6 +82,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
|||||||
else:
|
else:
|
||||||
rfxtrx.RFX_DEVICES[entity_id].turn_off()
|
rfxtrx.RFX_DEVICES[entity_id].turn_off()
|
||||||
|
|
||||||
|
# Subscribe to main rfxtrx events
|
||||||
if light_update not in rfxtrx.RECEIVED_EVT_SUBSCRIBERS:
|
if light_update not in rfxtrx.RECEIVED_EVT_SUBSCRIBERS:
|
||||||
rfxtrx.RECEIVED_EVT_SUBSCRIBERS.append(light_update)
|
rfxtrx.RECEIVED_EVT_SUBSCRIBERS.append(light_update)
|
||||||
|
|
||||||
|
@ -55,9 +55,10 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
|||||||
def switch_update(event):
|
def switch_update(event):
|
||||||
""" Callback for sensor updates from the RFXtrx gateway. """
|
""" Callback for sensor updates from the RFXtrx gateway. """
|
||||||
if isinstance(event.device, LightingDevice):
|
if isinstance(event.device, LightingDevice):
|
||||||
entity_id = slugify(event.device.id_string.lower())
|
return
|
||||||
|
|
||||||
# Add entity if not exist and the automatic_add is True
|
# Add entity if not exist and the automatic_add is True
|
||||||
|
entity_id = slugify(event.device.id_string.lower())
|
||||||
if entity_id not in rfxtrx.RFX_DEVICES:
|
if entity_id not in rfxtrx.RFX_DEVICES:
|
||||||
automatic_add = config.get('automatic_add', False)
|
automatic_add = config.get('automatic_add', False)
|
||||||
if automatic_add:
|
if automatic_add:
|
||||||
@ -82,6 +83,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
|||||||
else:
|
else:
|
||||||
rfxtrx.RFX_DEVICES[entity_id].turn_off()
|
rfxtrx.RFX_DEVICES[entity_id].turn_off()
|
||||||
|
|
||||||
|
# Subscribe to main rfxtrx events
|
||||||
if switch_update not in rfxtrx.RECEIVED_EVT_SUBSCRIBERS:
|
if switch_update not in rfxtrx.RECEIVED_EVT_SUBSCRIBERS:
|
||||||
rfxtrx.RECEIVED_EVT_SUBSCRIBERS.append(switch_update)
|
rfxtrx.RECEIVED_EVT_SUBSCRIBERS.append(switch_update)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user