mirror of
https://github.com/basnijholt/adaptive-lighting.git
synced 2026-09-12 14:54:04 +02:00
* 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> |
||
|---|---|---|
| .. | ||
| adaptive_lighting | ||