From 43b1dd64a73e83a60102c9e8143d75ed30be7e95 Mon Sep 17 00:00:00 2001 From: "Glenn Vandeuren (aka Iondependent)" Date: Wed, 14 May 2025 17:13:06 +0200 Subject: [PATCH] Handle unit conversion in lib for niko_home_control (#141837) * handle unit conversion in lib * bump lib * Fix --------- Co-authored-by: Joostlek --- homeassistant/components/niko_home_control/light.py | 6 +++--- homeassistant/components/niko_home_control/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- tests/components/niko_home_control/conftest.py | 2 +- tests/components/niko_home_control/test_light.py | 8 ++++---- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/homeassistant/components/niko_home_control/light.py b/homeassistant/components/niko_home_control/light.py index b0a2d12b004..853fae342f4 100644 --- a/homeassistant/components/niko_home_control/light.py +++ b/homeassistant/components/niko_home_control/light.py @@ -110,11 +110,11 @@ class NikoHomeControlLight(NikoHomeControlEntity, LightEntity): if action.is_dimmable: self._attr_color_mode = ColorMode.BRIGHTNESS self._attr_supported_color_modes = {ColorMode.BRIGHTNESS} - self._attr_brightness = round(action.state * 2.55) + self._attr_brightness = action.state async def async_turn_on(self, **kwargs: Any) -> None: """Instruct the light to turn on.""" - await self._action.turn_on(round(kwargs.get(ATTR_BRIGHTNESS, 255) / 2.55)) + await self._action.turn_on(kwargs.get(ATTR_BRIGHTNESS, 255)) async def async_turn_off(self, **kwargs: Any) -> None: """Instruct the light to turn off.""" @@ -125,4 +125,4 @@ class NikoHomeControlLight(NikoHomeControlEntity, LightEntity): state = self._action.state self._attr_is_on = state > 0 if brightness_supported(self.supported_color_modes): - self._attr_brightness = round(state * 2.55) + self._attr_brightness = state diff --git a/homeassistant/components/niko_home_control/manifest.json b/homeassistant/components/niko_home_control/manifest.json index 83fca0ca2d6..1193d33d435 100644 --- a/homeassistant/components/niko_home_control/manifest.json +++ b/homeassistant/components/niko_home_control/manifest.json @@ -6,5 +6,5 @@ "documentation": "https://www.home-assistant.io/integrations/niko_home_control", "iot_class": "local_push", "loggers": ["nikohomecontrol"], - "requirements": ["nhc==0.4.10"] + "requirements": ["nhc==0.4.12"] } diff --git a/requirements_all.txt b/requirements_all.txt index 787e1831914..d6fb1ae7bfa 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1505,7 +1505,7 @@ nextcord==2.6.0 nextdns==4.0.0 # homeassistant.components.niko_home_control -nhc==0.4.10 +nhc==0.4.12 # homeassistant.components.nibe_heatpump nibe==2.17.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 2fe65d0a93d..a4e35701a74 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1269,7 +1269,7 @@ nextcord==2.6.0 nextdns==4.0.0 # homeassistant.components.niko_home_control -nhc==0.4.10 +nhc==0.4.12 # homeassistant.components.nibe_heatpump nibe==2.17.0 diff --git a/tests/components/niko_home_control/conftest.py b/tests/components/niko_home_control/conftest.py index 130baf72228..35260b387de 100644 --- a/tests/components/niko_home_control/conftest.py +++ b/tests/components/niko_home_control/conftest.py @@ -45,7 +45,7 @@ def dimmable_light() -> NHCLight: mock.is_dimmable = True mock.name = "dimmable light" mock.suggested_area = "room" - mock.state = 100 + mock.state = 255 return mock diff --git a/tests/components/niko_home_control/test_light.py b/tests/components/niko_home_control/test_light.py index 865e1303cb0..a11f846bba6 100644 --- a/tests/components/niko_home_control/test_light.py +++ b/tests/components/niko_home_control/test_light.py @@ -42,11 +42,11 @@ async def test_entities( @pytest.mark.parametrize( ("light_id", "data", "set_brightness"), [ - (0, {ATTR_ENTITY_ID: "light.light"}, 100), + (0, {ATTR_ENTITY_ID: "light.light"}, 255), ( 1, {ATTR_ENTITY_ID: "light.dimmable_light", ATTR_BRIGHTNESS: 50}, - 20, + 50, ), ], ) @@ -121,8 +121,8 @@ async def test_updating( assert hass.states.get("light.dimmable_light").state == STATE_ON assert hass.states.get("light.dimmable_light").attributes[ATTR_BRIGHTNESS] == 255 - dimmable_light.state = 80 - await find_update_callback(mock_niko_home_control_connection, 2)(80) + dimmable_light.state = 204 + await find_update_callback(mock_niko_home_control_connection, 2)(204) await hass.async_block_till_done() assert hass.states.get("light.dimmable_light").state == STATE_ON