mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
Fix remaining issues (#18416)
This commit is contained in:
parent
61e0e11156
commit
1cbe080df9
@ -5,7 +5,6 @@ For more details about this platform, please refer to the documentation
|
|||||||
https://home-assistant.io/components/light.niko_home_control/
|
https://home-assistant.io/components/light.niko_home_control/
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import socket
|
|
||||||
|
|
||||||
import voluptuous as vol
|
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."""
|
"""Set up the Niko Home Control light platform."""
|
||||||
import nikohomecontrol
|
import nikohomecontrol
|
||||||
|
|
||||||
host = config.get(CONF_HOST)
|
host = config[CONF_HOST]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
hub = nikohomecontrol.Hub({
|
hub = nikohomecontrol.Hub({
|
||||||
@ -37,11 +36,11 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
'timeout': 20000,
|
'timeout': 20000,
|
||||||
'events': True
|
'events': True
|
||||||
})
|
})
|
||||||
except socket.error as err:
|
except OSError as err:
|
||||||
_LOGGER.error("Unable to access %s (%s)", host, err)
|
_LOGGER.error("Unable to access %s (%s)", host, err)
|
||||||
raise PlatformNotReady
|
raise PlatformNotReady
|
||||||
|
|
||||||
add_devices(
|
add_entities(
|
||||||
[NikoHomeControlLight(light, hub) for light in hub.list_actions()],
|
[NikoHomeControlLight(light, hub) for light in hub.list_actions()],
|
||||||
True)
|
True)
|
||||||
|
|
||||||
@ -76,12 +75,10 @@ class NikoHomeControlLight(Light):
|
|||||||
"""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)
|
||||||
self._light.turn_on()
|
self._light.turn_on()
|
||||||
self._state = True
|
|
||||||
|
|
||||||
def turn_off(self, **kwargs):
|
def turn_off(self, **kwargs):
|
||||||
"""Instruct the light to turn off."""
|
"""Instruct the light to turn off."""
|
||||||
self._light.turn_off()
|
self._light.turn_off()
|
||||||
self._state = False
|
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Fetch new state data for this light."""
|
"""Fetch new state data for this light."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user