Rename lights in tests (#681)

* Rename lights in tests

* Remove unused dependencies
This commit is contained in:
Bas Nijholt 2023-07-29 21:48:45 -07:00 committed by GitHub
commit 68985199f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -118,8 +118,9 @@ LAT_LONG_TZS = [
(32.87336, -117.22743, "US/Pacific"),
]
ENTITY_LIGHT = "light.bed_light"
ENTITY_LIGHT3 = "light.kitchen_lights"
ENTITY_LIGHT_1 = "light.light_1"
ENTITY_LIGHT_2 = "light.light_2"
ENTITY_LIGHT_3 = "light.light_3"
_SWITCH_FMT = f"{SWITCH_DOMAIN}.{DOMAIN}"
ENTITY_SWITCH = f"{_SWITCH_FMT}_{DEFAULT_NAME}"
ENTITY_SLEEP_MODE_SWITCH = f"{_SWITCH_FMT}_sleep_mode_{DEFAULT_NAME}"
@ -128,11 +129,6 @@ ENTITY_ADAPT_COLOR_SWITCH = f"{_SWITCH_FMT}_adapt_color_{DEFAULT_NAME}"
ORIG_TIMEZONE = dt_util.DEFAULT_TIME_ZONE
GLOBAL_TEST_DEPENDENCIES = [
"test_adaptive_lighting_switches",
"test_light_settings",
]
def create_random_context() -> str:
return Context(id=ulid_transform.ulid_now(), parent_id=None)
@ -173,8 +169,8 @@ async def setup_lights(hass: HomeAssistant):
{
"platform": "template",
"lights": {
"bed_light": {
"friendly_name": "Bed Light",
"light_1": {
"friendly_name": "light_1",
"unique_id": "light_1",
"turn_on": None,
"turn_off": None,
@ -182,8 +178,8 @@ async def setup_lights(hass: HomeAssistant):
"set_temperature": None,
"set_color": None,
},
"ceiling_lights": {
"friendly_name": "Ceiling Lights",
"light_2": {
"friendly_name": "light_2",
"unique_id": "light_2",
"turn_on": None,
"turn_off": None,
@ -191,8 +187,8 @@ async def setup_lights(hass: HomeAssistant):
"set_temperature": None,
"set_color": None,
},
"kitchen_lights": {
"friendly_name": "Kitchen Lights",
"light_3": {
"friendly_name": "light_3",
"unique_id": "light_3",
"turn_on": None,
"turn_off": None,
@ -229,18 +225,18 @@ async def setup_lights_and_switch(hass, extra_conf=None, all_lights: bool = Fals
await hass.services.async_call(
LIGHT_DOMAIN,
SERVICE_TURN_ON,
{ATTR_ENTITY_ID: ENTITY_LIGHT},
{ATTR_ENTITY_ID: ENTITY_LIGHT_1},
blocking=True,
)
# Setup switch
lights = [
ENTITY_LIGHT,
"light.ceiling_lights",
ENTITY_LIGHT_1,
ENTITY_LIGHT_2,
]
if all_lights:
lights.append(ENTITY_LIGHT3)
lights.append(ENTITY_LIGHT_3)
assert all(hass.states.get(light) is not None for light in lights)
_, switch = await setup_switch(
@ -341,7 +337,6 @@ async def test_adaptive_lighting_switches(hass):
@pytest.mark.parametrize("lat,long,timezone", LAT_LONG_TZS)
@pytest.mark.dependency("test_adaptive_lighting_switches")
async def test_adaptive_lighting_time_zones_with_default_settings(
hass, lat, long, timezone, reset_time_zone # pylint: disable=redefined-outer-name
):
@ -530,11 +525,10 @@ async def test_light_settings(hass):
assert_expected_color_temp(state)
@pytest.mark.dependency(depends=GLOBAL_TEST_DEPENDENCIES)
async def test_manager_not_tracking_untracked_lights(hass):
"""Test that lights that are not in a Adaptive Lighting switch aren't tracked."""
switch, _ = await setup_lights_and_switch(hass)
light = "light.kitchen_lights"
light = ENTITY_LIGHT_3
assert light not in switch.lights
for state in [True, False]:
await hass.services.async_call(
@ -550,7 +544,6 @@ async def test_manager_not_tracking_untracked_lights(hass):
assert light not in switch.manager.lights
@pytest.mark.dependency(depends=GLOBAL_TEST_DEPENDENCIES)
async def test_manual_control(hass):
"""Test the 'manual control' tracking."""
switch, (light, *_) = await setup_lights_and_switch(hass)
@ -565,7 +558,7 @@ async def test_manual_control(hass):
await hass.services.async_call(
LIGHT_DOMAIN,
SERVICE_TURN_ON if state else SERVICE_TURN_OFF,
{ATTR_ENTITY_ID: ENTITY_LIGHT, **kwargs},
{ATTR_ENTITY_ID: ENTITY_LIGHT_1, **kwargs},
blocking=True,
)
await hass.async_block_till_done()
@ -583,7 +576,7 @@ async def test_manual_control(hass):
async def change_manual_control(set_to, extra_service_data=None):
if extra_service_data is None:
extra_service_data = {CONF_LIGHTS: [ENTITY_LIGHT]}
extra_service_data = {CONF_LIGHTS: [ENTITY_LIGHT_1]}
await hass.services.async_call(
DOMAIN,
SERVICE_SET_MANUAL_CONTROL,
@ -608,48 +601,48 @@ async def test_manual_control(hass):
# Nothing is manually controlled
await update()
assert not manual_control[ENTITY_LIGHT]
# Call light.turn_on for ENTITY_LIGHT
assert not manual_control[ENTITY_LIGHT_1]
# Call light.turn_on for ENTITY_LIGHT_1
await turn_light(True, brightness=increased_brightness())
# Check that ENTITY_LIGHT is manually controlled
assert manual_control[ENTITY_LIGHT]
# Check that ENTITY_LIGHT_1 is manually controlled
assert manual_control[ENTITY_LIGHT_1]
# Test adaptive_lighting.set_manual_control
await change_manual_control(False)
# Check that ENTITY_LIGHT is not manually controlled
assert not manual_control[ENTITY_LIGHT]
# Check that ENTITY_LIGHT_1 is not manually controlled
assert not manual_control[ENTITY_LIGHT_1]
# Check that toggling light off to on resets manual control
await change_manual_control(True)
assert manual_control[ENTITY_LIGHT]
assert manual_control[ENTITY_LIGHT_1]
await turn_light(False)
await turn_light(True, brightness=increased_brightness())
assert hass.states.get(ENTITY_LIGHT).state == STATE_ON
assert not manual_control[ENTITY_LIGHT], manual_control
assert hass.states.get(ENTITY_LIGHT_1).state == STATE_ON
assert not manual_control[ENTITY_LIGHT_1], manual_control
# Check that toggling (sleep mode) switch resets manual control
for entity_id in [ENTITY_SWITCH, ENTITY_SLEEP_MODE_SWITCH]:
await change_manual_control(True)
assert manual_control[ENTITY_LIGHT]
assert manual_control[ENTITY_LIGHT_1]
await turn_switch(False, entity_id)
await turn_switch(True, entity_id)
assert not manual_control[ENTITY_LIGHT]
assert not manual_control[ENTITY_LIGHT_1]
# Check that manual control is still enabled if set while bulb is off.
# Test issue #37
await turn_light(False)
await change_manual_control(True)
await turn_light(True)
assert manual_control[ENTITY_LIGHT]
assert manual_control[ENTITY_LIGHT_1]
# Check that when 'adapt_brightness' is off, changing the brightness
# doesn't mark it as manually controlled but changing color_temp
# does
await turn_light(False)
await turn_light(True) # reset manually controlled status
assert not manual_control[ENTITY_LIGHT]
assert not manual_control[ENTITY_LIGHT_1]
await switch.adapt_brightness_switch.async_turn_off()
await turn_light(True, brightness=increased_brightness())
assert not manual_control[ENTITY_LIGHT]
assert not manual_control[ENTITY_LIGHT_1]
mired_range = (light.min_color_temp_kelvin, light.max_color_temp_kelvin)
kelvin_range = (
color_temperature_mired_to_kelvin(mired_range[1]),
@ -659,7 +652,7 @@ async def test_manual_control(hass):
await turn_light(
True, color_temp_kelvin=(light._attr_color_temp + 100) % ptp_kelvin
)
assert manual_control[ENTITY_LIGHT]
assert manual_control[ENTITY_LIGHT_1]
await switch.adapt_brightness_switch.async_turn_on() # turn on again
# Check that when 'adapt_color' is off, changing the color
@ -667,12 +660,12 @@ async def test_manual_control(hass):
# does
await turn_light(False) # reset manually controlled status
await turn_light(True)
assert not manual_control[ENTITY_LIGHT]
assert not manual_control[ENTITY_LIGHT_1]
await switch.adapt_color_switch.async_turn_off()
await turn_light(True, color_temp=increased_color_temp())
assert not manual_control[ENTITY_LIGHT]
assert not manual_control[ENTITY_LIGHT_1]
await turn_light(True, brightness=increased_brightness())
assert manual_control[ENTITY_LIGHT]
assert manual_control[ENTITY_LIGHT_1]
# Check that when 'adapt_color' adapt_brightness are both off
# nothing marks it as manually controlled
@ -680,7 +673,7 @@ async def test_manual_control(hass):
await turn_light(True)
await switch.adapt_color_switch.async_turn_off()
await switch.adapt_brightness_switch.async_turn_off()
assert not manual_control[ENTITY_LIGHT]
assert not manual_control[ENTITY_LIGHT_1]
await turn_light(True, color_temp=increased_color_temp())
await turn_light(True, brightness=increased_brightness())
await turn_light(
@ -688,7 +681,7 @@ async def test_manual_control(hass):
color_temp=increased_color_temp(),
brightness=increased_brightness(),
)
assert not manual_control[ENTITY_LIGHT]
assert not manual_control[ENTITY_LIGHT_1]
# Turn switches on again
await switch.adapt_color_switch.async_turn_on()
await switch.adapt_brightness_switch.async_turn_on()
@ -701,7 +694,6 @@ async def test_manual_control(hass):
assert all([not manual_control[eid] for eid in switch.lights])
@pytest.mark.dependency(depends=[*GLOBAL_TEST_DEPENDENCIES, "test_manual_control"])
async def test_auto_reset_manual_control(hass):
switch, (light, *_) = await setup_lights_and_switch(
hass, {CONF_AUTORESET_CONTROL: 0.1}
@ -752,7 +744,6 @@ async def test_auto_reset_manual_control(hass):
assert not manual_control[light.entity_id]
@pytest.mark.dependency(depends=GLOBAL_TEST_DEPENDENCIES)
async def test_apply_service(hass):
"""Test adaptive_lighting.apply service."""
switch, (_, _, light) = await setup_lights_and_switch(hass)
@ -817,9 +808,6 @@ async def test_apply_service(hass):
assert old_state[ATTR_COLOR_TEMP_KELVIN] == new_state[ATTR_COLOR_TEMP_KELVIN]
@pytest.mark.dependency(
depends=[*GLOBAL_TEST_DEPENDENCIES, "test_apply_service", "test_manual_control"]
)
async def test_switch_off_on_off(hass):
"""Test switch rapid off_on_off."""
@ -827,7 +815,7 @@ async def test_switch_off_on_off(hass):
await hass.services.async_call(
LIGHT_DOMAIN,
SERVICE_TURN_ON if state else SERVICE_TURN_OFF,
{ATTR_ENTITY_ID: ENTITY_LIGHT, **kwargs},
{ATTR_ENTITY_ID: ENTITY_LIGHT_1, **kwargs},
blocking=True,
)
await hass.async_block_till_done()
@ -846,23 +834,23 @@ async def test_switch_off_on_off(hass):
# Turn light off with transition
await turn_light(False, transition=1)
assert not switch.manager.manual_control[ENTITY_LIGHT]
assert not switch.manager.manual_control[ENTITY_LIGHT_1]
# Set state to on after a second (like happens IRL)
await asyncio.sleep(1e-3)
hass.states.async_set(ENTITY_LIGHT, STATE_ON)
hass.states.async_set(ENTITY_LIGHT_1, STATE_ON)
# Set state to off after a second (like happens IRL)
await asyncio.sleep(1e-3)
hass.states.async_set(ENTITY_LIGHT, STATE_OFF)
hass.states.async_set(ENTITY_LIGHT_1, STATE_OFF)
# Now we test whether the sleep task is there
assert ENTITY_LIGHT in switch.manager.sleep_tasks
sleep_task = switch.manager.sleep_tasks[ENTITY_LIGHT]
assert ENTITY_LIGHT_1 in switch.manager.sleep_tasks
sleep_task = switch.manager.sleep_tasks[ENTITY_LIGHT_1]
assert not sleep_task.cancelled()
# A 'light.turn_on' event should cancel that task
await turn_light(turn_light_state_at_end)
await update()
state = hass.states.get(ENTITY_LIGHT).state
state = hass.states.get(ENTITY_LIGHT_1).state
if turn_light_state_at_end:
assert sleep_task.cancelled()
assert state == STATE_ON
@ -870,7 +858,6 @@ async def test_switch_off_on_off(hass):
assert state == STATE_OFF
@pytest.mark.dependency(depends=GLOBAL_TEST_DEPENDENCIES)
def test_color_difference_redmean():
"""Test color_difference_redmean function."""
for _ in range(10):
@ -933,7 +920,6 @@ def test_attributes_have_changed():
)
@pytest.mark.dependency(depends=GLOBAL_TEST_DEPENDENCIES)
async def test_state_change_handlers(hass):
"""
Test AdaptiveLightingManager's EVENT_STATE_CHANGED listener.
@ -955,7 +941,7 @@ async def test_state_change_handlers(hass):
async def set_brightness(val: int):
# 'Unsafe' set but we know what we're doing.
hass.states.async_set(
ENTITY_LIGHT, "on", {ATTR_BRIGHTNESS: val, ATTR_SUPPORTED_FEATURES: 1}
ENTITY_LIGHT_1, "on", {ATTR_BRIGHTNESS: val, ATTR_SUPPORTED_FEATURES: 1}
)
await hass.async_block_till_done()
# Call code in AdaptiveLightingManager
@ -963,7 +949,7 @@ async def test_state_change_handlers(hass):
EVENT_STATE_CHANGED,
{
"new_state": {
ATTR_ENTITY_ID: ENTITY_LIGHT,
ATTR_ENTITY_ID: ENTITY_LIGHT_1,
"state": "on",
ATTR_BRIGHTNESS: val,
}
@ -975,7 +961,7 @@ async def test_state_change_handlers(hass):
await hass.services.async_call(
LIGHT_DOMAIN,
SERVICE_TURN_ON if state else SERVICE_TURN_OFF,
{ATTR_ENTITY_ID: ENTITY_LIGHT, **kwargs},
{ATTR_ENTITY_ID: ENTITY_LIGHT_1, **kwargs},
blocking=True,
)
await hass.async_block_till_done()
@ -998,11 +984,11 @@ async def test_state_change_handlers(hass):
blocking=True,
)
await hass.async_block_till_done()
assert switch.manager.last_state_change.get(ENTITY_LIGHT)
assert len(switch.manager.last_state_change[ENTITY_LIGHT]) == 1
assert not switch.manager.transition_timers.get(ENTITY_LIGHT)
assert switch.manager.last_state_change.get(ENTITY_LIGHT_1)
assert len(switch.manager.last_state_change[ENTITY_LIGHT_1]) == 1
assert not switch.manager.transition_timers.get(ENTITY_LIGHT_1)
last_service_data = deepcopy(switch.manager.last_service_data)
assert last_service_data.get(ENTITY_LIGHT)
assert last_service_data.get(ENTITY_LIGHT_1)
# 2 Adapt from sleep with a 'transition'.
await switch.sleep_mode_switch.async_turn_off()
@ -1068,9 +1054,9 @@ async def test_state_change_handlers(hass):
# asyncio.sleep(3)
# 4. Assert the transition timer started and everything was filled.
listener = switch.manager
assert listener.last_state_change.get(ENTITY_LIGHT)
assert len(listener.last_state_change[ENTITY_LIGHT]) == total_events
assert listener.transition_timers.get(ENTITY_LIGHT)
assert listener.last_state_change.get(ENTITY_LIGHT_1)
assert len(listener.last_state_change[ENTITY_LIGHT_1]) == total_events
assert listener.transition_timers.get(ENTITY_LIGHT_1)
# 5. Execute some checks during a transition
_LOGGER.debug("Test detect_non_ha_changes:")
@ -1080,25 +1066,25 @@ async def test_state_change_handlers(hass):
assert switch._detect_non_ha_changes
await asyncio.sleep(transition_used / 3)
# Ensure the timer still exists
timer = listener.transition_timers.get(ENTITY_LIGHT)
timer = listener.transition_timers.get(ENTITY_LIGHT_1)
assert timer and timer.is_running()
last_service_data = deepcopy(current_service_data)
await update()
assert not switch.manager.manual_control[ENTITY_LIGHT]
assert not switch.manager.manual_control[ENTITY_LIGHT_1]
await update()
assert not switch.manager.manual_control[ENTITY_LIGHT]
timer = listener.transition_timers.get(ENTITY_LIGHT)
assert not switch.manager.manual_control[ENTITY_LIGHT_1]
timer = listener.transition_timers.get(ENTITY_LIGHT_1)
assert timer and timer.is_running()
# Ensure the light did not adapt during the transition.
assert last_service_data == current_service_data
# 6. Assert everything after the transition finishes.
await asyncio.sleep(transition_used)
assert listener.last_state_change.get(ENTITY_LIGHT)
assert len(listener.last_state_change[ENTITY_LIGHT]) == total_events
assert listener.last_state_change.get(ENTITY_LIGHT_1)
assert len(listener.last_state_change[ENTITY_LIGHT_1]) == total_events
# Timer should be done and reset now.
# This is the assert that I can't fix.
timer = listener.transition_timers.get(ENTITY_LIGHT)
timer = listener.transition_timers.get(ENTITY_LIGHT_1)
assert not timer or not timer.is_running()
# build last service data
@ -1108,35 +1094,25 @@ async def test_state_change_handlers(hass):
await turn_light(True, brightness=40)
await turn_light(True, brightness=20)
await update(force=False)
assert switch.manager.manual_control[ENTITY_LIGHT]
assert switch.manager.manual_control[ENTITY_LIGHT_1]
await update(force=True)
assert switch.manager.manual_control[ENTITY_LIGHT]
assert switch.manager.manual_control[ENTITY_LIGHT_1]
# turn light off then on should reset manual control.
await turn_light(False)
await turn_light(True)
assert not switch.manager.manual_control[ENTITY_LIGHT]
assert not switch.manager.manual_control[ENTITY_LIGHT_1]
await turn_light(True, brightness=50)
_LOGGER.debug("Test: Brightness set to %s", 50)
# On next update ENTITY_LIGHT should be marked as manually controlled
# On next update ENTITY_LIGHT_1 should be marked as manually controlled
await update(force=False)
assert switch.manager.last_service_data.get(ENTITY_LIGHT) is not None
assert switch.manager.last_state_change.get(ENTITY_LIGHT) is not None
assert switch.manager.manual_control[ENTITY_LIGHT]
assert switch.manager.last_service_data.get(ENTITY_LIGHT_1) is not None
assert switch.manager.last_state_change.get(ENTITY_LIGHT_1) is not None
assert switch.manager.manual_control[ENTITY_LIGHT_1]
@pytest.mark.dependency(
depends=[
*GLOBAL_TEST_DEPENDENCIES,
"test_manual_control",
"test_apply_service",
"test_attributes_have_changed",
"test_state_change_handling",
]
)
@pytest.mark.dependency(depends=GLOBAL_TEST_DEPENDENCIES)
def test_is_our_context():
"""Test is_our_context function."""
context = create_context(DOMAIN, "test", 0)
@ -1211,7 +1187,6 @@ async def test_turn_on_and_off_when_already_at_that_state(hass):
await hass.async_block_till_done()
@pytest.mark.dependency(depends=GLOBAL_TEST_DEPENDENCIES)
async def test_async_update_at_interval_action(hass):
"""Test '_async_update_at_interval_action' method."""
_, switch = await setup_switch(hass, {})
@ -1219,7 +1194,6 @@ async def test_async_update_at_interval_action(hass):
@pytest.mark.parametrize("separate_turn_on_commands", (True, False))
@pytest.mark.dependency(depends=GLOBAL_TEST_DEPENDENCIES)
async def test_separate_turn_on_commands(hass, separate_turn_on_commands):
"""Test 'separate_turn_on_commands' argument."""
switch, (light, *_) = await setup_lights_and_switch(
@ -1256,7 +1230,6 @@ async def test_separate_turn_on_commands(hass, separate_turn_on_commands):
assert sleep_color_temp != color_temp
@pytest.mark.dependency(depends=GLOBAL_TEST_DEPENDENCIES)
async def test_area(hass):
switch, (light, *_) = await setup_lights_and_switch(hass)
@ -1293,7 +1266,6 @@ async def test_area(hass):
assert light.entity_id not in switch.manager.last_service_data
@pytest.mark.dependency(depends=GLOBAL_TEST_DEPENDENCIES)
async def test_change_switch_settings_service(hass):
"""Test adaptive_lighting.change_switch_settings service."""
switch, (_, _, light) = await setup_lights_and_switch(hass)
@ -1346,7 +1318,6 @@ async def test_change_switch_settings_service(hass):
assert switch._sun_light_settings.min_color_temp == 2500
@pytest.mark.dependency(depends=GLOBAL_TEST_DEPENDENCIES)
async def test_cancellable_service_calls_task(hass):
"""Test the creation and execution of the task that wraps adaptation service calls."""
(light, *_) = await setup_lights(hass)
@ -1377,7 +1348,6 @@ async def test_cancellable_service_calls_task(hass):
assert task.done()
@pytest.mark.dependency(depends=GLOBAL_TEST_DEPENDENCIES)
async def test_service_calls_task_cancellation(hass):
"""Tests if the task that wraps ongoing adaptation service calls gets cancelled."""
_, switch = await setup_switch(hass, {})
@ -1441,7 +1411,7 @@ async def test_proactive_adaptation(hass):
)
event_context_ids = await _turn_on_and_track_event_contexts(
hass, "test_context", ENTITY_LIGHT3
hass, "test_context", ENTITY_LIGHT_3
)
# Expect a single service call
@ -1449,7 +1419,7 @@ async def test_proactive_adaptation(hass):
assert event_context_ids == ["test_context"]
# Expect adapted light state
state = hass.states.get(ENTITY_LIGHT3)
state = hass.states.get(ENTITY_LIGHT_3)
# Sun light settings use %, state only contains absolute
assert state.attributes[ATTR_BRIGHTNESS] == 171 # == 67%
assert state.attributes[ATTR_COLOR_TEMP_KELVIN] == 3448
@ -1476,7 +1446,7 @@ async def test_proactive_adaptation_with_separate_commands(hass):
)
event_context_ids = await _turn_on_and_track_event_contexts(
hass, "test_context", ENTITY_LIGHT3
hass, "test_context", ENTITY_LIGHT_3
)
# Expect two service calls
@ -1485,7 +1455,7 @@ async def test_proactive_adaptation_with_separate_commands(hass):
assert is_our_context_id(event_context_ids[1])
# Expect adapted light state
state = hass.states.get(ENTITY_LIGHT3)
state = hass.states.get(ENTITY_LIGHT_3)
assert state.attributes[ATTR_BRIGHTNESS] == 171
assert state.attributes[ATTR_COLOR_TEMP_KELVIN] == 3448
@ -1504,7 +1474,7 @@ async def test_proactive_adaptation_toggle(hass):
await hass.services.async_call(
LIGHT_DOMAIN,
SERVICE_TOGGLE,
{ATTR_ENTITY_ID: ENTITY_LIGHT3},
{ATTR_ENTITY_ID: ENTITY_LIGHT_3},
blocking=True,
context=Context(id="test1"),
)
@ -1515,7 +1485,7 @@ async def test_proactive_adaptation_toggle(hass):
await hass.services.async_call(
LIGHT_DOMAIN,
SERVICE_TOGGLE,
{ATTR_ENTITY_ID: ENTITY_LIGHT3},
{ATTR_ENTITY_ID: ENTITY_LIGHT_3},
blocking=True,
context=Context(id="test2"),
)
@ -1540,14 +1510,14 @@ async def test_proactive_adaptation_transition_override(hass):
await hass.services.async_call(
LIGHT_DOMAIN,
SERVICE_TURN_ON,
{ATTR_ENTITY_ID: ENTITY_LIGHT3},
{ATTR_ENTITY_ID: ENTITY_LIGHT_3},
blocking=True,
)
await hass.services.async_call(
LIGHT_DOMAIN,
SERVICE_TURN_ON,
{ATTR_ENTITY_ID: ENTITY_LIGHT3, ATTR_TRANSITION: 456},
{ATTR_ENTITY_ID: ENTITY_LIGHT_3, ATTR_TRANSITION: 456},
blocking=True,
)
@ -1560,7 +1530,7 @@ async def test_proactive_adaptation_transition_override(hass):
assert set({ATTR_TRANSITION: 456}.items()).issubset(kwargs.items())
# Cleanup
switch.manager.cancel_ongoing_adaptation_calls(ENTITY_LIGHT3)
switch.manager.cancel_ongoing_adaptation_calls(ENTITY_LIGHT_3)
async def test_two_switches_for_single_light(hass):
@ -1588,7 +1558,7 @@ async def test_two_switches_for_single_light(hass):
await hass.services.async_call(
LIGHT_DOMAIN,
SERVICE_TURN_ON if state else SERVICE_TURN_OFF,
{ATTR_ENTITY_ID: ENTITY_LIGHT, **kwargs},
{ATTR_ENTITY_ID: ENTITY_LIGHT_1, **kwargs},
blocking=True,
)
await hass.async_block_till_done()
@ -1672,31 +1642,31 @@ async def test_adapt_until_sleep_and_rgb_colors(hass):
assert not switch._settings["force_rgb_color"]
assert switch._settings[ATTR_BRIGHTNESS_PCT] == DEFAULT_MAX_BRIGHTNESS
assert switch._settings["color_temp_kelvin"] > min_color_temp
assert "color_temp_kelvin" in switch.manager.last_service_data[ENTITY_LIGHT]
assert "color_temp_kelvin" in switch.manager.last_service_data[ENTITY_LIGHT_1]
# One hour after sunset the brightness should be down and use RGB
await patch_time_and_update(after_sunset)
assert switch._settings["force_rgb_color"]
assert switch._settings[ATTR_BRIGHTNESS_PCT] < DEFAULT_MAX_BRIGHTNESS
assert "rgb_color" in switch.manager.last_service_data[ENTITY_LIGHT]
assert "rgb_color" in switch.manager.last_service_data[ENTITY_LIGHT_1]
# At sunrise the brightness should be max and use Kelvin
await patch_time_and_update(sunrise)
assert switch._settings[ATTR_BRIGHTNESS_PCT] == DEFAULT_MAX_BRIGHTNESS
assert switch._settings["color_temp_kelvin"] == min_color_temp
assert "color_temp_kelvin" in switch.manager.last_service_data[ENTITY_LIGHT]
assert "color_temp_kelvin" in switch.manager.last_service_data[ENTITY_LIGHT_1]
# One hour before sunrise the brightness should smaller than max
# and use RGB
await patch_time_and_update(before_sunrise)
assert switch._settings[ATTR_BRIGHTNESS_PCT] < DEFAULT_MAX_BRIGHTNESS
assert "rgb_color" in switch.manager.last_service_data[ENTITY_LIGHT]
assert "rgb_color" in switch.manager.last_service_data[ENTITY_LIGHT_1]
# One hour after sunrise the brightness should be up and it should use Kelvin
await patch_time_and_update(after_sunrise)
assert switch._settings[ATTR_BRIGHTNESS_PCT] == DEFAULT_MAX_BRIGHTNESS
assert switch._settings["color_temp_kelvin"] > min_color_temp
assert "color_temp_kelvin" in switch.manager.last_service_data[ENTITY_LIGHT]
assert "color_temp_kelvin" in switch.manager.last_service_data[ENTITY_LIGHT_1]
# Turn on sleep mode which make the brightness and color_temp
# deterministic regardless of the time