Commit graph

1,151 commits

Author SHA1 Message Date
allcontributors[bot]
00185e75e0
docs: add 00schteven as a contributor for ideas (#1555)
* docs: update README.md

* docs: update .all-contributorsrc

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2026-09-06 12:54:51 +02:00
allcontributors[bot]
6254b56dab
docs: add b-rad15 as a contributor for ideas (#1554)
* docs: update README.md

* docs: update .all-contributorsrc

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2026-09-06 12:54:18 +02:00
allcontributors[bot]
f97e502cbc
docs: add jrbergen as a contributor for ideas (#1553)
* docs: update README.md

* docs: update .all-contributorsrc

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2026-09-06 12:53:46 +02:00
allcontributors[bot]
17b0aa1103
docs: add GollyJer as a contributor for ideas (#1552)
* docs: update README.md

* docs: update .all-contributorsrc

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2026-09-06 12:53:12 +02:00
allcontributors[bot]
8fb22adc45
docs: add BenoitAnastay as a contributor for ideas (#1551)
* docs: update README.md

* docs: update .all-contributorsrc

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2026-09-06 12:52:39 +02:00
allcontributors[bot]
dda664ac7e
docs: add djurny as a contributor for ideas (#1550)
* docs: update README.md

* docs: update .all-contributorsrc

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2026-09-06 12:52:07 +02:00
allcontributors[bot]
6fdbffc7fc
docs: add haasn as a contributor for ideas (#1549)
* docs: update README.md

* docs: update .all-contributorsrc

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2026-09-06 12:51:34 +02:00
allcontributors[bot]
1969a8cdff
docs: add mrbillpapas as a contributor for ideas (#1548)
* docs: update README.md

* docs: update .all-contributorsrc

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2026-09-06 12:50:53 +02:00
allcontributors[bot]
288d9d344a
docs: add rhtenhove as a contributor for code (#1547)
* docs: update README.md

* docs: update .all-contributorsrc

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2026-09-06 12:37:02 +02:00
rhtenhove
722779d59b
Allow opting out of manual-control reset on sleep changes (#1063)
* Disable manual control reset on sleep mode change

* adapt test to new behavior

* fix comment

* add switch + test

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

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

* Update auto-generated content

* fix: preserve existing sleep-toggle reset defaults

* fix: keep cancelling stale adaptations on sleep changes

---------

Co-authored-by: Bas Nijholt <basnijholt@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Bas Nijholt <bas@nijho.lt>
2026-09-06 12:35:45 +02:00
Bas Nijholt
ecf2403422
fix: publish manual-control state when it changes (#1538) 2026-09-06 12:32:40 +02:00
Bas Nijholt
a04a533f45
ci: support one year of Home Assistant releases (#1546) 2026-09-06 12:17:22 +02:00
allcontributors[bot]
0003655828
docs: add chewth91 as a contributor for bug (#1545)
* docs: update README.md

* docs: update .all-contributorsrc

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2026-09-06 11:59:17 +02:00
allcontributors[bot]
508959fff3
docs: add bisquit2003 as a contributor for bug (#1544)
* docs: update README.md

* docs: update .all-contributorsrc

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2026-09-06 11:58:24 +02:00
Bas Nijholt
d6ddd3f27e
docs: credit Weblate-only translators (#1543) 2026-09-06 11:52:39 +02:00
allcontributors[bot]
95ccc02789
docs: add sergeybelozorov as a contributor for translation (#1542)
* docs: update README.md

* docs: update .all-contributorsrc

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2026-09-06 11:49:57 +02:00
allcontributors[bot]
8056fcc5f8
docs: add rutgerkra as a contributor for translation (#1541)
* docs: update README.md

* docs: update .all-contributorsrc

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2026-09-06 11:49:26 +02:00
allcontributors[bot]
3df5787019
docs: add LukTyn as a contributor for translation (#1540)
* docs: update README.md

* docs: update .all-contributorsrc

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2026-09-06 11:48:49 +02:00
allcontributors[bot]
397b50d492
docs: add belkin as a contributor for translation (#1539)
* docs: update README.md

* docs: update .all-contributorsrc

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2026-09-06 11:48:19 +02:00
Bas Nijholt
72128f07ae
Restore missing Russian option labels (#1534)
* feat: restore missing Russian option labels

Restore the translated option labels from PR #1277 that are still absent on current main. Existing Russian values and stale descriptions remain untouched.

Co-authored-by: belozorov_sv <belozorov_sv@magnit.ru>

* fix: drop ambiguous Russian brightness timing labels

---------

Co-authored-by: belozorov_sv <belozorov_sv@magnit.ru>
2026-09-06 11:46:49 +02:00
Bas Nijholt
4973f79c3a
Restore missing Weblate translations (#1533)
* feat: restore missing Weblate translations

Import only translated keys absent from current main whose English source is unchanged. Existing locale values and stale hard-coded URL descriptions remain untouched.

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: NataN <natan.ns.ns@gmail.com>
Co-authored-by: Allan Himidi-Rattenborg <allanrlang@gmail.com>
Co-authored-by: Hans Henrik Juhl <hans@kopula.dk>
Co-authored-by: Belkin Fahri <belkinfahri@gmail.com>
Co-authored-by: Максим Горпиніч <gorpinicmaksim0@gmail.com>
Co-authored-by: Enric Pagès i Gassull <enricpages@hotmail.com>
Co-authored-by: Lukas Tynovsky <LukTyn@gmail.com>
Co-authored-by: Rutger <r.kraaijer@gmail.com>
Co-authored-by: Yllelder <yllelder@gmail.com>
Co-authored-by: Hosted Weblate user 144010 <jf.cosse@users.noreply.hosted.weblate.org>
Co-authored-by: Loïc R <loicdu81@gmail.com>
Co-authored-by: Maxime Bailleul <mexx.bailleul@gmail.com>
Co-authored-by: Pose marto <weblate.drainage895@passmail.net>
Co-authored-by: Esspel <eric.soderstrom06@gmail.com>
Co-authored-by: Max <max.bengtzen@icloud.com>

* fix: omit inaccurate restored translations

Drop the imported strings flagged by review for semantic omissions or visible translation errors. English fallback remains available for these keys.

* fix: drop unclear Brazilian Portuguese imports

---------

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: NataN <natan.ns.ns@gmail.com>
Co-authored-by: Allan Himidi-Rattenborg <allanrlang@gmail.com>
Co-authored-by: Hans Henrik Juhl <hans@kopula.dk>
Co-authored-by: Belkin Fahri <belkinfahri@gmail.com>
Co-authored-by: Максим Горпиніч <gorpinicmaksim0@gmail.com>
Co-authored-by: Enric Pagès i Gassull <enricpages@hotmail.com>
Co-authored-by: Lukas Tynovsky <LukTyn@gmail.com>
Co-authored-by: Rutger <r.kraaijer@gmail.com>
Co-authored-by: Yllelder <yllelder@gmail.com>
Co-authored-by: Hosted Weblate user 144010 <jf.cosse@users.noreply.hosted.weblate.org>
Co-authored-by: Loïc R <loicdu81@gmail.com>
Co-authored-by: Maxime Bailleul <mexx.bailleul@gmail.com>
Co-authored-by: Pose marto <weblate.drainage895@passmail.net>
Co-authored-by: Esspel <eric.soderstrom06@gmail.com>
Co-authored-by: Max <max.bengtzen@icloud.com>
2026-09-06 11:46:44 +02:00
Bas Nijholt
187185698e
Add test_expand_light_groups (#319)
* Add test_expand_light_groups

* Add imports

* import

---------

Co-authored-by: Benjamin Auquite <halomastar@gmail.com>
2026-09-06 11:42:55 +02:00
pre-commit-ci[bot]
4c1140c517
[pre-commit.ci] pre-commit autoupdate (#1229)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/pre-commit/pre-commit-hooks: v5.0.0 → v6.0.0](https://github.com/pre-commit/pre-commit-hooks/compare/v5.0.0...v6.0.0)
- [github.com/astral-sh/ruff-pre-commit: v0.11.13 → v0.16.5](https://github.com/astral-sh/ruff-pre-commit/compare/v0.11.13...v0.16.5)
- https://github.com/psf/blackhttps://github.com/psf/black-pre-commit-mirror
- [github.com/psf/black-pre-commit-mirror: 25.1.0 → 26.5.1](https://github.com/psf/black-pre-commit-mirror/compare/25.1.0...26.5.1)

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

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

* ci: preserve Ruff lint baseline

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Bas Nijholt <bas@nijho.lt>
2026-09-06 11:38:40 +02:00
Bas Nijholt
6b7dbc3a66
Add Lonsonho ZB-RGBCW to troubleshooting (#756)
* Add Lonsonho ZB-RGBCW to troubleshooting

* add link
2026-09-06 11:36:51 +02:00
allcontributors[bot]
92c071f4f3
docs: add frankysan as a contributor for translation (#1537)
* docs: update README.md

* docs: update .all-contributorsrc

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2026-09-06 11:36:23 +02:00
allcontributors[bot]
179cb2ef30
docs: add MSL-DA as a contributor for translation (#1536)
* docs: update README.md

* docs: update .all-contributorsrc

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2026-09-06 11:35:48 +02:00
frankysan
cd1e653da5
Minor update to Swedish translation (#1412)
Removed a superfluous "Swedish: " from the description of the manual control option.

Co-authored-by: Bas Nijholt <basnijholt@users.noreply.github.com>
Co-authored-by: Bas Nijholt <bas@nijho.lt>
2026-09-06 11:35:11 +02:00
Jan
c9d9c75b14
Enhance Danish translation description for adaptive lighting (#1488)
* Enhance Danish translation description for adaptive lighting

Updated the description in the Danish translation for adaptive lighting settings to include documentation and webapp URLs.

* Update custom_components/adaptive_lighting/translations/da.json

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: Bas Nijholt <bas@nijho.lt>
2026-09-06 11:35:07 +02:00
Adam DeMuri
4b0638a4d8
Only run the validate_hacs CI action on the upstream repo. (#1423)
This avoids running this action on forks, since they likely won't have
issues or topics enabled, and shouldn't need them.

Co-authored-by: Bas Nijholt <basnijholt@users.noreply.github.com>
Co-authored-by: Bas Nijholt <bas@nijho.lt>
2026-09-06 11:35:02 +02:00
renovate[bot]
548e5048ec
⬆️ Pin dependencies (#1475)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-09-06 11:34:59 +02:00
Bas Nijholt
28f0fe8c58
test: keep split-command brightness checks deterministic (#1532) 2026-09-06 10:58:20 +02:00
Bas Nijholt
fdce4c9102
fix: keep adaptation updates from restarting manual-control timers (#1525)
* Fix autoreset timeout during partial adaptation

* Test manual timeout renewal for mixed light requests
2026-09-06 10:45:08 +02:00
Marijn Eken
8f78233e11
docs: clarify that UI setup needs no YAML entry (#1031)
* Fixed outdated info in README.md

The README says to always add an adaptive_lighting: entry in the YAML, where this seems to be no longer needed (or even preferred).

* docs: clarify YAML is optional for UI setup

---------

Co-authored-by: Bas Nijholt <basnijholt@users.noreply.github.com>
Co-authored-by: Bas Nijholt <bas@nijho.lt>
2026-09-06 10:43:37 +02:00
allcontributors[bot]
edc8f70996
docs: add davidgeiger as a contributor for bug (#1529)
* docs: update README.md

* docs: update .all-contributorsrc

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Bas Nijholt <bas@nijho.lt>
2026-09-06 10:38:49 +02:00
allcontributors[bot]
ee12752927
docs: add callistoprime as a contributor for bug (#1528)
* docs: update README.md

* docs: update .all-contributorsrc

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Bas Nijholt <bas@nijho.lt>
2026-09-06 10:37:50 +02:00
allcontributors[bot]
66e6d5ff5f
docs: add kasiom as a contributor for translation (#1527)
* docs: update README.md

* docs: update .all-contributorsrc

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Bas Nijholt <bas@nijho.lt>
2026-09-06 10:36:25 +02:00
Bas Nijholt
efa64d01be
fix: allow negative service offsets (#1524) 2026-09-06 10:35:35 +02:00
Bas Nijholt
17d9b39700
fix: restore Czech options placeholders (#1523) 2026-09-06 10:35:30 +02:00
allcontributors[bot]
c03a19c5a3
docs: add marijneken as a contributor for doc (#1526)
* docs: update README.md

* docs: update .all-contributorsrc

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2026-09-06 10:34:44 +02:00
Bas Nijholt
c7339678a6
ci: check out the workflow commit during test setup (#1522) 2026-09-06 10:32:01 +02:00
proscar87
a2186ecf22
perf: stagger periodic adaptation updates (#1500)
Spread recurring updates with a deterministic per-switch offset while keeping turn-on adaptation immediate. Register the delayed listener on Home Assistant's event loop and cover cancellation, reconfiguration, and cadence with real timer tests.

Closes #939.

Co-authored-by: Bas Nijholt <basnijholt@gmail.com>
2026-09-06 01:12:28 -07:00
mueslo
68c0e4db69
fix: preserve Home Assistant area target exclusions (#1511)
* Exclude 'service' lights (entity_category) from area intercept turn-on

Fixes #1510

When Adaptive Lighting intercepts an area/label-targeted light.turn_on, the
intercept rewrites the call to target only the managed lights (see
modify_service_data), so Home Assistant's own handler turns on only those.
AL then re-issues light.turn_on for the remaining 'skipped' (unmanaged)
entities so they still come on.

The problem: HA excludes entities with an entity_category (config/diagnostic,
e.g. the Home Assistant Voice LED ring) from area/label expansion, but AL's
re-issue did not, so AL was the sole thing turning these service lights on.

Changes:
- Keep re-issuing skipped lights so unmanaged normal lights still come on,
  but filter out 'service' lights (entity_category set) from that re-issue.
- Add _is_service_light helper (registry-based) and divert a *managed*
  service light to 'skipped' in _separate_entity_ids, so it is excluded from
  the intercept turn-on while still being adapted when on.

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

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

* Add toggle regression test for service light exclusion from area intercept

Mirrors test_service_light_excluded_from_area_intercept_turn_on but uses
light.toggle: a service light (entity_category set) in an area must remain
off when AL intercepts an area toggle. The managed lights still toggle on.

Refs #1510, PR #1511.

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

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

* Only exclude service lights from indirect (area/device/label) expansion

Previously _is_service_light filtered service lights unconditionally, which
also excluded a service light explicitly named in `entity_id`. Home
Assistant only excludes such lights from indirect area/device/label expansion
and turns them on when directly targeted, so AL must mirror that: service
lights are now excluded from the intercept/re-issue only when not directly
targeted (`direct_entity_ids`).

Adds a regression test for the direct-target case.

Refs #1510, PR #1511.

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

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

* Use if/elif/else for indirect service-light exclusion; inline check

Address review: collapse the two separate `if is_service`/"if not
is_service" into an `if/elif/else` chain (ruff PLR5501) and inline the
service check as `self._is_service_light(...) and entity_id not in
direct_entity_ids`, which conceptually is `is_indirect_service`.
Matches HA's indirect-only exclusion and keeps the flow simple.

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

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

* Filter service lights directly in _get_entity_list expansion

Move service-light filtering to the single expansion site
AdaptiveLightingManager._get_entity_list. Area/device expansion is the
only place where HA excludes entity_category lights, so filtering there
mirrors HA and makes the later direct_entity_ids / skipped_normal guards
unnecessary. Explicit entity_id targets bypass expansion and therefore
still turn on service lights, matching HA.

Fully reverts the direct_entity_ids / skipped_normal addition per review.

---------

Co-authored-by: mueslo <mueslo@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Bas Nijholt <basnijholt@gmail.com>
2026-09-06 01:04:50 -07:00
Jared Jensen
e453541a78
feat: expose per-attribute manual-control state (#1469)
Adds two new read-only state attributes on the AdaptiveSwitch entity:

- manual_control_brightness: list of light entity_ids whose brightness
  axis is currently in manual override (i.e. AL is paused for brightness
  on those lights).
- manual_control_color: same, for the color axis.

These mirror the existing 'manual_control' attribute (which is a
union of both axes) but expose the LightControlAttributes bitfield
that AL already tracks internally per-light.

Why: the existing 'manual_control' state attribute and the
adaptive_lighting.manual_control event are useful, but neither lets
a template or dashboard see which axis is paused without subscribing
to events. This is especially important with take_over_control_mode:
pause_changed, where one axis can be manual while the other still
adapts. Now a Lovelace card or template sensor can display
brightness/color manual state directly via state_attr().

Test: extends test_manual_control to assert the new attributes
reflect the bitfield correctly.

No new platform, no breaking changes.

Co-authored-by: Bas Nijholt <basnijholt@gmail.com>
2026-09-06 00:59:38 -07:00
allcontributors[bot]
61896eb86a
docs: credit mueslo for code contributions (#1521)
* docs: update README.md

* docs: update .all-contributorsrc

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2026-09-06 00:55:27 -07:00
allcontributors[bot]
9b0f03045b
docs: credit jaredjxyz for code contributions (#1520)
* docs: update README.md

* docs: update .all-contributorsrc

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2026-09-06 00:54:58 -07:00
Bas Nijholt
cc99067c73
fix: keep adapting during polar night and midnight sun (#1489)
Handle missing polar sunrise and sunset with a shared fallback. Bound offsets between actual solar anchors while preserving the daily lighting cycle and configured time behavior.

Co-authored-by: Oscar Pacheco <oscar@gigadefense.com.mx>
2026-09-06 00:23:21 -07:00
proscar87
55f871fd0c
Adopt has_entity_name to fix duplicated entity ids on HA 2026.4+ (#1499)
* Adopt has_entity_name to fix duplicated entity ids on HA 2026.4+

Since HA core 2026.4 (PR 166246) composes entity names as device name +
entity name, and only strips the device prefix when the entity name
starts with it. Adaptive Lighting's names ('Adaptive Lighting Sleep
Mode: stairs' on device 'Adaptive Lighting: stairs') never match, so
new installs get ids like
switch.adaptive_lighting_stairs_adaptive_lighting_sleep_mode_stairs.

Adopt has_entity_name: the main switch takes the device name
('Adaptive Lighting: <name>'), the simple switches use their role
('Sleep Mode', 'Adapt Brightness', 'Adapt Color'). Unique ids are
unchanged, so existing installs keep their entity ids via the registry.

Fixes #1459

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Test the new entity ids and that existing ones survive

The renamed constants were defined but never asserted, so neither the
fresh-install ids nor the registry-preservation claim were covered.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* test: keep the apply-service test light on

Avoid generating brightness zero in the attribute-change helper, which turns the light off and makes the test depend on the current adaptive brightness.

---------

Co-authored-by: proscar87 <proscar87@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Bas Nijholt <bas@nijho.lt>
Co-authored-by: Bas Nijholt <basnijholt@gmail.com>
2026-09-06 09:18:49 +02:00
proscar87
67d4a2f657
fix: clamp() collapsed to minimum when min_brightness > max_brightness (#1507)
* fix: clamp() collapsed to minimum when min_brightness > max_brightness

A user can intentionally set min_brightness > max_brightness (or the
equivalent for color temperature) for an inverted timescale -- e.g. a
porch light that should be brighter at night than during the day.
clamp()'s max(minimum, min(value, maximum)) assumed minimum <= maximum;
when inverted, min(value, maximum) is always <= maximum < minimum, so
max(minimum, ...) always returns minimum. linear and tanh brightness
modes -- both of which end in a clamp(brightness, min_brightness,
max_brightness) call -- got stuck returning one fixed value regardless
of the time of day.

Fixes #1421

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

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

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

* test: accept current Home Assistant brightness validation errors

Keep asserting the maximum brightness limit without depending on the validation library's dictionary-path wording.

---------

Co-authored-by: Oscar Pacheco <proscar@MacBook-Pro-de-Oscar.local>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Bas Nijholt <bas@nijho.lt>
Co-authored-by: Bas Nijholt <basnijholt@gmail.com>
2026-09-06 00:10:21 -07:00
Dennis Dekker
c620d1480a
fix: re-adapt lights right after the auto-reset timer fires (#1506)
When the auto-reset timer fired, its callback called manager.reset(),
which pops the timer and calls timer.cancel() - cancelling the very task
that was running the callback. The manual_control flag was cleared, but
the re-adaptation that should follow was silently cancelled, so the light
only changed on the next interval pass (with the normal transition).

_AsyncSingleShotTimer.cancel() now never cancels the task that is
currently running its own callback. The trailing assert in the callback
is removed because it is reachable now and could trip when a new manual
change comes in while the re-adaptation is still running. The existing
auto-reset test also checks that a light.turn_on with the 'autoreset'
context is sent.

Fixes #1233

Co-authored-by: Dennis-Dekker <>
Co-authored-by: Bas Nijholt <bas@nijho.lt>
2026-09-06 07:01:50 +00:00
Samson Brock
68c66a0ff3
Fix options flow changes silently discarded for pre-refactor UI entries (#1504)
* Fix options flow changes being silently discarded for UI-configured entries

validate() merges config_entry.options then config_entry.data, on the
assumption that data only ever holds YAML-imported settings (which should
win) or, for UI-created entries, just the entry name (harmless to apply
last).

That assumption doesn't hold for entries created before data/options were
split: their data still carries the full settings snapshot from initial
setup. Applying it after options means any change made through the options
flow for a key that already exists in data (e.g. adding a light) is
silently ignored, even though the options flow reports success and the
entry reloads without error.

Reproduced on a real entry: added a light via the options flow, entry
reloaded cleanly, but the light was never picked up by the switch's
service-call interceptor ("No switch found for entity_id=...") because
data still held the old light list and clobbered the updated options.

Fix: only let data win over options for genuinely YAML-imported entries
(config_entry.source == SOURCE_IMPORT), matching the existing use of that
check elsewhere in this file. For UI-configured entries, apply options
last so changes made through the options flow actually take effect.

* Add focused tests for the data/options merge order in validate()

Covers both source-specific contracts the merge logic relies on, per
review feedback on this PR:

- SOURCE_USER: options must win over data (this PR's actual fix - proven
  to fail against the pre-fix code, verified locally by reverting
  switch.py and re-running).
- SOURCE_IMPORT: data must keep winning over options (the existing,
  intentional YAML-precedence behavior - unchanged by this PR, verified
  to already pass against the pre-fix code too).

Verified against a real Home Assistant instance's test harness
(pytest-homeassistant-custom-component + the actual installed
homeassistant package), not just reasoned about statically.

---------

Co-authored-by: Bas Nijholt <bas@nijho.lt>
2026-09-06 00:00:02 -07:00