From 254abeeb4fa1cf871fdb232eb94eb74a1824849d Mon Sep 17 00:00:00 2001 From: rappenze Date: Thu, 4 Jan 2024 09:45:08 +0100 Subject: [PATCH] Remove dead code in fibaro light (#106890) --- homeassistant/components/fibaro/light.py | 35 ++++++------------------ 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/homeassistant/components/fibaro/light.py b/homeassistant/components/fibaro/light.py index 981b81fdd43..17de9a6636a 100644 --- a/homeassistant/components/fibaro/light.py +++ b/homeassistant/components/fibaro/light.py @@ -1,9 +1,7 @@ """Support for Fibaro lights.""" from __future__ import annotations -import asyncio from contextlib import suppress -from functools import partial from typing import Any from pyfibaro.fibaro_device import DeviceModel @@ -68,8 +66,6 @@ class FibaroLight(FibaroDevice, LightEntity): def __init__(self, fibaro_device: DeviceModel) -> None: """Initialize the light.""" - self._update_lock = asyncio.Lock() - supports_color = ( "color" in fibaro_device.properties or "colorComponents" in fibaro_device.properties @@ -106,13 +102,8 @@ class FibaroLight(FibaroDevice, LightEntity): super().__init__(fibaro_device) self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id) - async def async_turn_on(self, **kwargs: Any) -> None: + def turn_on(self, **kwargs: Any) -> None: """Turn the light on.""" - async with self._update_lock: - await self.hass.async_add_executor_job(partial(self._turn_on, **kwargs)) - - def _turn_on(self, **kwargs): - """Really turn the light on.""" if ATTR_BRIGHTNESS in kwargs: self._attr_brightness = kwargs[ATTR_BRIGHTNESS] self.set_level(scaleto99(self._attr_brightness)) @@ -120,26 +111,23 @@ class FibaroLight(FibaroDevice, LightEntity): if ATTR_RGB_COLOR in kwargs: # Update based on parameters - self._attr_rgb_color = kwargs[ATTR_RGB_COLOR] - self.call_set_color(*self._attr_rgb_color, 0) + rgb = kwargs[ATTR_RGB_COLOR] + self._attr_rgb_color = rgb + self.call_set_color(int(rgb[0]), int(rgb[1]), int(rgb[2]), 0) return if ATTR_RGBW_COLOR in kwargs: # Update based on parameters - self._attr_rgbw_color = kwargs[ATTR_RGBW_COLOR] - self.call_set_color(*self._attr_rgbw_color) + rgbw = kwargs[ATTR_RGBW_COLOR] + self._attr_rgbw_color = rgbw + self.call_set_color(int(rgbw[0]), int(rgbw[1]), int(rgbw[2]), int(rgbw[3])) return # The simplest case is left for last. No dimming, just switch on self.call_turn_on() - async def async_turn_off(self, **kwargs: Any) -> None: + def turn_off(self, **kwargs: Any) -> None: """Turn the light off.""" - async with self._update_lock: - await self.hass.async_add_executor_job(partial(self._turn_off, **kwargs)) - - def _turn_off(self, **kwargs): - """Really turn the light off.""" self.call_turn_off() @property @@ -165,13 +153,8 @@ class FibaroLight(FibaroDevice, LightEntity): return False - async def async_update(self) -> None: + def update(self) -> None: """Update the state.""" - async with self._update_lock: - await self.hass.async_add_executor_job(self._update) - - def _update(self): - """Really update the state.""" super().update() # Brightness handling if brightness_supported(self.supported_color_modes):