rfxtrx refactor

This commit is contained in:
Daniel committed 2016-02-25 17:40:24 +01:00
1 parent 23db6e753f
commit 8ffa3684e3
3 files changed
+32 -29

No files matched your search

+12 -11
View File
@@ -29,19 +29,20 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
switchs = []
signal_repetitions = config.get('signal_repetitions', SIGNAL_REPETITIONS)
for device_id, entity_info in config.get('devices', {}).items():
if device_id not in rfxtrx.RFX_DEVICES:
_LOGGER.info("Add %s rfxtrx.switch", entity_info[ATTR_NAME])
if device_id in rfxtrx.RFX_DEVICES:
continue
_LOGGER.info("Add %s rfxtrx.switch", entity_info[ATTR_NAME])
# Check if i must fire event
fire_event = entity_info.get(ATTR_FIREEVENT, False)
datas = {ATTR_STATE: False, ATTR_FIREEVENT: fire_event}
# Check if i must fire event
fire_event = entity_info.get(ATTR_FIREEVENT, False)
datas = {ATTR_STATE: False, ATTR_FIREEVENT: fire_event}
rfxobject = rfxtrx.get_rfx_object(entity_info[ATTR_PACKETID])
newswitch = RfxtrxSwitch(
entity_info[ATTR_NAME], rfxobject, datas,
signal_repetitions)
rfxtrx.RFX_DEVICES[device_id] = newswitch
switchs.append(newswitch)
rfxobject = rfxtrx.get_rfx_object(entity_info[ATTR_PACKETID])
newswitch = RfxtrxSwitch(
entity_info[ATTR_NAME], rfxobject, datas,
signal_repetitions)
rfxtrx.RFX_DEVICES[device_id] = newswitch
switchs.append(newswitch)
add_devices_callback(switchs)