Commit graph

708 commits

Author SHA1 Message Date
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
Mario Guggenberger
36c656b795
docs: Ikea light config recommendations (#614) 2023-06-14 09:39:47 -07:00
pre-commit-ci[bot]
42edd5eb8f
[pre-commit.ci] pre-commit autoupdate (#587)
updates:
- [github.com/asottile/pyupgrade: v3.3.2 → v3.6.0](https://github.com/asottile/pyupgrade/compare/v3.3.2...v3.6.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-06-12 17:43:18 -07:00
Bas Nijholt
68d500bd12
Update manifest.json (#613) 1.14.0 2023-06-12 16:13:29 -07:00
Mario Guggenberger
6283158ff7
VS Code Dev Container (dev & test environment) (#605)
* build: dev container

Add a VS Code Dev Container from the blueprint at bceaae212f

* build: dev container test setup

Add support for unit testing in the dev container environment with debugging and code coverage.

* ci: adjust to dev container test restructuring

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* ci: fix coverage collection

* build: add dummy light to HA config

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* build: update dev container to Python 3.11 (for HA 2023.6)

* Add VS Code tasks

* Use pre-commit hooks for linting

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Unpin HA version

---------

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-06-11 15:33:07 -07:00
Mario Guggenberger
12dae4b6a6
fix: 2023.6 compatibility (#607)
* fix: 2023.6.0 compatibility

* ci: test with Python 3.11 against 2023.6.0b4

* Set 2023.06.0

* Bump to 2023.06.1

---------

Co-authored-by: Bas Nijholt <basnijholt@gmail.com>
2023-06-11 14:12:37 -07:00
Bas Nijholt
90b8d6089d
Bump to 1.13.0 in manifest.json (#610) 1.13.0 2023-06-08 16:09:57 -07:00
Mario Guggenberger
2c8a45604a
feat: brightness prioritization (#598)
* feat: optional brightness prioritization

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Remove config flag and change default split order

* Fix test

* Fix edge case

* Add tests

* Backwards compatiblity

* Fix another edge case

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-06-08 16:01:19 -07:00
Bas Nijholt
4683f083f6
Update version to 1.12.0 in manifest.json (#596) 2023-05-22 12:16:40 -07:00
allcontributors[bot]
bf3b709ba6
docs: add protyposis as a contributor for code (#597) 2023-05-21 13:35:45 -07:00
Mario Guggenberger
2033fcebe9
fix: lights unexpectedly turn back on after switch-off (#590) 2023-05-21 10:36:16 -07:00
Bas Nijholt
29e54185e3
Add "See also" to README (#591) 1.12.0
* Add "See also" section

* Add date

* chore(docs): update TOC

* Add YouTube videos

* Add components.cloud

* verbose loggin

---------

Co-authored-by: basnijholt <basnijholt@users.noreply.github.com>
2023-05-12 11:36:24 -07:00
pre-commit-ci[bot]
9caf645093
[pre-commit.ci] pre-commit autoupdate (#584)
updates:
- [github.com/asottile/pyupgrade: v3.3.1 → v3.3.2](https://github.com/asottile/pyupgrade/compare/v3.3.1...v3.3.2)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-05-01 16:56:03 -07:00
Benjamin Auquite
47c5ea93e0
Add test_supported_features and fix the problem introduced in #565 (#575)
* Update test_switch.py

* Update test_switch.py

* test is now done.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix the test only.

test is backwards compatible with the old method.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix _supported_to_attributes

everything works now.

* pre-commit fixes

cannot fix the `function too complex` problem.

* ignore test_switch.py in `pre-commit-config.yaml`

* Add ignore C901 to test_supported_features

* remove commented out code

---------

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: Bas Nijholt <bas@nijho.lt>
2023-04-27 12:56:49 -07:00
Benjamin Auquite
adf0d0cf30
Auto reload YAML config changes (#573)
* Update __init__.py

* Update __init__.py

* skip installing codecov

* remove in CI

* test 2023.4.6

---------

Co-authored-by: Bas Nijholt <bas@nijho.lt>
2023-04-26 19:10:52 -07:00
Benjamin Auquite
a888afd6dc
Refactor _supported_features (#565)
* initial commit

* change features to dict

* another slight refactor
2023-04-10 10:07:31 -07:00
Benjamin Auquite
e30b7debe5
Refactor _adapt_lights into _update_manual_control_and_maybe_adapt (#513) 1.11.0
* Add auto_reset_manual_control with async timer

* cherry-pick wait for transition stuff

* Update switch.py

* merge wait_for_transition

* Update switch.py

* not renamed in this branch yet.

* Update switch.py

* update tests

* Update switch.py

* Update switch.py

* merge related fix

* cleanup

* Revert "cleanup"

This reverts commit 3aa2f3242b.

* 0.1 sometimes fails the test

* not in this pr yet

* Update switch.py

* Update switch.py

* Update switch.py

* Update switch.py

* Update README.md, strings.json, and services.yaml

* slight refactor

* Update switch.py

* Update switch.py

* Possible refactor of _update_attrs_and_maybe_adapt_lights

* cleaned up

* Revert "cleaned up"

This reverts commit 441cb1ff5c.

* Possible refactor of _update_attrs_and_maybe_adapt_lights (#537)

Co-authored-by: Benjamin Auquite <halomastar@gmail.com>

* Revert "Revert "cleaned up""

This reverts commit 11b268148b.

* remove bad merge conflict

* revert permissions

* Bump to 1.11.0

* Undo unrelated test changes

* 'else' instead of 'continue'

---------

Co-authored-by: Bas Nijholt <bas@nijho.lt>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Bas Nijholt <basnijholt@gmail.com>
2023-04-08 18:54:06 -07:00
Bas Nijholt
fe7bdd3940
Add auto_reset_time_remaining attribute (#558)
* Add auto_reset_time_remaining attribute

* fix attr

* Add test
2023-04-08 05:39:08 -05:00
Bas Nijholt
39e9d0e74f
Update issue templates (#557) 2023-04-07 19:40:36 -05:00
Bas Nijholt
c0c363136b
Test multiple Home Assistant releases and the dev branch (#552)
* Test for multiple Home Assistant versions

* Install ulid-transform

* remove unnecessary unsafe `async_set` from test

* Skip test_state_change_handlers in <2023.4

* Revert "Skip test_state_change_handlers in <2023.4"

This reverts commit 8d01b6ec4e.

---------

Co-authored-by: Benjamin Auquite <halomastar@gmail.com>
2023-04-06 16:36:57 -07:00
Benjamin Auquite
a01fec0211
Bump to 1.10.1 (#551) 1.10.1
* Update manifest.json

* undo merge mistake

* Version 1.10.1
2023-04-06 13:29:32 -07:00