Commit graph

753 commits

Author SHA1 Message Date
Bas Nijholt
597e050ab2
Prevent light.turn_on of light that was just turned off (#727)
Closes #726
2023-08-09 13:54:18 -07:00
Bas Nijholt
b06d38eb24 Add mp4 link in README 2023-08-08 18:03:17 -07:00
Bas Nijholt
db5f9d623c
Mention app more prominently and improve style (#725)
* Mention app more prominently

* Use dark-mode

* add setuptools

* no cyber

* no not run on PR

* Ruff fixes

* Add link

* remove unused deps
2023-08-08 17:34:35 -07:00
Bas Nijholt
f8e7880a96
Split up SunLightSettings and improve https://basnijholt.github.io/adaptive-lighting/ (#719)
* Split up SunLightSettings

* Renames

* factor out SunEvents

* more renames

* rewrite

* rewrite more

* simpler

* refactor

* refact

* raise

* refact

* rename

* move method

* clean

* Move to new module 'sun.py'

* make sun independent of HA

* rename

* Move to webapp/homeassistant_util_color.py

* Rework app

* Add link

* new plotting

* app changes

* fix tests

* test clean

* tz fixes

* fix

* use sed

* verbose

* fix tz

* fix

* tiem
2023-08-08 21:31:17 +00:00
pre-commit-ci[bot]
61d51cbf1e
[pre-commit.ci] pre-commit autoupdate (#722)
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.281 → v0.0.282](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.281...v0.0.282)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-08-07 22:20:28 -07:00
Bas Nijholt
00ec76a467
Bump to 1.19.0b4 in manifest.json (#718) 1.19.0b4 2023-08-06 19:21:39 -07:00
Bas Nijholt
ef1546b6b9
Fix min_sunrise_time and max_sunset_time (#717)
Closes #714
2023-08-07 02:21:16 +00:00
Bas Nijholt
69355b8c3a
Small WebApp improvements (#716)
* Small WebApp improvements

* Add link
2023-08-07 00:20:58 +00:00
Bas Nijholt
943a6360c7
Add simple webapp to play with different parameters (#715)
* Add simple webapp to play with different parameters

* ignore
2023-08-06 16:42:56 -07:00
Bas Nijholt
104664d358
Bump to 1.19.0b3 in manifest.json (#713) 1.19.0b3 2023-08-06 11:21:54 -07:00
Bas Nijholt
cb9ae39ee4
Fix adaptive_lighting.change_switch_settings service (#712)
* Fix adaptive_lighting.change_switch_settings service

Closes #623

* filter defaults

* fix mutable

* Revert debugging logs
2023-08-06 11:15:14 -07:00
Bas Nijholt
d2c6811e63
Bump to 1.19.0b2 in manifest.json (#710) 1.19.0b2 2023-08-05 23:06:27 -07:00
Benjamin Auquite
fec50ad526
Adapt lights simultaneously instead of one by one (#529)
* Update switch.py

* Update test_switch.py

* Revert "Update test_switch.py"

This reverts commit 87ea5243b9.

* remove unnecessary create_task

* remove unneeded len()

* Revert "remove unnecessary create_task"

This reverts commit 2c5da6d739.

* use `hass.async_create_task`

---------

Co-authored-by: Bas Nijholt <basnijholt@gmail.com>
Co-authored-by: Bas Nijholt <bas@nijho.lt>
2023-08-05 21:19:18 -07:00
Bas Nijholt
d44cb66148
Add adapt_only_on_bare_turn_on which instantly triggers manual_control when turning on with brightness or color (#709) 2023-08-05 20:56:32 -07:00
Bas Nijholt
3f17738bd1
Add warning about Zigbee groups (#708) 2023-08-05 16:48:35 -07:00
Bas Nijholt
72419cb60f
Add a min_sunrise_time and max_sunset_time (#707) 2023-08-05 22:08:45 +00:00
Bas Nijholt
11a4489cb5
Bump to 1.19.0b1 manifest.json (#706) 1.19.0b1 2023-08-05 14:42:40 -07:00
Bas Nijholt
51a18f2afb
Allow adaptive_lighting.apply to turn on lights and do not issue log message (#705) 2023-08-05 20:59:58 +00:00
Bas Nijholt
e3a84ffd96
Logging fixes in significant_changes (#704) 2023-08-05 13:52:54 -07:00
Bas Nijholt
a1cec19351
feat: add different brightness ramping mechanisms (#699)
* feat: add different brightness ramping mechanisms

* Rephrase

* Fix curves

* update images

* link to other graphs

* update images
2023-08-05 20:14:21 +00:00
Bas Nijholt
9a7cff9d6a
feat: change the order of options in config flow (#700)
* Change the order of options in config flow

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

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-08-04 21:45:12 +00:00
Bas Nijholt
1ef7ed507e
Implement call intercept for multiple lights (#679) 1.19.0b0
* Implement call intercept for multiple lights

* remove comment

* skip if no eids

* add comment

* fix type

* Fix skipped

* indentation

* Add logging and fix error

* Fix for HA ≤2023.04

* simplify

* remove unused ignores

* Debug mode

* Add test

* Make test failing

* rename switch

* rename lights

* Fix tests

* Rename lights in tests

* Remove unused dependencies

* Improve tests

* More tests

* Remove the DEBUG_MODE

* Add doc-string

* Extra test

* assert

* extra test

* Comments

* fix

* fix

* expand light groups

* more logging

* sort

* Revert is_proactively_adapting checks
This reverts commit 39fd8f2be0.

* simplify the mapping

* Revert "Revert is_proactively_adapting checks"

This reverts commit 18803e8e50.

* test

* no light groups

* do not expand

* Do not expand_light_groups in intercept

* more logging

* Fix

* add comment

* Add multi_light_intercept config option

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

* add light group

* fix platform

* add simple test

* turn off again

* Test without take over control

* improve test and fix it in one way

* Fixes

* add cleanup fixture

* format

* Update test_switch.py

* add __str__

* remove unneeded call

* simplify service_data construction

* Generalize is_our_context

* Fix multi_light_intercept: false

* add comments

* add docs

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

* Add feature line

* move function

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-08-03 17:47:09 -07:00
Bas Nijholt
4251ccacc5
Bump to 1.18.3 in manifest.json (#698) 1.18.3 2023-08-04 00:46:19 +00:00
Bas Nijholt
b80b253fa1
Warning when calling light.turn_on with brightness=0 (#678)
* Do not update the call when calling light.turn_on with brightness=0

* Simplify

* issue warning instead
2023-08-02 23:12:13 -07:00
Bas Nijholt
e0e04da0f6
Before scheduling turn_on do a last-minute check if lights are off (#671)
* Before scheduling turn_on do a last-minute check if lights are off

* Pass force

* add comment

* fix for proactive

* commetn

* No default for force

* rm newline

* no force

* Return bool
2023-08-02 23:11:45 -07:00
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