Skip to content

Commit

Permalink
make device_discovered synchronous
Browse files Browse the repository at this point in the history
  • Loading branch information
heythisisnate committed May 16, 2018
1 parent 3e7d4fc commit 5315fb1
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions homeassistant/components/konnected.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,19 @@ async def async_setup(hass, config):
if DOMAIN not in hass.data:
hass.data[DOMAIN] = {CONF_ACCESS_TOKEN: access_token}

async def async_device_discovered(service, info):
def device_discovered(service, info):
"""Call when a Konnected device has been discovered."""
_LOGGER.debug("Discovered a new Konnected device: %s", info)
host = info.get(CONF_HOST)
port = info.get(CONF_PORT)

device = KonnectedDevice(hass, host, port, cfg)
await device.async_setup()
device.setup()

discovery.async_listen(
hass,
SERVICE_KONNECTED,
async_device_discovered)
device_discovered)

hass.http.register_view(KonnectedView(access_token))

Expand All @@ -121,17 +121,17 @@ def __init__(self, hass, host, port, config):
self.status = self.client.get_status()
_LOGGER.info('Initialized Konnected device %s', self.device_id)

async def async_setup(self):
def setup(self):
"""Set up a newly discovered Konnected device."""
user_config = self.config()
if user_config:
_LOGGER.debug('Configuring Konnected device %s', self.device_id)
self.save_data()
await self.async_sync_device_config()
await discovery.async_load_platform(
self.sync_device_config()
discovery.load_platform(
self.hass, 'binary_sensor',
DOMAIN, {'device_id': self.device_id})
await discovery.async_load_platform(
discovery.load_platform(
self.hass, 'switch', DOMAIN,
{'device_id': self.device_id})

Expand Down Expand Up @@ -235,7 +235,7 @@ def actuator_configuration(self):
for p, data in
self.stored_configuration[CONF_SWITCHES].items()]

async def async_sync_device_config(self):
def sync_device_config(self):
"""Sync the new pin configuration to the Konnected device."""
desired_sensor_configuration = self.sensor_configuration()
current_sensor_configuration = [
Expand Down

0 comments on commit 5315fb1

Please sign in to comment.