Fix remaining issues (#18416)

pull/18748/head
Fabian Affolter 2018-11-27 13:21:42 +01:00 committed by Paulus Schoutsen
parent 61e0e11156
commit 1cbe080df9
1 changed files with 4 additions and 7 deletions

View File

@ -5,7 +5,6 @@ For more details about this platform, please refer to the documentation
https://home-assistant.io/components/light.niko_home_control/
"""
import logging
import socket
import voluptuous as vol
@ -24,11 +23,11 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
})
def setup_platform(hass, config, add_devices, discovery_info=None):
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Niko Home Control light platform."""
import nikohomecontrol
host = config.get(CONF_HOST)
host = config[CONF_HOST]
try:
hub = nikohomecontrol.Hub({
@ -37,11 +36,11 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
'timeout': 20000,
'events': True
})
except socket.error as err:
except OSError as err:
_LOGGER.error("Unable to access %s (%s)", host, err)
raise PlatformNotReady
add_devices(
add_entities(
[NikoHomeControlLight(light, hub) for light in hub.list_actions()],
True)
@ -76,12 +75,10 @@ class NikoHomeControlLight(Light):
"""Instruct the light to turn on."""
self._light.brightness = kwargs.get(ATTR_BRIGHTNESS, 255)
self._light.turn_on()
self._state = True
def turn_off(self, **kwargs):
"""Instruct the light to turn off."""
self._light.turn_off()
self._state = False
def update(self):
"""Fetch new state data for this light."""