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

Test that switch is on before updating time listeners #936

Merged
merged 1 commit into from
Feb 21, 2024

Conversation

droans
Copy link
Contributor

@droans droans commented Feb 21, 2024

Calling adaptive_lighting.change_switch_settings while the lights are off will cause the below errors to appear in your HA logs:

2024-02-21 11:04:29.042 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/config/custom_components/adaptive_lighting/switch.py", line 1132, in _async_update_at_interval_action
    await self._update_attrs_and_maybe_adapt_lights(
  File "/config/custom_components/adaptive_lighting/switch.py", line 1361, in _update_attrs_and_maybe_adapt_lights
    assert self.is_on
AssertionError

These errors appear about every 90 seconds, I assume more or less depending on the set transition time.

It appears this is because the function handle_change_switch_settings will always make a call to _update_time_interval_listener, even when the switch is off.

This PR just adds a single line to check if the switch is on before calling the above function.

@droans droans requested a review from basnijholt as a code owner February 21, 2024 17:38
@basnijholt
Copy link
Owner

@all-contributors please add @droans for code

@basnijholt basnijholt merged commit 92aa504 into basnijholt:main Feb 21, 2024
14 of 15 checks passed
Copy link
Contributor

@basnijholt

I've put up a pull request to add @droans! 🎉

@basnijholt
Copy link
Owner

Thanks a lot for fixing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants