mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Handle unit conversion in lib for niko_home_control (#141837)
* handle unit conversion in lib * bump lib * Fix --------- Co-authored-by: Joostlek <joostlek@outlook.com>
This commit is contained in:
parent
2d0c1fac24
commit
43b1dd64a7
@ -110,11 +110,11 @@ class NikoHomeControlLight(NikoHomeControlEntity, LightEntity):
|
|||||||
if action.is_dimmable:
|
if action.is_dimmable:
|
||||||
self._attr_color_mode = ColorMode.BRIGHTNESS
|
self._attr_color_mode = ColorMode.BRIGHTNESS
|
||||||
self._attr_supported_color_modes = {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:
|
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||||
"""Instruct the light to turn on."""
|
"""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:
|
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||||
"""Instruct the light to turn off."""
|
"""Instruct the light to turn off."""
|
||||||
@ -125,4 +125,4 @@ class NikoHomeControlLight(NikoHomeControlEntity, LightEntity):
|
|||||||
state = self._action.state
|
state = self._action.state
|
||||||
self._attr_is_on = state > 0
|
self._attr_is_on = state > 0
|
||||||
if brightness_supported(self.supported_color_modes):
|
if brightness_supported(self.supported_color_modes):
|
||||||
self._attr_brightness = round(state * 2.55)
|
self._attr_brightness = state
|
||||||
|
@ -6,5 +6,5 @@
|
|||||||
"documentation": "https://www.home-assistant.io/integrations/niko_home_control",
|
"documentation": "https://www.home-assistant.io/integrations/niko_home_control",
|
||||||
"iot_class": "local_push",
|
"iot_class": "local_push",
|
||||||
"loggers": ["nikohomecontrol"],
|
"loggers": ["nikohomecontrol"],
|
||||||
"requirements": ["nhc==0.4.10"]
|
"requirements": ["nhc==0.4.12"]
|
||||||
}
|
}
|
||||||
|
2
requirements_all.txt
generated
2
requirements_all.txt
generated
@ -1505,7 +1505,7 @@ nextcord==2.6.0
|
|||||||
nextdns==4.0.0
|
nextdns==4.0.0
|
||||||
|
|
||||||
# homeassistant.components.niko_home_control
|
# homeassistant.components.niko_home_control
|
||||||
nhc==0.4.10
|
nhc==0.4.12
|
||||||
|
|
||||||
# homeassistant.components.nibe_heatpump
|
# homeassistant.components.nibe_heatpump
|
||||||
nibe==2.17.0
|
nibe==2.17.0
|
||||||
|
2
requirements_test_all.txt
generated
2
requirements_test_all.txt
generated
@ -1269,7 +1269,7 @@ nextcord==2.6.0
|
|||||||
nextdns==4.0.0
|
nextdns==4.0.0
|
||||||
|
|
||||||
# homeassistant.components.niko_home_control
|
# homeassistant.components.niko_home_control
|
||||||
nhc==0.4.10
|
nhc==0.4.12
|
||||||
|
|
||||||
# homeassistant.components.nibe_heatpump
|
# homeassistant.components.nibe_heatpump
|
||||||
nibe==2.17.0
|
nibe==2.17.0
|
||||||
|
@ -45,7 +45,7 @@ def dimmable_light() -> NHCLight:
|
|||||||
mock.is_dimmable = True
|
mock.is_dimmable = True
|
||||||
mock.name = "dimmable light"
|
mock.name = "dimmable light"
|
||||||
mock.suggested_area = "room"
|
mock.suggested_area = "room"
|
||||||
mock.state = 100
|
mock.state = 255
|
||||||
return mock
|
return mock
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,11 +42,11 @@ async def test_entities(
|
|||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
("light_id", "data", "set_brightness"),
|
("light_id", "data", "set_brightness"),
|
||||||
[
|
[
|
||||||
(0, {ATTR_ENTITY_ID: "light.light"}, 100),
|
(0, {ATTR_ENTITY_ID: "light.light"}, 255),
|
||||||
(
|
(
|
||||||
1,
|
1,
|
||||||
{ATTR_ENTITY_ID: "light.dimmable_light", ATTR_BRIGHTNESS: 50},
|
{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").state == STATE_ON
|
||||||
assert hass.states.get("light.dimmable_light").attributes[ATTR_BRIGHTNESS] == 255
|
assert hass.states.get("light.dimmable_light").attributes[ATTR_BRIGHTNESS] == 255
|
||||||
|
|
||||||
dimmable_light.state = 80
|
dimmable_light.state = 204
|
||||||
await find_update_callback(mock_niko_home_control_connection, 2)(80)
|
await find_update_callback(mock_niko_home_control_connection, 2)(204)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert hass.states.get("light.dimmable_light").state == STATE_ON
|
assert hass.states.get("light.dimmable_light").state == STATE_ON
|
||||||
|
Loading…
x
Reference in New Issue
Block a user