Remove dead code in fibaro light (#106890)

pull/107080/head
rappenze 2024-01-04 09:45:08 +01:00 committed by GitHub
parent 9c69212ad5
commit 254abeeb4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 26 deletions

View File

@ -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):