mirror of
https://github.com/home-assistant/core.git
synced 2025-04-27 10:47:51 +00:00
Fix round typing [fritzbox] (#82434)
This commit is contained in:
parent
c899e72029
commit
caac3d03c4
@ -1,7 +1,7 @@
|
|||||||
"""Support for AVM FRITZ!SmartHome lightbulbs."""
|
"""Support for AVM FRITZ!SmartHome lightbulbs."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any
|
from typing import Any, cast
|
||||||
|
|
||||||
from requests.exceptions import HTTPError
|
from requests.exceptions import HTTPError
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ class FritzboxLight(FritzBoxDeviceEntity, LightEntity):
|
|||||||
|
|
||||||
# Fritz!DECT 500 only supports 12 values for hue, with 3 saturations each.
|
# Fritz!DECT 500 only supports 12 values for hue, with 3 saturations each.
|
||||||
# Map supported colors to dict {hue: [sat1, sat2, sat3]} for easier lookup
|
# Map supported colors to dict {hue: [sat1, sat2, sat3]} for easier lookup
|
||||||
self._supported_hs = {}
|
self._supported_hs: dict[int, list[int]] = {}
|
||||||
for values in supported_colors.values():
|
for values in supported_colors.values():
|
||||||
hue = int(values[0][0])
|
hue = int(values[0][0])
|
||||||
self._supported_hs[hue] = [
|
self._supported_hs[hue] = [
|
||||||
@ -138,7 +138,9 @@ class FritzboxLight(FritzBoxDeviceEntity, LightEntity):
|
|||||||
try:
|
try:
|
||||||
# HA gives 0..360 for hue, fritz light only supports 0..359
|
# HA gives 0..360 for hue, fritz light only supports 0..359
|
||||||
unmapped_hue = int(kwargs[ATTR_HS_COLOR][0] % 360)
|
unmapped_hue = int(kwargs[ATTR_HS_COLOR][0] % 360)
|
||||||
unmapped_saturation = round(kwargs[ATTR_HS_COLOR][1] * 255.0 / 100.0)
|
unmapped_saturation = round(
|
||||||
|
cast(float, kwargs[ATTR_HS_COLOR][1]) * 255.0 / 100.0
|
||||||
|
)
|
||||||
await self.hass.async_add_executor_job(
|
await self.hass.async_add_executor_job(
|
||||||
self.data.set_unmapped_color, (unmapped_hue, unmapped_saturation)
|
self.data.set_unmapped_color, (unmapped_hue, unmapped_saturation)
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user