mirror of
https://github.com/home-assistant/core.git
synced 2025-12-25 05:26:47 +00:00
Update Fritz! lights to use kelvin (#79733)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"""Tests for AVM Fritz!Box light component."""
|
||||
from datetime import timedelta
|
||||
from unittest.mock import Mock
|
||||
from unittest.mock import Mock, call
|
||||
|
||||
from requests.exceptions import HTTPError
|
||||
|
||||
@@ -11,8 +11,10 @@ from homeassistant.components.fritzbox.const import (
|
||||
)
|
||||
from homeassistant.components.light import (
|
||||
ATTR_BRIGHTNESS,
|
||||
ATTR_COLOR_TEMP,
|
||||
ATTR_COLOR_TEMP_KELVIN,
|
||||
ATTR_HS_COLOR,
|
||||
ATTR_MAX_COLOR_TEMP_KELVIN,
|
||||
ATTR_MIN_COLOR_TEMP_KELVIN,
|
||||
DOMAIN,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
@@ -24,7 +26,6 @@ from homeassistant.const import (
|
||||
STATE_ON,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.util import color
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
from . import FritzDeviceLightMock, setup_config_entry
|
||||
@@ -53,9 +54,9 @@ async def test_setup(hass: HomeAssistant, fritz: Mock):
|
||||
assert state
|
||||
assert state.state == STATE_ON
|
||||
assert state.attributes[ATTR_FRIENDLY_NAME] == "fake_name"
|
||||
assert state.attributes[ATTR_COLOR_TEMP] == color.color_temperature_kelvin_to_mired(
|
||||
2700
|
||||
)
|
||||
assert state.attributes[ATTR_COLOR_TEMP_KELVIN] == 2700
|
||||
assert state.attributes[ATTR_MIN_COLOR_TEMP_KELVIN] == 2700
|
||||
assert state.attributes[ATTR_MAX_COLOR_TEMP_KELVIN] == 6500
|
||||
|
||||
|
||||
async def test_setup_color(hass: HomeAssistant, fritz: Mock):
|
||||
@@ -95,12 +96,14 @@ async def test_turn_on(hass: HomeAssistant, fritz: Mock):
|
||||
assert await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_BRIGHTNESS: 100, ATTR_COLOR_TEMP: 300},
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_BRIGHTNESS: 100, ATTR_COLOR_TEMP_KELVIN: 3000},
|
||||
True,
|
||||
)
|
||||
assert device.set_state_on.call_count == 1
|
||||
assert device.set_level.call_count == 1
|
||||
assert device.set_color_temp.call_count == 1
|
||||
assert device.set_color_temp.call_args_list == [call(3000)]
|
||||
assert device.set_level.call_args_list == [call(100)]
|
||||
|
||||
|
||||
async def test_turn_on_color(hass: HomeAssistant, fritz: Mock):
|
||||
@@ -122,6 +125,10 @@ async def test_turn_on_color(hass: HomeAssistant, fritz: Mock):
|
||||
assert device.set_state_on.call_count == 1
|
||||
assert device.set_level.call_count == 1
|
||||
assert device.set_unmapped_color.call_count == 1
|
||||
assert device.set_level.call_args_list == [call(100)]
|
||||
assert device.set_unmapped_color.call_args_list == [
|
||||
call((100, round(70 * 255.0 / 100.0)))
|
||||
]
|
||||
|
||||
|
||||
async def test_turn_on_color_unsupported_api_method(hass: HomeAssistant, fritz: Mock):
|
||||
@@ -150,6 +157,8 @@ async def test_turn_on_color_unsupported_api_method(hass: HomeAssistant, fritz:
|
||||
assert device.set_state_on.call_count == 1
|
||||
assert device.set_level.call_count == 1
|
||||
assert device.set_color.call_count == 1
|
||||
assert device.set_level.call_args_list == [call(100)]
|
||||
assert device.set_color.call_args_list == [call((100, 70))]
|
||||
|
||||
|
||||
async def test_turn_off(hass: HomeAssistant, fritz: Mock):
|
||||
|
||||
Reference in New Issue
Block a user