mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 14:27:07 +00:00
rfxtrx refactor
This commit is contained in:
parent
23db6e753f
commit
8ffa3684e3
@ -29,19 +29,20 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
|||||||
signal_repetitions = config.get('signal_repetitions', SIGNAL_REPETITIONS)
|
signal_repetitions = config.get('signal_repetitions', SIGNAL_REPETITIONS)
|
||||||
|
|
||||||
for device_id, entity_info in config.get('devices', {}).items():
|
for device_id, entity_info in config.get('devices', {}).items():
|
||||||
if device_id not in rfxtrx.RFX_DEVICES:
|
if device_id in rfxtrx.RFX_DEVICES:
|
||||||
_LOGGER.info("Add %s rfxtrx.light", entity_info[ATTR_NAME])
|
continue
|
||||||
|
_LOGGER.info("Add %s rfxtrx.light", entity_info[ATTR_NAME])
|
||||||
|
|
||||||
# Check if i must fire event
|
# Check if i must fire event
|
||||||
fire_event = entity_info.get(ATTR_FIREEVENT, False)
|
fire_event = entity_info.get(ATTR_FIREEVENT, False)
|
||||||
datas = {ATTR_STATE: False, ATTR_FIREEVENT: fire_event}
|
datas = {ATTR_STATE: False, ATTR_FIREEVENT: fire_event}
|
||||||
|
|
||||||
rfxobject = rfxtrx.get_rfx_object(entity_info[ATTR_PACKETID])
|
rfxobject = rfxtrx.get_rfx_object(entity_info[ATTR_PACKETID])
|
||||||
new_light = RfxtrxLight(
|
new_light = RfxtrxLight(
|
||||||
entity_info[ATTR_NAME], rfxobject, datas,
|
entity_info[ATTR_NAME], rfxobject, datas,
|
||||||
signal_repetitions)
|
signal_repetitions)
|
||||||
rfxtrx.RFX_DEVICES[device_id] = new_light
|
rfxtrx.RFX_DEVICES[device_id] = new_light
|
||||||
lights.append(new_light)
|
lights.append(new_light)
|
||||||
|
|
||||||
add_devices_callback(lights)
|
add_devices_callback(lights)
|
||||||
|
|
||||||
|
@ -33,13 +33,14 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
|||||||
|
|
||||||
sensors = []
|
sensors = []
|
||||||
for device_id, entity_info in config.get('devices', {}).items():
|
for device_id, entity_info in config.get('devices', {}).items():
|
||||||
if device_id not in rfxtrx.RFX_DEVICES:
|
if device_id in rfxtrx.RFX_DEVICES:
|
||||||
_LOGGER.info("Add %s rfxtrx.sensor", entity_info[ATTR_NAME])
|
continue
|
||||||
event = rfxtrx.get_rfx_object(entity_info[ATTR_PACKETID])
|
_LOGGER.info("Add %s rfxtrx.sensor", entity_info[ATTR_NAME])
|
||||||
new_sensor = RfxtrxSensor(event, entity_info[ATTR_NAME],
|
event = rfxtrx.get_rfx_object(entity_info[ATTR_PACKETID])
|
||||||
entity_info.get(ATTR_DATA_TYPE, None))
|
new_sensor = RfxtrxSensor(event, entity_info[ATTR_NAME],
|
||||||
rfxtrx.RFX_DEVICES[device_id] = new_sensor
|
entity_info.get(ATTR_DATA_TYPE, None))
|
||||||
sensors.append(new_sensor)
|
rfxtrx.RFX_DEVICES[device_id] = new_sensor
|
||||||
|
sensors.append(new_sensor)
|
||||||
|
|
||||||
add_devices_callback(sensors)
|
add_devices_callback(sensors)
|
||||||
|
|
||||||
|
@ -29,19 +29,20 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
|||||||
switchs = []
|
switchs = []
|
||||||
signal_repetitions = config.get('signal_repetitions', SIGNAL_REPETITIONS)
|
signal_repetitions = config.get('signal_repetitions', SIGNAL_REPETITIONS)
|
||||||
for device_id, entity_info in config.get('devices', {}).items():
|
for device_id, entity_info in config.get('devices', {}).items():
|
||||||
if device_id not in rfxtrx.RFX_DEVICES:
|
if device_id in rfxtrx.RFX_DEVICES:
|
||||||
_LOGGER.info("Add %s rfxtrx.switch", entity_info[ATTR_NAME])
|
continue
|
||||||
|
_LOGGER.info("Add %s rfxtrx.switch", entity_info[ATTR_NAME])
|
||||||
|
|
||||||
# Check if i must fire event
|
# Check if i must fire event
|
||||||
fire_event = entity_info.get(ATTR_FIREEVENT, False)
|
fire_event = entity_info.get(ATTR_FIREEVENT, False)
|
||||||
datas = {ATTR_STATE: False, ATTR_FIREEVENT: fire_event}
|
datas = {ATTR_STATE: False, ATTR_FIREEVENT: fire_event}
|
||||||
|
|
||||||
rfxobject = rfxtrx.get_rfx_object(entity_info[ATTR_PACKETID])
|
rfxobject = rfxtrx.get_rfx_object(entity_info[ATTR_PACKETID])
|
||||||
newswitch = RfxtrxSwitch(
|
newswitch = RfxtrxSwitch(
|
||||||
entity_info[ATTR_NAME], rfxobject, datas,
|
entity_info[ATTR_NAME], rfxobject, datas,
|
||||||
signal_repetitions)
|
signal_repetitions)
|
||||||
rfxtrx.RFX_DEVICES[device_id] = newswitch
|
rfxtrx.RFX_DEVICES[device_id] = newswitch
|
||||||
switchs.append(newswitch)
|
switchs.append(newswitch)
|
||||||
|
|
||||||
add_devices_callback(switchs)
|
add_devices_callback(switchs)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user