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

Fix autoreset_control_seconds_test on dev HA core #733

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
76a0f89
Fix autoreset_control_seconds_test on dev HA core
basnijholt Aug 10, 2023
a641f28
change times
basnijholt Aug 10, 2023
cf8bd94
remove loggin
basnijholt Aug 10, 2023
a591b23
Test working and non-working
basnijholt Aug 10, 2023
af6db3d
Merge remote-tracking branch 'origin/main' into fix-autoreset-dev-core
basnijholt Aug 10, 2023
34b3dee
more tests
basnijholt Aug 10, 2023
814bbd6
use full ref
basnijholt Aug 10, 2023
4508c39
verify error in 2023.8.0
basnijholt Aug 10, 2023
eb77863
more
basnijholt Aug 10, 2023
d5c0fe1
more
basnijholt Aug 10, 2023
bb09c73
more
basnijholt Aug 10, 2023
255b443
more
basnijholt Aug 10, 2023
163493b
one before 2023.7.3 and one after
basnijholt Aug 10, 2023
d910bf5
run a crazy amount of jobs
basnijholt Aug 10, 2023
82c57cc
test more
basnijholt Aug 10, 2023
3a79c8d
limit range
basnijholt Aug 10, 2023
11c4d72
limit range
basnijholt Aug 10, 2023
e179024
probably 3a06659120aa629e0db290ec9e83e2ad129baaf3 is the cause
basnijholt Aug 10, 2023
ad897fd
add more logging
basnijholt Aug 10, 2023
8ad56a3
add one more logging call
basnijholt Aug 10, 2023
1193f4d
remove logging call and use hass.async_create_task
basnijholt Aug 10, 2023
29ce84b
add log
basnijholt Aug 10, 2023
eb57209
await switch.manager.adaptation_tasks
basnijholt Aug 10, 2023
5648750
assert 0
basnijholt Aug 10, 2023
04b3c53
remove log statement
basnijholt Aug 10, 2023
6ef8d41
undo log
basnijholt Aug 10, 2023
98390a5
revert tests
basnijholt Aug 10, 2023
2f0223d
await in test again
basnijholt Aug 10, 2023
aeeddd0
shorter periods
basnijholt Aug 10, 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
8 changes: 6 additions & 2 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ jobs:
- python-version: "3.10"
core-version: "2023.4.6"
- python-version: "3.10"
core-version: "2023.5.2"
core-version: "2023.5.4"
- python-version: "3.11"
core-version: "2023.6.1"
core-version: "2023.6.3"
- python-version: "3.11"
core-version: "2023.7.3"
- python-version: "3.11"
core-version: "2023.8.1"
- python-version: "3.11"
core-version: "dev"
steps:
Expand Down
8 changes: 3 additions & 5 deletions custom_components/adaptive_lighting/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2013,11 +2013,9 @@ async def _service_interceptor_turn_on_single_light_handler(

# Don't await to avoid blocking the service call.
# Assign to a variable only to await in tests.
self.adaptation_tasks.add(
asyncio.create_task(
switch.execute_cancellable_adaptation_calls(adaptation_data),
),
)
coro = switch.execute_cancellable_adaptation_calls(adaptation_data)
task = self.hass.async_create_task(coro)
self.adaptation_tasks.add(task)
# Remove tasks that are done
if done_tasks := [t for t in self.adaptation_tasks if t.done()]:
self.adaptation_tasks.difference_update(done_tasks)
Expand Down
5 changes: 3 additions & 2 deletions tests/test_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@ async def test_auto_reset_manual_control(hass):

async def update():
await switch._update_attrs_and_maybe_adapt_lights(context=context, transition=0)
await asyncio.gather(*switch.manager.adaptation_tasks)
await hass.async_block_till_done()

async def turn_light(state, **kwargs):
Expand Down Expand Up @@ -796,10 +797,10 @@ async def turn_light(state, **kwargs):
)

# Do a couple of quick changes and check that light is not reset
for i in range(3):
for i in range(15): # do 15 changes to get to >0.1s
_LOGGER.debug("Quick change %s", i)
await turn_light(True, brightness=(i + 1) * 20)
await asyncio.sleep(0.05) # Less than 0.1
await asyncio.sleep(0.01) # Less than 0.1
assert manual_control[light.entity_id]

await update()
Expand Down