Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 9 additions & 28 deletions homeassistant/components/niko_home_control/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# 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
Expand All @@ -18,7 +18,6 @@

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_HOST): cv.string,
vol.Optional(CONF_SCAN_INTERVAL, default=SCAN_INTERVAL): cv.time_period,
})


Expand Down Expand Up @@ -56,27 +55,12 @@ def __init__(self, light, data):
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."""
Expand All @@ -92,16 +76,16 @@ def is_on(self):
"""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."""
Expand Down Expand Up @@ -134,10 +118,7 @@ async def async_update(self):

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")
2 changes: 1 addition & 1 deletion homeassistant/components/niko_home_control/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": []
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down