diff --git a/homeassistant/components/cover/lutron_caseta.py b/homeassistant/components/cover/lutron_caseta.py new file mode 100644 index 00000000000..2c411c61ba4 --- /dev/null +++ b/homeassistant/components/cover/lutron_caseta.py @@ -0,0 +1,62 @@ +""" +Support for Lutron Caseta SerenaRollerShade. + +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/cover.lutron_caseta/ +""" +import logging + + +from homeassistant.components.cover import ( + CoverDevice, SUPPORT_OPEN, SUPPORT_CLOSE) +from homeassistant.components.lutron_caseta import ( + LUTRON_CASETA_SMARTBRIDGE, LutronCasetaDevice) + + +_LOGGER = logging.getLogger(__name__) + +DEPENDENCIES = ['lutron_caseta'] + + +# pylint: disable=unused-argument +def setup_platform(hass, config, add_devices, discovery_info=None): + """Set up the Lutron Caseta Serena shades as a cover device.""" + devs = [] + bridge = hass.data[LUTRON_CASETA_SMARTBRIDGE] + cover_devices = bridge.get_devices_by_types(["SerenaRollerShade"]) + for cover_device in cover_devices: + dev = LutronCasetaCover(cover_device, bridge) + devs.append(dev) + + add_devices(devs, True) + + +class LutronCasetaCover(LutronCasetaDevice, CoverDevice): + """Representation of a Lutron Serena shade.""" + + @property + def supported_features(self): + """Flag supported features.""" + return SUPPORT_OPEN | SUPPORT_CLOSE + + @property + def is_closed(self): + """Return if the cover is closed.""" + return self._state["current_state"] < 1 + + def close_cover(self): + """Close the cover.""" + self._smartbridge.set_value(self._device_id, 0) + + def open_cover(self): + """Open the cover.""" + self._smartbridge.set_value(self._device_id, 100) + + def set_cover_position(self, position, **kwargs): + """Move the roller shutter to a specific position.""" + self._smartbridge.set_value(self._device_id, position) + + def update(self): + """Call when forcing a refresh of the device.""" + self._state = self._smartbridge.get_device_by_id(self._device_id) + _LOGGER.debug(self._state) diff --git a/homeassistant/components/lutron_caseta.py b/homeassistant/components/lutron_caseta.py index 7dd5c647213..e2ad733fb36 100644 --- a/homeassistant/components/lutron_caseta.py +++ b/homeassistant/components/lutron_caseta.py @@ -44,7 +44,7 @@ def setup(hass, base_config): _LOGGER.info("Connected to Lutron smartbridge at %s", config[CONF_HOST]) - for component in ('light', 'switch'): + for component in ('light', 'switch', 'cover'): discovery.load_platform(hass, component, DOMAIN, {}, config) return True