diff --git a/homeassistant/components/light/rfxtrx.py b/homeassistant/components/light/rfxtrx.py index 69ea23a6d4b..ed9c8f99dfc 100644 --- a/homeassistant/components/light/rfxtrx.py +++ b/homeassistant/components/light/rfxtrx.py @@ -36,24 +36,30 @@ DOMAIN = "rfxtrx" def setup_platform(hass, config, add_devices_callback, discovery_info=None): """ Setup the RFXtrx platform. """ + logger = logging.getLogger(__name__) + # Add light from config file + lights = [] devices = config.get('devices') for entity_id, entity_name in devices.items(): if entity_id not in rfxtrx.RFX_DEVICES: + logger.info("Add %s rfxtrx.light" % entity_name) new_light = RfxtrxLight(entity_name, False) rfxtrx.RFX_DEVICES[entity_id] = new_light + lights.append(new_light) - add_devices_callback(rfxtrx.RFX_DEVICES.values()) + add_devices_callback(lights) def light_update(event): """ Callback for sensor updates from the RFXtrx gateway. """ if isinstance(event.device, LightingDevice): - entity_id = '%s-%s' % (event.device.type_string.lower(), slugify(event.device.id_string.lower())) + entity_id = slugify(event.device.id_string.lower()) # Add entity if not exist and the automatic_add is True if entity_id not in rfxtrx.RFX_DEVICES: automatic_add = config.get('automatic_add', False) if automatic_add: + logger.info("Automatic add %s rfxtrx.light" % entity_name) new_light = RfxtrxLight(entity_id, False) rfxtrx.RFX_DEVICES[entity_id] = new_light add_devices_callback([new_light]) diff --git a/homeassistant/components/switch/rfxtrx.py b/homeassistant/components/switch/rfxtrx.py index a7b39655249..3f2b957cc25 100644 --- a/homeassistant/components/switch/rfxtrx.py +++ b/homeassistant/components/switch/rfxtrx.py @@ -36,24 +36,30 @@ DOMAIN = "rfxtrx" def setup_platform(hass, config, add_devices_callback, discovery_info=None): """ Setup the RFXtrx platform. """ + logger = logging.getLogger(__name__) + # Add switch from config file + switchs = [] devices = config.get('devices') for entity_id, entity_name in devices.items(): if entity_id not in rfxtrx.RFX_DEVICES: + logger.info("Add %s rfxtrx.switch" % entity_name) new_switch = RfxtrxSwitch(entity_name, False) rfxtrx.RFX_DEVICES[entity_id] = new_switch + switchs.append(new_switch) - add_devices_callback(rfxtrx.RFX_DEVICES.values()) + add_devices_callback(switchs) def switch_update(event): """ Callback for sensor updates from the RFXtrx gateway. """ if isinstance(event.device, LightingDevice): - entity_id = '%s-%s' % (event.device.type_string.lower(), slugify(event.device.id_string.lower())) + entity_id = slugify(event.device.id_string.lower()) # Add entity if not exist and the automatic_add is True if entity_id not in rfxtrx.RFX_DEVICES: automatic_add = config.get('automatic_add', False) if automatic_add: + logger.info("Automatic add %s rfxtrx.switch" % entity_name) new_switch = RfxtrxSwitch(entity_id, False) rfxtrx.RFX_DEVICES[entity_id] = new_switch add_devices_callback([new_switch])