mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 15:17:35 +00:00
Fix niko home control dependency installation (#23176)
* Upgrade niko-home-control library * Fix additional feedback * Lint
This commit is contained in:
parent
4a2a130bfa
commit
6e4083d7f4
@ -7,7 +7,7 @@ import voluptuous as vol
|
|||||||
# Import the device class from the component that you want to support
|
# Import the device class from the component that you want to support
|
||||||
from homeassistant.components.light import (
|
from homeassistant.components.light import (
|
||||||
ATTR_BRIGHTNESS, PLATFORM_SCHEMA, Light)
|
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
|
from homeassistant.exceptions import PlatformNotReady
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.util import Throttle
|
from homeassistant.util import Throttle
|
||||||
@ -18,7 +18,6 @@ SCAN_INTERVAL = timedelta(seconds=30)
|
|||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
vol.Required(CONF_HOST): cv.string,
|
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._name = light.name
|
||||||
self._state = light.is_on
|
self._state = light.is_on
|
||||||
self._brightness = None
|
self._brightness = None
|
||||||
_LOGGER.debug("Init new light: %s", light.name)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""Return unique ID for light."""
|
"""Return unique ID for light."""
|
||||||
return self._unique_id
|
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
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the display name of this light."""
|
"""Return the display name of this light."""
|
||||||
@ -92,16 +76,16 @@ class NikoHomeControlLight(Light):
|
|||||||
"""Return true if light is on."""
|
"""Return true if light is on."""
|
||||||
return self._state
|
return self._state
|
||||||
|
|
||||||
async def async_turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
"""Instruct the light to turn on."""
|
"""Instruct the light to turn on."""
|
||||||
self._light.brightness = kwargs.get(ATTR_BRIGHTNESS, 255)
|
self._light.brightness = kwargs.get(ATTR_BRIGHTNESS, 255)
|
||||||
_LOGGER.debug('Turn on: %s', self.name)
|
_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."""
|
"""Instruct the light to turn off."""
|
||||||
_LOGGER.debug('Turn off: %s', self.name)
|
_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):
|
async def async_update(self):
|
||||||
"""Get the latest data from NikoHomeControl API."""
|
"""Get the latest data from NikoHomeControl API."""
|
||||||
@ -134,10 +118,7 @@ class NikoHomeControlData:
|
|||||||
|
|
||||||
def get_state(self, aid):
|
def get_state(self, aid):
|
||||||
"""Find and filter state based on action id."""
|
"""Find and filter state based on action id."""
|
||||||
return next(filter(lambda a: a['id'] == aid, self.data))['value1'] != 0
|
for state in self.data:
|
||||||
|
if state['id'] == aid:
|
||||||
def info_swversion(self, light):
|
return state['value1'] != 0
|
||||||
"""Return software version information."""
|
_LOGGER.error("Failed to retrieve state off unknown light")
|
||||||
if self._system_info is None:
|
|
||||||
self._system_info = self._nhc.system_info()
|
|
||||||
return self._system_info['swversion']
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"name": "Niko home control",
|
"name": "Niko home control",
|
||||||
"documentation": "https://www.home-assistant.io/components/niko_home_control",
|
"documentation": "https://www.home-assistant.io/components/niko_home_control",
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"niko-home-control==0.2.0"
|
"niko-home-control==0.2.1"
|
||||||
],
|
],
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"codeowners": []
|
"codeowners": []
|
||||||
|
@ -746,7 +746,7 @@ netdisco==2.6.0
|
|||||||
neurio==0.3.1
|
neurio==0.3.1
|
||||||
|
|
||||||
# homeassistant.components.niko_home_control
|
# homeassistant.components.niko_home_control
|
||||||
niko-home-control==0.2.0
|
niko-home-control==0.2.1
|
||||||
|
|
||||||
# homeassistant.components.nilu
|
# homeassistant.components.nilu
|
||||||
niluclient==0.1.2
|
niluclient==0.1.2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user