Remove dead code in fibaro light (#106890)
parent
9c69212ad5
commit
254abeeb4f
|
@ -1,9 +1,7 @@
|
||||||
"""Support for Fibaro lights."""
|
"""Support for Fibaro lights."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from functools import partial
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from pyfibaro.fibaro_device import DeviceModel
|
from pyfibaro.fibaro_device import DeviceModel
|
||||||
|
@ -68,8 +66,6 @@ class FibaroLight(FibaroDevice, LightEntity):
|
||||||
|
|
||||||
def __init__(self, fibaro_device: DeviceModel) -> None:
|
def __init__(self, fibaro_device: DeviceModel) -> None:
|
||||||
"""Initialize the light."""
|
"""Initialize the light."""
|
||||||
self._update_lock = asyncio.Lock()
|
|
||||||
|
|
||||||
supports_color = (
|
supports_color = (
|
||||||
"color" in fibaro_device.properties
|
"color" in fibaro_device.properties
|
||||||
or "colorComponents" in fibaro_device.properties
|
or "colorComponents" in fibaro_device.properties
|
||||||
|
@ -106,13 +102,8 @@ class FibaroLight(FibaroDevice, LightEntity):
|
||||||
super().__init__(fibaro_device)
|
super().__init__(fibaro_device)
|
||||||
self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id)
|
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."""
|
"""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:
|
if ATTR_BRIGHTNESS in kwargs:
|
||||||
self._attr_brightness = kwargs[ATTR_BRIGHTNESS]
|
self._attr_brightness = kwargs[ATTR_BRIGHTNESS]
|
||||||
self.set_level(scaleto99(self._attr_brightness))
|
self.set_level(scaleto99(self._attr_brightness))
|
||||||
|
@ -120,26 +111,23 @@ class FibaroLight(FibaroDevice, LightEntity):
|
||||||
|
|
||||||
if ATTR_RGB_COLOR in kwargs:
|
if ATTR_RGB_COLOR in kwargs:
|
||||||
# Update based on parameters
|
# Update based on parameters
|
||||||
self._attr_rgb_color = kwargs[ATTR_RGB_COLOR]
|
rgb = kwargs[ATTR_RGB_COLOR]
|
||||||
self.call_set_color(*self._attr_rgb_color, 0)
|
self._attr_rgb_color = rgb
|
||||||
|
self.call_set_color(int(rgb[0]), int(rgb[1]), int(rgb[2]), 0)
|
||||||
return
|
return
|
||||||
|
|
||||||
if ATTR_RGBW_COLOR in kwargs:
|
if ATTR_RGBW_COLOR in kwargs:
|
||||||
# Update based on parameters
|
# Update based on parameters
|
||||||
self._attr_rgbw_color = kwargs[ATTR_RGBW_COLOR]
|
rgbw = kwargs[ATTR_RGBW_COLOR]
|
||||||
self.call_set_color(*self._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
|
return
|
||||||
|
|
||||||
# The simplest case is left for last. No dimming, just switch on
|
# The simplest case is left for last. No dimming, just switch on
|
||||||
self.call_turn_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."""
|
"""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()
|
self.call_turn_off()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -165,13 +153,8 @@ class FibaroLight(FibaroDevice, LightEntity):
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
async def async_update(self) -> None:
|
def update(self) -> None:
|
||||||
"""Update the state."""
|
"""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()
|
super().update()
|
||||||
# Brightness handling
|
# Brightness handling
|
||||||
if brightness_supported(self.supported_color_modes):
|
if brightness_supported(self.supported_color_modes):
|
||||||
|
|
Loading…
Reference in New Issue