upgrade to new pylutron_caseta with TLS (#10286)

* upgrade to new pylutron with TLS

* rename configuration options

* change more methods to coroutines

* use async_add_devices
This commit is contained in:
Matthew Donoughe authored and Pascal Vizeli committed 2017-11-10 12:17:25 +01:00
1 parent 9bfdff0be1
commit e7dc96397c
6 files changed
+63 -34

No files matched your search

@@ -4,6 +4,7 @@ Support for Lutron Caseta lights.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/light.lutron_caseta/
"""
import asyncio
import logging
from homeassistant.components.light import (
@@ -19,7 +20,8 @@ DEPENDENCIES = ['lutron_caseta']
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
@asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Set up the Lutron Caseta lights."""
devs = []
bridge = hass.data[LUTRON_CASETA_SMARTBRIDGE]
@@ -28,7 +30,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
dev = LutronCasetaLight(light_device, bridge)
devs.append(dev)
add_devices(devs, True)
async_add_devices(devs, True)
class LutronCasetaLight(LutronCasetaDevice, Light):
@@ -44,7 +46,8 @@ class LutronCasetaLight(LutronCasetaDevice, Light):
"""Return the brightness of the light."""
return to_hass_level(self._state["current_state"])
def turn_on(self, **kwargs):
@asyncio.coroutine
def async_turn_on(self, **kwargs):
"""Turn the light on."""
if ATTR_BRIGHTNESS in kwargs:
brightness = kwargs[ATTR_BRIGHTNESS]
@@ -53,7 +56,8 @@ class LutronCasetaLight(LutronCasetaDevice, Light):
self._smartbridge.set_value(self._device_id,
to_lutron_level(brightness))
def turn_off(self, **kwargs):
@asyncio.coroutine
def async_turn_off(self, **kwargs):
"""Turn the light off."""
self._smartbridge.set_value(self._device_id, 0)
@@ -62,7 +66,8 @@ class LutronCasetaLight(LutronCasetaDevice, Light):
"""Return true if device is on."""
return self._state["current_state"] > 0
def update(self):
@asyncio.coroutine
def async_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)