From caac3d03c4862a779147614a659f7fc451b135d2 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Mon, 21 Nov 2022 11:46:18 +0100 Subject: [PATCH] Fix round typing [fritzbox] (#82434) --- homeassistant/components/fritzbox/light.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/fritzbox/light.py b/homeassistant/components/fritzbox/light.py index 5053eda69d7..03eb9eb9d78 100644 --- a/homeassistant/components/fritzbox/light.py +++ b/homeassistant/components/fritzbox/light.py @@ -1,7 +1,7 @@ """Support for AVM FRITZ!SmartHome lightbulbs.""" from __future__ import annotations -from typing import Any +from typing import Any, cast 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. # 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(): hue = int(values[0][0]) self._supported_hs[hue] = [ @@ -138,7 +138,9 @@ class FritzboxLight(FritzBoxDeviceEntity, LightEntity): try: # HA gives 0..360 for hue, fritz light only supports 0..359 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( self.data.set_unmapped_color, (unmapped_hue, unmapped_saturation) )