From 6e4083d7f4f3e2dc5828fcbd81fb7295c2106233 Mon Sep 17 00:00:00 2001 From: Dries De Peuter Date: Thu, 18 Apr 2019 10:52:48 +0200 Subject: [PATCH] Fix niko home control dependency installation (#23176) * Upgrade niko-home-control library * Fix additional feedback * Lint --- .../components/niko_home_control/light.py | 37 +++++-------------- .../niko_home_control/manifest.json | 2 +- requirements_all.txt | 2 +- 3 files changed, 11 insertions(+), 30 deletions(-) diff --git a/homeassistant/components/niko_home_control/light.py b/homeassistant/components/niko_home_control/light.py index aabee41694c..17b5f60cf44 100644 --- a/homeassistant/components/niko_home_control/light.py +++ b/homeassistant/components/niko_home_control/light.py @@ -7,7 +7,7 @@ import voluptuous as vol # Import the device class from the component that you want to support from homeassistant.components.light import ( ATTR_BRIGHTNESS, PLATFORM_SCHEMA, Light) -from homeassistant.const import CONF_HOST, CONF_SCAN_INTERVAL +from homeassistant.const import CONF_HOST from homeassistant.exceptions import PlatformNotReady import homeassistant.helpers.config_validation as cv from homeassistant.util import Throttle @@ -18,7 +18,6 @@ SCAN_INTERVAL = timedelta(seconds=30) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_HOST): cv.string, - vol.Optional(CONF_SCAN_INTERVAL, default=SCAN_INTERVAL): cv.time_period, }) @@ -56,27 +55,12 @@ class NikoHomeControlLight(Light): self._name = light.name self._state = light.is_on self._brightness = None - _LOGGER.debug("Init new light: %s", light.name) @property def unique_id(self): """Return unique ID for light.""" return self._unique_id - @property - def device_info(self): - """Return device info for light.""" - return { - 'identifiers': { - ('niko_home_control', self.unique_id) - }, - 'name': self.name, - 'manufacturer': 'Niko group nv', - 'model': 'Niko connected controller', - 'sw_version': self._data.info_swversion(self._light), - 'via_hub': ('niko_home_control'), - } - @property def name(self): """Return the display name of this light.""" @@ -92,16 +76,16 @@ class NikoHomeControlLight(Light): """Return true if light is on.""" return self._state - async def async_turn_on(self, **kwargs): + def turn_on(self, **kwargs): """Instruct the light to turn on.""" self._light.brightness = kwargs.get(ATTR_BRIGHTNESS, 255) _LOGGER.debug('Turn on: %s', self.name) - await self._data.hass.async_add_executor_job(self._light.turn_on) + self._light.turn_on() - async def async_turn_off(self, **kwargs): + def turn_off(self, **kwargs): """Instruct the light to turn off.""" _LOGGER.debug('Turn off: %s', self.name) - await self._data.hass.async_add_executor_job(self._light.turn_off) + self._light.turn_off() async def async_update(self): """Get the latest data from NikoHomeControl API.""" @@ -134,10 +118,7 @@ class NikoHomeControlData: def get_state(self, aid): """Find and filter state based on action id.""" - return next(filter(lambda a: a['id'] == aid, self.data))['value1'] != 0 - - def info_swversion(self, light): - """Return software version information.""" - if self._system_info is None: - self._system_info = self._nhc.system_info() - return self._system_info['swversion'] + for state in self.data: + if state['id'] == aid: + return state['value1'] != 0 + _LOGGER.error("Failed to retrieve state off unknown light") diff --git a/homeassistant/components/niko_home_control/manifest.json b/homeassistant/components/niko_home_control/manifest.json index c1c095f989a..8cb58a7b74c 100644 --- a/homeassistant/components/niko_home_control/manifest.json +++ b/homeassistant/components/niko_home_control/manifest.json @@ -3,7 +3,7 @@ "name": "Niko home control", "documentation": "https://www.home-assistant.io/components/niko_home_control", "requirements": [ - "niko-home-control==0.2.0" + "niko-home-control==0.2.1" ], "dependencies": [], "codeowners": [] diff --git a/requirements_all.txt b/requirements_all.txt index b861e8e2a49..c4411eb1789 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -746,7 +746,7 @@ netdisco==2.6.0 neurio==0.3.1 # homeassistant.components.niko_home_control -niko-home-control==0.2.0 +niko-home-control==0.2.1 # homeassistant.components.nilu niluclient==0.1.2