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
https://home-assistant.io/components/cover.lutron_caseta/
"""
import logging
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 (
LUTRON_CASETA_SMARTBRIDGE, LutronCasetaDevice)
@ -19,11 +19,10 @@ 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."""
"""Set up the Lutron Caseta shades as a cover device."""
devs = []
bridge = hass.data[LUTRON_CASETA_SMARTBRIDGE]
cover_devices = bridge.get_devices_by_types(["SerenaRollerShade",
"SerenaHoneycombShade"])
cover_devices = bridge.get_devices_by_domain(DOMAIN)
for cover_device in cover_devices:
dev = LutronCasetaCover(cover_device, bridge)
devs.append(dev)
@ -32,7 +31,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class LutronCasetaCover(LutronCasetaDevice, CoverDevice):
"""Representation of a Lutron Serena shade."""
"""Representation of a Lutron shade."""
@property
def supported_features(self):
@ -42,24 +41,26 @@ class LutronCasetaCover(LutronCasetaDevice, CoverDevice):
@property
def is_closed(self):
"""Return if the cover is closed."""
return self._state["current_state"] < 1
return self._state['current_state'] < 1
@property
def current_cover_position(self):
"""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."""
self._smartbridge.set_value(self._device_id, 0)
def open_cover(self):
def open_cover(self, **kwargs):
"""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 set_cover_position(self, **kwargs):
"""Move the shade to a specific position."""
if ATTR_POSITION in kwargs:
position = kwargs[ATTR_POSITION]
self._smartbridge.set_value(self._device_id, position)
def update(self):
"""Call when forcing a refresh of the device."""

View file

@ -7,7 +7,7 @@ https://home-assistant.io/components/light.lutron_caseta/
import logging
from homeassistant.components.light import (
ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light)
ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light, DOMAIN)
from homeassistant.components.light.lutron import (
to_hass_level, to_lutron_level)
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."""
devs = []
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:
dev = LutronCasetaLight(light_device, bridge)
devs.append(dev)

View file

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

View file

@ -8,7 +8,7 @@ import logging
from homeassistant.components.lutron_caseta import (
LUTRON_CASETA_SMARTBRIDGE, LutronCasetaDevice)
from homeassistant.components.switch import SwitchDevice
from homeassistant.components.switch import SwitchDevice, DOMAIN
_LOGGER = logging.getLogger(__name__)
@ -20,7 +20,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up Lutron switch."""
devs = []
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:
dev = LutronCasetaLight(switch_device, bridge)

View file

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