mirror of
https://github.com/basnijholt/adaptive-lighting.git
synced 2026-09-15 00:04:05 +02:00
Add test
This commit is contained in:
parent
a31ffe293a
commit
6c08ae39de
2 changed files with 51 additions and 2 deletions
|
|
@ -20,6 +20,7 @@ import ulid_transform
|
|||
import voluptuous as vol
|
||||
from homeassistant.components.light import (
|
||||
ATTR_BRIGHTNESS,
|
||||
ATTR_COLOR_TEMP,
|
||||
ATTR_COLOR_TEMP_KELVIN,
|
||||
ATTR_RGB_COLOR,
|
||||
ATTR_SUPPORTED_COLOR_MODES,
|
||||
|
|
@ -2083,14 +2084,17 @@ class AdaptiveLightingManager:
|
|||
modify_service_data(data, skipped)
|
||||
# Call light turn_on service for skipped entities
|
||||
_LOGGER.debug(
|
||||
"_service_interceptor_turn_on_handler: calling `light.turn_on` with skipped='%s', data: ",
|
||||
"_service_interceptor_turn_on_handler: calling `light.turn_on` with skipped='%s', data: '%s'",
|
||||
skipped,
|
||||
data,
|
||||
)
|
||||
service_data = data.copy()
|
||||
service_data.update(service_data.pop(CONF_PARAMS, {}))
|
||||
service_data.pop(ATTR_COLOR_TEMP, None)
|
||||
await self.hass.services.async_call(
|
||||
LIGHT_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
data,
|
||||
service_data,
|
||||
blocking=True,
|
||||
context=call.context,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1563,6 +1563,51 @@ async def test_proactive_adaptation_transition_override(hass):
|
|||
switch.manager.cancel_ongoing_adaptation_calls(ENTITY_LIGHT3)
|
||||
|
||||
|
||||
async def test_proactive_multiple_lights(hass):
|
||||
"""Create switch and demo lights."""
|
||||
# Setup demo lights and turn on
|
||||
lights_instances = await setup_lights(hass)
|
||||
# Setup switches
|
||||
lights = [
|
||||
ENTITY_LIGHT,
|
||||
"light.ceiling_lights",
|
||||
ENTITY_LIGHT3,
|
||||
]
|
||||
await hass.services.async_call(
|
||||
LIGHT_DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
{ATTR_ENTITY_ID: lights},
|
||||
blocking=True,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
defaults = {
|
||||
CONF_SUNRISE_TIME: datetime.time(SUNRISE.hour),
|
||||
CONF_SUNSET_TIME: datetime.time(SUNSET.hour),
|
||||
CONF_INITIAL_TRANSITION: 0,
|
||||
CONF_TRANSITION: 0,
|
||||
CONF_DETECT_NON_HA_CHANGES: True,
|
||||
CONF_PREFER_RGB_COLOR: False,
|
||||
CONF_MIN_COLOR_TEMP: 2500, # to not coincide with sleep_color_temp}
|
||||
INTERNAL_CONF_PROACTIVE_SERVICE_CALL_ADAPTATION: True,
|
||||
}
|
||||
assert all(hass.states.get(light) is not None for light in lights)
|
||||
_, switch1 = await setup_switch(
|
||||
hass, {CONF_NAME: "switch1", CONF_LIGHTS: [lights[0]], **defaults}
|
||||
)
|
||||
_, switch2 = await setup_switch(
|
||||
hass, {CONF_NAME: "switch2", CONF_LIGHTS: [lights[1]], **defaults}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
LIGHT_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: lights},
|
||||
blocking=True,
|
||||
context=Context(id="test1"),
|
||||
)
|
||||
assert switch1.manager.is_proactively_adapting("test1")
|
||||
|
||||
|
||||
async def test_two_switches_for_single_light(hass):
|
||||
"""Test the case where someone has two switches for a single light.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue