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:
1 parent
9bfdff0be1
commit
e7dc96397c
6 files changed
+63
-34
No files matched your search
@@ -4,6 +4,7 @@ Support for Lutron Caseta switches.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sitch.lutron_caseta/
|
||||
"""
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
from homeassistant.components.lutron_caseta import (
|
||||
@@ -16,7 +17,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 Lutron switch."""
|
||||
devs = []
|
||||
bridge = hass.data[LUTRON_CASETA_SMARTBRIDGE]
|
||||
@@ -26,18 +28,20 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
dev = LutronCasetaLight(switch_device, bridge)
|
||||
devs.append(dev)
|
||||
|
||||
add_devices(devs, True)
|
||||
async_add_devices(devs, True)
|
||||
return True
|
||||
|
||||
|
||||
class LutronCasetaLight(LutronCasetaDevice, SwitchDevice):
|
||||
"""Representation of a Lutron Caseta switch."""
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
@asyncio.coroutine
|
||||
def async_turn_on(self, **kwargs):
|
||||
"""Turn the switch on."""
|
||||
self._smartbridge.turn_on(self._device_id)
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
@asyncio.coroutine
|
||||
def async_turn_off(self, **kwargs):
|
||||
"""Turn the switch off."""
|
||||
self._smartbridge.turn_off(self._device_id)
|
||||
|
||||
@@ -46,7 +50,8 @@ class LutronCasetaLight(LutronCasetaDevice, SwitchDevice):
|
||||
"""Return true if device is on."""
|
||||
return self._state["current_state"] > 0
|
||||
|
||||
def update(self):
|
||||
@asyncio.coroutine
|
||||
def async_update(self):
|
||||
"""Update when forcing a refresh of the device."""
|
||||
self._state = self._smartbridge.get_device_by_id(self._device_id)
|
||||
_LOGGER.debug(self._state)
|
||||
Reference in new issue
Block a user