Improved Lutron Caseta shade support (#9302)

This commit is contained in:
upsert 2017-09-05 05:30:36 -04:00 committed by Pascal Vizeli
parent ed699896cb
commit c3a91000ac
5 changed files with 21 additions and 20 deletions

View File

@ -1,14 +1,14 @@
""" """
Support for Lutron Caseta SerenaRollerShade. Support for Lutron Caseta shades.
For more details about this platform, please refer to the documentation at For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/cover.lutron_caseta/ https://home-assistant.io/components/cover.lutron_caseta/
""" """
import logging import logging
from homeassistant.components.cover import ( from homeassistant.components.cover import (
CoverDevice, SUPPORT_OPEN, SUPPORT_CLOSE, SUPPORT_SET_POSITION) CoverDevice, SUPPORT_OPEN, SUPPORT_CLOSE, SUPPORT_SET_POSITION,
ATTR_POSITION, DOMAIN)
from homeassistant.components.lutron_caseta import ( from homeassistant.components.lutron_caseta import (
LUTRON_CASETA_SMARTBRIDGE, LutronCasetaDevice) LUTRON_CASETA_SMARTBRIDGE, LutronCasetaDevice)
@ -19,11 +19,10 @@ DEPENDENCIES = ['lutron_caseta']
# pylint: disable=unused-argument # pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up the Lutron Caseta Serena shades as a cover device.""" """Set up the Lutron Caseta shades as a cover device."""
devs = [] devs = []
bridge = hass.data[LUTRON_CASETA_SMARTBRIDGE] bridge = hass.data[LUTRON_CASETA_SMARTBRIDGE]
cover_devices = bridge.get_devices_by_types(["SerenaRollerShade", cover_devices = bridge.get_devices_by_domain(DOMAIN)
"SerenaHoneycombShade"])
for cover_device in cover_devices: for cover_device in cover_devices:
dev = LutronCasetaCover(cover_device, bridge) dev = LutronCasetaCover(cover_device, bridge)
devs.append(dev) devs.append(dev)
@ -32,7 +31,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class LutronCasetaCover(LutronCasetaDevice, CoverDevice): class LutronCasetaCover(LutronCasetaDevice, CoverDevice):
"""Representation of a Lutron Serena shade.""" """Representation of a Lutron shade."""
@property @property
def supported_features(self): def supported_features(self):
@ -42,24 +41,26 @@ class LutronCasetaCover(LutronCasetaDevice, CoverDevice):
@property @property
def is_closed(self): def is_closed(self):
"""Return if the cover is closed.""" """Return if the cover is closed."""
return self._state["current_state"] < 1 return self._state['current_state'] < 1
@property @property
def current_cover_position(self): def current_cover_position(self):
"""Return the current position of cover.""" """Return the current position of cover."""
return self._state["current_state"] return self._state['current_state']
def close_cover(self): def close_cover(self, **kwargs):
"""Close the cover.""" """Close the cover."""
self._smartbridge.set_value(self._device_id, 0) self._smartbridge.set_value(self._device_id, 0)
def open_cover(self): def open_cover(self, **kwargs):
"""Open the cover.""" """Open the cover."""
self._smartbridge.set_value(self._device_id, 100) self._smartbridge.set_value(self._device_id, 100)
def set_cover_position(self, position, **kwargs): def set_cover_position(self, **kwargs):
"""Move the roller shutter to a specific position.""" """Move the shade to a specific position."""
self._smartbridge.set_value(self._device_id, position) if ATTR_POSITION in kwargs:
position = kwargs[ATTR_POSITION]
self._smartbridge.set_value(self._device_id, position)
def update(self): def update(self):
"""Call when forcing a refresh of the device.""" """Call when forcing a refresh of the device."""

View File

@ -7,7 +7,7 @@ https://home-assistant.io/components/light.lutron_caseta/
import logging import logging
from homeassistant.components.light import ( from homeassistant.components.light import (
ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light) ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light, DOMAIN)
from homeassistant.components.light.lutron import ( from homeassistant.components.light.lutron import (
to_hass_level, to_lutron_level) to_hass_level, to_lutron_level)
from homeassistant.components.lutron_caseta import ( from homeassistant.components.lutron_caseta import (
@ -23,7 +23,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up the Lutron Caseta lights.""" """Set up the Lutron Caseta lights."""
devs = [] devs = []
bridge = hass.data[LUTRON_CASETA_SMARTBRIDGE] bridge = hass.data[LUTRON_CASETA_SMARTBRIDGE]
light_devices = bridge.get_devices_by_types(["WallDimmer", "PlugInDimmer"]) light_devices = bridge.get_devices_by_domain(DOMAIN)
for light_device in light_devices: for light_device in light_devices:
dev = LutronCasetaLight(light_device, bridge) dev = LutronCasetaLight(light_device, bridge)
devs.append(dev) devs.append(dev)

View File

@ -14,7 +14,7 @@ from homeassistant.const import CONF_HOST
from homeassistant.helpers import discovery from homeassistant.helpers import discovery
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
REQUIREMENTS = ['pylutron-caseta==0.2.7'] REQUIREMENTS = ['pylutron-caseta==0.2.8']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)

View File

@ -8,7 +8,7 @@ import logging
from homeassistant.components.lutron_caseta import ( from homeassistant.components.lutron_caseta import (
LUTRON_CASETA_SMARTBRIDGE, LutronCasetaDevice) LUTRON_CASETA_SMARTBRIDGE, LutronCasetaDevice)
from homeassistant.components.switch import SwitchDevice from homeassistant.components.switch import SwitchDevice, DOMAIN
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -20,7 +20,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up Lutron switch.""" """Set up Lutron switch."""
devs = [] devs = []
bridge = hass.data[LUTRON_CASETA_SMARTBRIDGE] bridge = hass.data[LUTRON_CASETA_SMARTBRIDGE]
switch_devices = bridge.get_devices_by_type("WallSwitch") switch_devices = bridge.get_devices_by_domain(DOMAIN)
for switch_device in switch_devices: for switch_device in switch_devices:
dev = LutronCasetaLight(switch_device, bridge) dev = LutronCasetaLight(switch_device, bridge)

View File

@ -646,7 +646,7 @@ pylitejet==0.1
pyloopenergy==0.0.17 pyloopenergy==0.0.17
# homeassistant.components.lutron_caseta # homeassistant.components.lutron_caseta
pylutron-caseta==0.2.7 pylutron-caseta==0.2.8
# homeassistant.components.lutron # homeassistant.components.lutron
pylutron==0.1.0 pylutron==0.1.0