Bas Nijholt
53ed220fa0
Bail adapting if on event equals off event context ( #696 )
...
* Bail adapting if on event equals off event context
Should prevent this (I saw in my logs)
```
2023-08-02 21:49:56.516 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_off('['light.philips_go', 'light.bed_led', 'light.bamboo']', transition=10.0)' event with context.id='01H6WVP8RJF4JZ78SFD98YA0RG'
2023-08-02 21:49:56.637 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'on' → 'off' event for 'light.bamboo' with context.id='01H6WVP8RJF4JZ78SFD98YA0RG'
2023-08-02 21:49:56.672 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'on' → 'off' event for 'light.bed_led' with context.id='01H6WVP8RJF4JZ78SFD98YA0RG'
2023-08-02 21:49:56.747 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'on' → 'off' event for 'light.philips_go' with context.id='01H6WVP8RJF4JZ78SFD98YA0RG'
2023-08-02 21:50:00.501 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.philips_go' 'state_changed' event: '{'min_color_temp_kelvin': 2000, 'max_color_temp_kelvin': 6666, 'min_mireds': 150, 'max_mireds': 500, 'effect_list': ['blink', 'breathe', 'okay', 'channel_change', 'candle', 'fireplace', 'colorloop', 'finish_effect', 'stop_effect', 'stop_hue_effect'], 'supported_color_modes': ['color_temp', 'xy'], 'color_mode': <ColorMode.XY: 'xy'>, 'brightness': 10, 'hs_color': (0.0, 100.0), 'rgb_color': (255, 0, 0), 'xy_color': (0.701, 0.299), 'friendly_name': 'Philips Go', 'supported_features': <LightEntityFeature.EFFECT|FLASH|TRANSITION: 44>}' with context.id='01H6WVP8RJF4JZ78SFD98YA0RG'
2023-08-02 21:50:00.502 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'off' → 'on' event for 'light.philips_go' with context.id='01H6WVP8RJF4JZ78SFD98YA0RG'
2023-08-02 21:50:00.502 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] is_proactively_adapting_context='False', context_id='01H6WVP8RJF4JZ78SFD98YA0RG'
2023-08-02 21:50:00.502 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] just_turned_off: Waiting with adjusting 'light.philips_go' for 6.240101
2023-08-02 21:50:00.528 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.bed_led' 'state_changed' event: '{'min_color_temp_kelvin': 2000, 'max_color_temp_kelvin': 6535, 'min_mireds': 153, 'max_mireds': 500, 'effect_list': ['blink', 'breathe', 'okay', 'channel_change', 'candle', 'fireplace', 'colorloop', 'finish_effect', 'stop_effect', 'stop_hue_effect'], 'supported_color_modes': ['color_temp', 'xy'], 'color_mode': <ColorMode.XY: 'xy'>, 'brightness': 10, 'hs_color': (10.824, 100.0), 'rgb_color': (255, 46, 0), 'xy_color': (0.689, 0.309), 'friendly_name': 'Bed LED', 'supported_features': <LightEntityFeature.EFFECT|FLASH|TRANSITION: 44>}' with context.id='01H6WVP8RJF4JZ78SFD98YA0RG'
2023-08-02 21:50:00.529 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'off' → 'on' event for 'light.bed_led' with context.id='01H6WVP8RJF4JZ78SFD98YA0RG'
2023-08-02 21:50:00.529 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] is_proactively_adapting_context='False', context_id='01H6WVP8RJF4JZ78SFD98YA0RG'
2023-08-02 21:50:00.529 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] just_turned_off: Waiting with adjusting 'light.bed_led' for 6.129017
2023-08-02 21:50:00.561 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.bamboo' 'state_changed' event: '{'min_color_temp_kelvin': 2000, 'max_color_temp_kelvin': 6535, 'min_mireds': 153, 'max_mireds': 500, 'effect_list': ['blink', 'breathe', 'okay', 'channel_change', 'candle', 'fireplace', 'colorloop', 'finish_effect', 'stop_effect', 'stop_hue_effect'], 'supported_color_modes': ['color_temp', 'xy'], 'color_mode': <ColorMode.XY: 'xy'>, 'brightness': 10, 'hs_color': (299.434, 83.137), 'rgb_color': (253, 43, 255), 'xy_color': (0.382, 0.159), 'friendly_name': 'Bamboo', 'supported_features': <LightEntityFeature.EFFECT|FLASH|TRANSITION: 44>}' with context.id='01H6WVP8RJF4JZ78SFD98YA0RG'
2023-08-02 21:50:00.562 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'off' → 'on' event for 'light.bamboo' with context.id='01H6WVP8RJF4JZ78SFD98YA0RG'
2023-08-02 21:50:00.562 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] is_proactively_adapting_context='False', context_id='01H6WVP8RJF4JZ78SFD98YA0RG'
2023-08-02 21:50:00.562 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] just_turned_off: Waiting with adjusting 'light.bamboo' for 6.072956
```
* log instead
2023-08-02 22:59:01 -07:00
Bas Nijholt
807f7109d4
Require take_over_control for to ignore non-turn_on state off -> on event ( #695 )
2023-08-03 00:59:44 +00:00
badboybeyer
8d13f13873
bug: fix bug in comment in readme ( #693 )
2023-08-02 08:09:34 -07:00
Bas Nijholt
e513393653
Keep on and off state tracking in Manager and listen to toggle ( #689 )
...
* Keep on and off state tracking in Manager
* Move manual_control code
* add todo
* check is_on
* Track toggle
* handle toggle
* fix debug
* test
* add comment
* better log
* Fix comment
* log
* test
* get
* check
* cancel early
* rephrase
* add assert
* Remove check
2023-07-31 18:40:32 -07:00
pre-commit-ci[bot]
da2e27d738
[pre-commit.ci] pre-commit autoupdate ( #691 )
...
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.280 → v0.0.281](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.280...v0.0.281 )
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-07-31 18:15:36 -07:00
Bas Nijholt
aa9f69a7bb
Set last_service_data in the right place ( #652 )
...
* Set last_service_data in the right place
* Do not get but access key
* rename
2023-07-31 17:52:53 -07:00
Bas Nijholt
d588a5984a
Refactor _update_attrs_and_maybe_adapt_lights ( #688 )
...
* Do not call self.manager.significant_change when not needed
* refact
* fix
* fix
* Add more logging to tests
* remove
2023-07-31 04:57:30 +00:00
Bas Nijholt
1842ac9bd5
Do not assert but issue a warning ( #687 )
...
1.18.2
* Do not assert but issue a warning
* bump to 1.18.2
2023-07-30 13:28:58 -07:00
Bas Nijholt
e98f0dfa55
Bump to 1.18.1
1.18.1
2023-07-30 13:11:30 -07:00
Bas Nijholt
f4d872a540
Make sure that SimpleSwitches are added before AdaptiveSwitch ( #686 )
2023-07-30 20:01:08 +00:00
Bas Nijholt
2e25af3125
Do not intercept effect and flash calls ( #685 )
...
* Do not intercept effect and flash calls
* log
* Do not intercept flash
2023-07-30 19:32:59 +00:00
Bas Nijholt
2b35ee1e5e
Mark as manually controlled when using flash, effect, or RGBW(W) ( #684 )
...
* Mark as manually controlled when using flash or effect
* Add comment
* Add RGBW and RGBWW
2023-07-30 18:49:40 +00:00
Bas Nijholt
68985199f6
Rename lights in tests ( #681 )
...
* Rename lights in tests
* Remove unused dependencies
2023-07-30 04:48:45 +00:00
Bas Nijholt
8322e516ba
Add link to repo in README
2023-07-28 18:41:41 -07:00
Bas Nijholt
8967747f31
Release 1.18.0 (fixes lights accidentally turning on 🚀 🎉 ) ( #676 )
1.18.0
2023-07-28 17:25:50 -07:00
Bas Nijholt
f28c031551
Fix alias in FUNDING.yml ( #677 )
2023-07-28 17:20:01 -07:00
Bas Nijholt
5c897f76da
More typing fixes ( #675 )
2023-07-29 00:17:26 +00:00
Bas Nijholt
5fa74a838f
Typing fixes ( #674 )
...
* Typing fixes
* Ignore tyoe
2023-07-28 16:55:46 -07:00
Bas Nijholt
416f1eb2f1
Rename maybe_cancel_adjusting to just_turned_off ( #673 )
2023-07-28 22:22:16 +00:00
Bas Nijholt
89c90adde0
Only start adapting on light.turn_on when detect_non_ha_changes: false to prevent unwanted light turn ons ( #663 )
...
* Fixes in maybe_cancel_adjusting to possibly fix accidental turn on
* simplify logic in maybe_cancel_adjusting
* Add logging statements
* only control if turn_on called
* more logs
* add TODO
* Add _state_event_is_from_our_turn_on
* Ignore off->on state switches that are not accociated with light.turn_on
* improve logging
* rename
* Update docs
* Update README.md, strings.json, and services.yaml
* Add caution message to README
* Change order of emojis
* Update README.md, strings.json, and services.yaml
* Check that platform is not None
* log the call
* fix args
* Do not re-add already added configs
* Do not re-add already added configs
* Use async_remove
* remove unused code
* [pre-commit.ci] pre-commit autoupdate (#627 )
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.279 → v0.0.280](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.279...v0.0.280 )
- [github.com/psf/black: 23.3.0 → 23.7.0](https://github.com/psf/black/compare/23.3.0...23.7.0 )
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Bas Nijholt <basnijholt@gmail.com>
* Extra logging statement
* Add to README
* log context_id
* return right indent
* move comment
* Skip on self.manager.is_proactively_adapting
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-07-28 15:17:17 -07:00
Bas Nijholt
f23aeb269b
Bump to 1.17.5
1.17.5
2023-07-27 18:09:37 -07:00
Bas Nijholt
9d6f93538f
Do not create multiple AdaptiveLightingManager instances ( #672 )
...
I didn't realize that setdefault always executes the default.
2023-07-28 01:01:06 +00:00
Bas Nijholt
f699486fd0
Only cancel ongoing adaptation calls if still running ( #668 )
2023-07-27 17:34:56 -07:00
pre-commit-ci[bot]
a6e987438d
[pre-commit.ci] pre-commit autoupdate ( #627 )
...
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.279 → v0.0.280](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.279...v0.0.280 )
- [github.com/psf/black: 23.3.0 → 23.7.0](https://github.com/psf/black/compare/23.3.0...23.7.0 )
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Bas Nijholt <basnijholt@gmail.com>
2023-07-27 17:22:12 +00:00
Bas Nijholt
9e15d1bd22
Update to 1.17.4 in manifest.json ( #670 )
1.17.4
2023-07-27 16:51:59 +00:00
Bas Nijholt
c64d9cefbe
Delete AdaptiveLighting instances that have been removed from YAML ( #669 )
...
* Do not re-add already added configs
* Use async_remove
2023-07-26 23:40:54 -07:00
Bas Nijholt
1cda675bbe
Add @bind_hass to functions ( #667 )
2023-07-26 15:01:29 -07:00
Bas Nijholt
e9297d562f
Cleanup after add_to_platform_abort is called, try-except intercept, update strings.json, fixes #658 ( #659 )
...
1.17.3
* Cleanup after add_to_platform_abort is called, fixes #658
* Add note
* try-catch because of priv
* Catch all exceptions
* Bump to 1.17.3 in manifest.json
* assert that hass is not None
* Rename _light_event_action -> _light_state_event_action
* update .github/update-strings.py
* Update README.md, strings.json, and services.yaml
* update name
* Fixes
* Update README.md, strings.json, and services.yaml
* Add name
* Do not add name
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-07-26 12:52:03 -07:00
Bas Nijholt
8696092879
Avoid adapting lights with nothing in service_data, closes #661 ( #662 )
1.17.2
2023-07-26 02:17:11 +00:00
Bas Nijholt
f9b6753e6d
Ensure that interpolation is in [0, 1], fixes #624 ( #660 )
...
1.17.1
* Ensure that interpolation is in [0, 1], fixes #624
* Bump to 1.17.1
* Add assert
* Interpolate via HSV space
* Add test
2023-07-25 10:46:34 -07:00
Bas Nijholt
7650a1b3e6
Bump to 1.17.0 in manifest.json ( #657 )
1.17.0
2023-07-23 21:44:17 +00:00
Bas Nijholt
bb84684bce
Style with ruff and logging ( #643 )
...
* Formatting with ruff
* more logging
* Require on_only
* Different implementation
* More ruff
* Remove new logging statements
* Remove 'pylint: disable=protected'
* style
* fixes
* ruff
* Switch to ruff
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix .github
* Fix
* Add ignores
* fix arg
* fix B905
* Fix D
* Fix more
* Fix more
* order
* use path
* moer path
* Remove unused ignores
* fix tes deps
* fix typo
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-07-23 14:24:22 -07:00
Bas Nijholt
97f388608a
With transition_until_sleep and sleep_rgb, after sunset, use RGB colors ( #656 )
...
* With transition_until_sleep and sleep_rgb, after sunset, use RGB colors
Closes #624
* Add comment
* Add test
2023-07-23 13:40:03 -07:00
Bas Nijholt
c1528ec10a
Refactor, simplify code, rename, and set minimal HA core ≥2022.11 ( #655 )
...
* Rename TurnOnOffListener to AdaptiveLightingManager
* Bump Python version
* Refactor and unify methods that are called once
* Simplify adaptation_utils.py
* Improve readability in adaptation_utils.py
* More renames
* Simplify
* More renames and simplifications
* fix test
* simplify _supported_features
* rename
* walrus
* drop old astral support
* Only support HA ≥2021.06
* Require 2016.06
* Try 2023.1
* even more old versions
* test
* more versions
* verify that only ≥2022.11 works
* named args
* setdefault
* no astral v1
* var
* simplify
* no need to pass adapt_brightness and adapt_color
* Add comment
2023-07-22 21:19:01 -07:00
Bas Nijholt
69592938db
Rename TurnOnOffListener to AdaptiveLightingManager ( #654 )
...
* Rename TurnOnOffListener to AdaptiveLightingManager
* Bump Python version
2023-07-22 17:57:49 -07:00
Bas Nijholt
fee90250ee
Better logging and prevent KeyError in state_changed_event_listener ( #650 )
...
1.16.3
* Better logging
* Remove useless and erroneous logging statement
* Bump to 1.16.3
2023-07-22 12:34:20 -07:00
Bas Nijholt
db40b9af6b
Only build Docker image on main ( #648 )
2023-07-21 18:08:43 -07:00
Bas Nijholt
52c7e4b1d5
Bump to v1.16.2 in manifest.json ( #647 )
1.16.2
2023-07-21 14:56:44 -07:00
Mario Guggenberger
30a310c514
fix: overlapping adaptations ( #646 )
...
Co-authored-by: Bas Nijholt <bas@nijho.lt>
2023-07-21 14:54:38 -07:00
Bas Nijholt
49857632cc
Fix multiple switches controlling one light (reactive path) ( #644 )
...
* Fix multiple switches controlling one light
* WIP
* Keep length in AdaptationData
* Do not proceed if there is nothing to do
* Simplify
* Set tasks correctly
* log more
* WIP
* realize that intercept and double switch not possible
* Remove which from find_switch_for_lights
* Rephrase
* Check which one to cancel
* length -> max_length
* Implement test_two_switches_for_single_light
* Clean up
* Simplify is_color_brightness_or_both
* Improve test
* no wait
* logging
* just block
* make test such that it fails on main
2023-07-21 14:46:18 -07:00
Bas Nijholt
2575f4ec30
Only adapt if switch if on in _service_interceptor_turn_on_handler ( #642 )
...
1.16.1
* Do not adapt if switch is off in _service_interceptor_turn_on_handler
* Bump to 1.16.1
2023-07-20 17:12:41 -07:00
Bas Nijholt
6c001b4132
Update version to 1.16.0 in manifest.json ( #640 )
2023-07-20 14:42:36 -07:00
Bas Nijholt
19d503b4d7
Revert supported_features from #565 and #575 , fixes #601 ( #637 )
1.16.0
2023-07-20 13:59:19 -07:00
Bas Nijholt
fd5f6bf310
Pass on lights that are not managed by AL, closes #638 ( #639 )
...
1.15.2
* Pass on lights that are not managed by AL, closes #638
* Rename exception
2023-07-20 11:53:38 -07:00
Bas Nijholt
1b31b26938
Add @protyposis to codeowners ( #636 )
2023-07-20 08:53:11 -07:00
Bas Nijholt
1133f0defa
Find adaptive_switch in TurnOnOffListener ( #635 )
...
1.15.1
* Find adaptive_switch in TurnOnOffListener
* remove unused argument
* Bump to 1.15.1
2023-07-20 08:52:14 -07:00
Mario Guggenberger
1cedb3fbc7
chore: bump manifest version to 1.15.0 ( #634 )
1.15.0
2023-07-19 18:53:42 +02:00
Mario Guggenberger
ed80bd7829
feat: service call adaptation ( #628 )
...
* feat: service call adaptation
* feat: toggle-on service call adaptation
* feat: prefer service call transition
2023-07-19 09:10:21 +02:00
pre-commit-ci[bot]
d16a9a5751
[pre-commit.ci] pre-commit autoupdate ( #620 )
...
* [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v3.6.0 → v3.7.0](https://github.com/asottile/pyupgrade/compare/v3.6.0...v3.7.0 )
* Update README.md, strings.json, and services.yaml
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Bas Nijholt <basnijholt@gmail.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-07-02 15:32:44 -07:00
Mario Guggenberger
72e140e293
feat: skip redundant adaptation commands ( #615 )
...
* feat: skip redundant adaptation commands
* update README
* style
* Remove "experimental"
---------
Co-authored-by: Bas Nijholt <basnijholt@gmail.com>
Co-authored-by: Bas Nijholt <bas@nijho.lt>
2023-07-02 15:26:07 -07:00