diff --git a/homeassistant/components/lutron_caseta/__init__.py b/homeassistant/components/lutron_caseta/__init__.py index 40b65293f1d..37a9d12af95 100644 --- a/homeassistant/components/lutron_caseta/__init__.py +++ b/homeassistant/components/lutron_caseta/__init__.py @@ -64,9 +64,9 @@ async def async_setup_entry(hass, config_entry): """Set up a bridge from a config entry.""" host = config_entry.data[CONF_HOST] - keyfile = config_entry.data[CONF_KEYFILE] - certfile = config_entry.data[CONF_CERTFILE] - ca_certs = config_entry.data[CONF_CA_CERTS] + keyfile = hass.config.path(config_entry.data[CONF_KEYFILE]) + certfile = hass.config.path(config_entry.data[CONF_CERTFILE]) + ca_certs = hass.config.path(config_entry.data[CONF_CA_CERTS]) bridge = Smartbridge.create_tls( hostname=host, keyfile=keyfile, certfile=certfile, ca_certs=ca_certs diff --git a/homeassistant/components/lutron_caseta/config_flow.py b/homeassistant/components/lutron_caseta/config_flow.py index 3a5a4a151a1..1290d88b09c 100644 --- a/homeassistant/components/lutron_caseta/config_flow.py +++ b/homeassistant/components/lutron_caseta/config_flow.py @@ -83,9 +83,9 @@ class LutronCasetaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): try: bridge = Smartbridge.create_tls( hostname=self.data[CONF_HOST], - keyfile=self.data[CONF_KEYFILE], - certfile=self.data[CONF_CERTFILE], - ca_certs=self.data[CONF_CA_CERTS], + keyfile=self.hass.config.path(self.data[CONF_KEYFILE]), + certfile=self.hass.config.path(self.data[CONF_CERTFILE]), + ca_certs=self.hass.config.path(self.data[CONF_CA_CERTS]), ) await bridge.connect() diff --git a/homeassistant/components/lutron_caseta/cover.py b/homeassistant/components/lutron_caseta/cover.py index 81a65786900..5eabfcd16fe 100644 --- a/homeassistant/components/lutron_caseta/cover.py +++ b/homeassistant/components/lutron_caseta/cover.py @@ -7,6 +7,7 @@ from homeassistant.components.cover import ( SUPPORT_CLOSE, SUPPORT_OPEN, SUPPORT_SET_POSITION, + SUPPORT_STOP, CoverEntity, ) @@ -39,7 +40,7 @@ class LutronCasetaCover(LutronCasetaDevice, CoverEntity): @property def supported_features(self): """Flag supported features.""" - return SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_SET_POSITION + return SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_STOP | SUPPORT_SET_POSITION @property def is_closed(self): @@ -51,19 +52,27 @@ class LutronCasetaCover(LutronCasetaDevice, CoverEntity): """Return the current position of cover.""" return self._device["current_state"] + async def async_stop_cover(self, **kwargs): + """Top the cover.""" + await self._smartbridge.stop_cover(self.device_id) + async def async_close_cover(self, **kwargs): """Close the cover.""" - self._smartbridge.set_value(self.device_id, 0) + await self._smartbridge.lower_cover(self.device_id) + self.async_update() + self.async_write_ha_state() async def async_open_cover(self, **kwargs): """Open the cover.""" - self._smartbridge.set_value(self.device_id, 100) + await self._smartbridge.raise_cover(self.device_id) + self.async_update() + self.async_write_ha_state() async def async_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) + await self._smartbridge.set_value(self.device_id, position) async def async_update(self): """Call when forcing a refresh of the device.""" diff --git a/homeassistant/components/lutron_caseta/fan.py b/homeassistant/components/lutron_caseta/fan.py index aa6ab1c7144..90728c5f2fe 100644 --- a/homeassistant/components/lutron_caseta/fan.py +++ b/homeassistant/components/lutron_caseta/fan.py @@ -84,7 +84,7 @@ class LutronCasetaFan(LutronCasetaDevice, FanEntity): async def async_set_speed(self, speed: str) -> None: """Set the speed of the fan.""" - self._smartbridge.set_fan(self.device_id, SPEED_TO_VALUE[speed]) + await self._smartbridge.set_fan(self.device_id, SPEED_TO_VALUE[speed]) @property def is_on(self): diff --git a/homeassistant/components/lutron_caseta/light.py b/homeassistant/components/lutron_caseta/light.py index 471be51219b..c46e8931390 100644 --- a/homeassistant/components/lutron_caseta/light.py +++ b/homeassistant/components/lutron_caseta/light.py @@ -1,10 +1,13 @@ """Support for Lutron Caseta lights.""" +from datetime import timedelta import logging from homeassistant.components.light import ( ATTR_BRIGHTNESS, + ATTR_TRANSITION, DOMAIN, SUPPORT_BRIGHTNESS, + SUPPORT_TRANSITION, LightEntity, ) @@ -47,21 +50,31 @@ class LutronCasetaLight(LutronCasetaDevice, LightEntity): @property def supported_features(self): """Flag supported features.""" - return SUPPORT_BRIGHTNESS + return SUPPORT_BRIGHTNESS | SUPPORT_TRANSITION @property def brightness(self): """Return the brightness of the light.""" return to_hass_level(self._device["current_state"]) + async def _set_brightness(self, brightness, **kwargs): + args = {} + if ATTR_TRANSITION in kwargs: + args["fade_time"] = timedelta(seconds=kwargs[ATTR_TRANSITION]) + + await self._smartbridge.set_value( + self.device_id, to_lutron_level(brightness), **args + ) + async def async_turn_on(self, **kwargs): """Turn the light on.""" - brightness = kwargs.get(ATTR_BRIGHTNESS, 255) - self._smartbridge.set_value(self.device_id, to_lutron_level(brightness)) + brightness = kwargs.pop(ATTR_BRIGHTNESS, 255) + + await self._set_brightness(brightness, **kwargs) async def async_turn_off(self, **kwargs): """Turn the light off.""" - self._smartbridge.set_value(self.device_id, 0) + await self._set_brightness(0, **kwargs) @property def is_on(self): diff --git a/homeassistant/components/lutron_caseta/manifest.json b/homeassistant/components/lutron_caseta/manifest.json index 34fc326425c..f80e34a6b5c 100644 --- a/homeassistant/components/lutron_caseta/manifest.json +++ b/homeassistant/components/lutron_caseta/manifest.json @@ -3,9 +3,9 @@ "name": "Lutron Caséta", "documentation": "https://www.home-assistant.io/integrations/lutron_caseta", "requirements": [ - "pylutron-caseta==0.6.1" + "pylutron-caseta==0.7.0" ], "codeowners": [ "@swails" ] -} +} \ No newline at end of file diff --git a/homeassistant/components/lutron_caseta/scene.py b/homeassistant/components/lutron_caseta/scene.py index c74f60bc88c..a69f4594d14 100644 --- a/homeassistant/components/lutron_caseta/scene.py +++ b/homeassistant/components/lutron_caseta/scene.py @@ -43,4 +43,4 @@ class LutronCasetaScene(Scene): async def async_activate(self, **kwargs: Any) -> None: """Activate the scene.""" - self._bridge.activate_scene(self._scene_id) + await self._bridge.activate_scene(self._scene_id) diff --git a/homeassistant/components/lutron_caseta/switch.py b/homeassistant/components/lutron_caseta/switch.py index d7f9246feeb..1cccd485524 100644 --- a/homeassistant/components/lutron_caseta/switch.py +++ b/homeassistant/components/lutron_caseta/switch.py @@ -32,11 +32,11 @@ class LutronCasetaLight(LutronCasetaDevice, SwitchEntity): async def async_turn_on(self, **kwargs): """Turn the switch on.""" - self._smartbridge.turn_on(self.device_id) + await self._smartbridge.turn_on(self.device_id) async def async_turn_off(self, **kwargs): """Turn the switch off.""" - self._smartbridge.turn_off(self.device_id) + await self._smartbridge.turn_off(self.device_id) @property def is_on(self): diff --git a/requirements_all.txt b/requirements_all.txt index d8a46407f3f..c9ff2934c98 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1473,7 +1473,7 @@ pylitejet==0.1 pyloopenergy==0.2.1 # homeassistant.components.lutron_caseta -pylutron-caseta==0.6.1 +pylutron-caseta==0.7.0 # homeassistant.components.lutron pylutron==0.2.5 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 6e57cf08344..1b5f229a138 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -716,7 +716,7 @@ pylibrespot-java==0.1.0 pylitejet==0.1 # homeassistant.components.lutron_caseta -pylutron-caseta==0.6.1 +pylutron-caseta==0.7.0 # homeassistant.components.mailgun pymailgunner==1.4