Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement call intercept for multiple lights #679

Merged
merged 73 commits into from
Aug 4, 2023
Merged
Changes from 3 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
3b4602c
Implement call intercept for multiple lights
basnijholt Jul 29, 2023
25d77ce
remove comment
basnijholt Jul 29, 2023
d07ca3d
skip if no eids
basnijholt Jul 29, 2023
60c8c6d
add comment
basnijholt Jul 29, 2023
d03613d
fix type
basnijholt Jul 29, 2023
c8a3e9a
Fix skipped
basnijholt Jul 29, 2023
3261e9f
indentation
basnijholt Jul 29, 2023
28fbd60
Add logging and fix error
basnijholt Jul 30, 2023
e98c5b1
Fix for HA ≤2023.04
basnijholt Jul 30, 2023
bed6163
simplify
basnijholt Jul 30, 2023
8e30574
remove unused ignores
basnijholt Jul 30, 2023
a31ffe2
Debug mode
basnijholt Jul 30, 2023
6c08ae3
Add test
basnijholt Jul 30, 2023
6a7e1c3
Make test failing
basnijholt Jul 30, 2023
8516e70
rename switch
basnijholt Jul 30, 2023
9006c6d
rename lights
basnijholt Jul 30, 2023
164b978
Fix tests
basnijholt Jul 30, 2023
c6a4801
Rename lights in tests
basnijholt Jul 30, 2023
da57df8
Remove unused dependencies
basnijholt Jul 30, 2023
82c7523
Merge branch 'test-rename-lights' into multi-light-intercept
basnijholt Jul 30, 2023
7abb469
Merge remote-tracking branch 'origin/main' into multi-light-intercept
basnijholt Jul 30, 2023
a680881
Improve tests
basnijholt Jul 30, 2023
a38b51f
More tests
basnijholt Jul 30, 2023
8e4ff80
Remove the DEBUG_MODE
basnijholt Jul 30, 2023
462ab0a
Merge remote-tracking branch 'origin/main' into multi-light-intercept
basnijholt Jul 30, 2023
50ecf54
Add doc-string
basnijholt Jul 30, 2023
76a9e09
Merge remote-tracking branch 'origin/main' into multi-light-intercept
basnijholt Jul 31, 2023
f04c475
Extra test
basnijholt Jul 31, 2023
6a14d71
assert
basnijholt Jul 31, 2023
155c6f8
extra test
basnijholt Jul 31, 2023
645b262
Merge remote-tracking branch 'origin/main' into multi-light-intercept
basnijholt Aug 1, 2023
8a16c9f
Comments
basnijholt Aug 1, 2023
1959278
fix
basnijholt Aug 1, 2023
1c6c274
fix
basnijholt Aug 1, 2023
74387ac
expand light groups
basnijholt Aug 1, 2023
2a78cce
more logging
basnijholt Aug 1, 2023
8ff125f
sort
basnijholt Aug 1, 2023
18803e8
Revert is_proactively_adapting checks
basnijholt Aug 1, 2023
462b1b6
simplify the mapping
basnijholt Aug 1, 2023
d22a05c
Revert "Revert is_proactively_adapting checks"
basnijholt Aug 1, 2023
eb814cd
test
basnijholt Aug 1, 2023
216ec2d
no light groups
basnijholt Aug 1, 2023
48ad8f7
do not expand
basnijholt Aug 1, 2023
a2479d4
Do not expand_light_groups in intercept
basnijholt Aug 2, 2023
4a149f0
more logging
basnijholt Aug 2, 2023
8f312bf
Fix
basnijholt Aug 2, 2023
c2ba878
add comment
basnijholt Aug 2, 2023
fa2c270
Add multi_light_intercept config option
basnijholt Aug 2, 2023
414630f
Merge fa2c27022156182e2773d88b8949bee2615627ff into e5133936536cb02d6…
basnijholt Aug 2, 2023
07f40eb
Update README.md, strings.json, and services.yaml
github-actions[bot] Aug 2, 2023
d12d58d
add light group
basnijholt Aug 2, 2023
585544a
fix platform
basnijholt Aug 2, 2023
abb4d05
add simple test
basnijholt Aug 2, 2023
26d338e
turn off again
basnijholt Aug 2, 2023
5f50cef
Test without take over control
basnijholt Aug 2, 2023
7ca3d92
improve test and fix it in one way
basnijholt Aug 2, 2023
0a06c6e
Fixes
basnijholt Aug 3, 2023
3e8933f
add cleanup fixture
basnijholt Aug 3, 2023
aea72ea
format
basnijholt Aug 3, 2023
38c858e
Update test_switch.py
basnijholt Aug 3, 2023
ebc3302
Merge remote-tracking branch 'origin/main' into multi-light-intercept
basnijholt Aug 3, 2023
d772761
Merge remote-tracking branch 'origin/main' into multi-light-intercept
basnijholt Aug 3, 2023
644ab1d
add __str__
basnijholt Aug 3, 2023
57240cb
remove unneeded call
basnijholt Aug 3, 2023
5d3627b
simplify service_data construction
basnijholt Aug 3, 2023
fcd1139
Generalize is_our_context
basnijholt Aug 3, 2023
645ee26
Fix multi_light_intercept: false
basnijholt Aug 4, 2023
7102f71
add comments
basnijholt Aug 4, 2023
2c577f3
add docs
basnijholt Aug 4, 2023
ac13435
Merge 2c577f3be288e8f3bd8e72853b9b5c4ae1092474 into b80b253fa1b840c63…
basnijholt Aug 4, 2023
d5a18f8
Update README.md, strings.json, and services.yaml
github-actions[bot] Aug 4, 2023
0f13c59
Add feature line
basnijholt Aug 4, 2023
8c3bb2d
move function
basnijholt Aug 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions tests/test_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,6 @@

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)
Expand Down Expand Up @@ -342,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
):
Expand Down Expand Up @@ -531,7 +525,6 @@ def assert_expected_color_temp(state):
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)
Expand All @@ -551,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)
Expand Down Expand Up @@ -702,7 +694,6 @@ def increased_color_temp():
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}
Expand Down Expand Up @@ -753,7 +744,6 @@ async def turn_light(state, **kwargs):
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)
Expand Down Expand Up @@ -818,9 +808,6 @@ async def apply(**kwargs):
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."""

Expand Down Expand Up @@ -871,7 +858,6 @@ async def update():
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):
Expand Down Expand Up @@ -934,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.
Expand Down Expand Up @@ -1128,16 +1113,6 @@ async def update(force: bool = False):
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)
Expand Down Expand Up @@ -1212,15 +1187,13 @@ 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, {})
await switch._async_update_at_interval_action()


@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(
Expand Down Expand Up @@ -1257,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)

Expand Down Expand Up @@ -1294,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)
Expand Down Expand Up @@ -1347,7 +1318,6 @@ async def change_switch_settings(**kwargs):
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)
Expand Down Expand Up @@ -1378,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, {})
Expand Down