Skip to content

Commit

Permalink
Debug devices not loading in hass
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Harris committed Feb 21, 2018
1 parent 4963a25 commit 07814b4
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions homeassistant/components/switch/insteon_plm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)

0 comments on commit 07814b4

Please sign in to comment.