Skip to content
Merged
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
11 changes: 4 additions & 7 deletions homeassistant/components/light/niko_home_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
https://home-assistant.io/components/light.niko_home_control/
"""
import logging
import socket

import voluptuous as vol

Expand All @@ -24,11 +23,11 @@
})


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({
Expand All @@ -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)

Expand Down Expand Up @@ -76,12 +75,10 @@ def turn_on(self, **kwargs):
"""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."""
Expand Down