From 07814b4f14cab85e67197812b055a2d71a954b1f Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Wed, 21 Feb 2018 01:31:11 -0500 Subject: [PATCH] Debug devices not loading in hass --- .../components/switch/insteon_plm.py | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/homeassistant/components/switch/insteon_plm.py b/homeassistant/components/switch/insteon_plm.py index 8e8bede9e22074..3083140a954294 100644 --- a/homeassistant/components/switch/insteon_plm.py +++ b/homeassistant/components/switch/insteon_plm.py @@ -19,7 +19,7 @@ @asyncio.coroutine def async_setup_platform(hass, config, async_add_devices, discovery_info=None): """Set up the INSTEON PLM device class for the hass platform.""" - entities = [] + #entities = [] plm = hass.data['insteon_plm'] address = discovery_info['address'] @@ -31,12 +31,14 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None): _LOGGER.debug('Adding device %s with state name %s to Switch platform.', device.address.hex, device.states[state_key].name) + new_entity = None if state_name in ['lightOnOff', 'outletTopOnOff', 'outletBottomOnOff']: - entities.append(InsteonPLMSwitchDevice(device, state_key)) + new_entity = InsteonPLMSwitchDevice(device, state_key) elif state_name == 'openClosedRelay': - entities.append(InsteonPLMOpenClosedDevice(device, state_key)) + new_entity = InsteonPLMOpenClosedDevice(device, state_key) - async_add_devices(entities) + if new_entity is not None: + async_add_devices(new_entity) class InsteonPLMSwitchDevice(SwitchDevice): @@ -99,14 +101,14 @@ def async_turn_off(self, **kwargs): """Turn device off.""" self._insteon_device_state.off() - #@asyncio.coroutine - #def async_added_to_hass(self): - # """Register INSTEON update events.""" - # _LOGGER.debug('Device %s added. Now registering callback.', - # self.address) - # self.hass.async_add_job( - # self._insteon_device_state.register_updates, - # self.async_switch_update) + @asyncio.coroutine + def async_added_to_hass(self): + """Register INSTEON update events.""" + _LOGGER.debug('Device %s added. Now registering callback.', + self.address) + self.hass.async_add_job( + self._insteon_device_state.register_updates, + self.async_switch_update) class InsteonPLMOpenClosedDevice(SwitchDevice): @@ -166,11 +168,11 @@ def async_turn_off(self, **kwargs): """Turn device off.""" self._insteon_device_state.close() - #@asyncio.coroutine - #def async_added_to_hass(self): - # """Register INSTEON update events.""" - # _LOGGER.debug('Device %s added. Now registering callback.', - # self.address) - # self.hass.async_add_job( - # self._insteon_device_state.register_updates, - # self.async_relay_update) + @asyncio.coroutine + def async_added_to_hass(self): + """Register INSTEON update events.""" + _LOGGER.debug('Device %s added. Now registering callback.', + self.address) + self.hass.async_add_job( + self._insteon_device_state.register_updates, + self.async_relay_update)