core/homeassistant/components/light/isy994.py

48 lines
1.4 KiB
Python
Raw Normal View History

2015-08-11 12:55:47 +00:00
"""
Support for ISY994 lights.
2015-11-09 12:12:18 +00:00
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/isy994/
2015-08-11 12:55:47 +00:00
"""
import logging
2016-02-19 05:27:50 +00:00
from homeassistant.components.isy994 import (
HIDDEN_STRING, ISY, SENSOR_STRING, ISYDeviceABC)
from homeassistant.components.light import ATTR_BRIGHTNESS
2016-02-19 05:27:50 +00:00
from homeassistant.const import STATE_OFF, STATE_ON
def setup_platform(hass, config, add_devices, discovery_info=None):
2016-03-07 21:08:21 +00:00
"""Setup the ISY994 platform."""
logger = logging.getLogger(__name__)
devs = []
2016-03-07 21:08:21 +00:00
if ISY is None or not ISY.connected:
logger.error('A connection has not been made to the ISY controller.')
return False
2016-03-07 21:08:21 +00:00
# Import dimmable nodes
for (path, node) in ISY.nodes:
if node.dimmable and SENSOR_STRING not in node.name:
if HIDDEN_STRING in path:
node.name += HIDDEN_STRING
devs.append(ISYLightDevice(node))
add_devices(devs)
class ISYLightDevice(ISYDeviceABC):
2016-03-07 21:08:21 +00:00
"""Representation of a ISY light."""
_domain = 'light'
_dtype = 'analog'
_attrs = {ATTR_BRIGHTNESS: 'value'}
_onattrs = [ATTR_BRIGHTNESS]
_states = [STATE_ON, STATE_OFF]
def _attr_filter(self, attr):
2016-03-07 21:08:21 +00:00
"""Filter brightness out of entity while off."""
if ATTR_BRIGHTNESS in attr and not self.is_on:
del attr[ATTR_BRIGHTNESS]
return attr