Use light.adjust for active light groups#1
Conversation
|
@codex review этого кода, учитывая что в HA эта тема щепетильная и меня будут терроризировать на точность, аккуратность, лишность и тд. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: af5c4d54c9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex rereview all other code until you find everything. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: af5c4d54c9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review new fix |
|
Codex Review: Didn't find any major issues. You're on a roll. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 45e9d78a47
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return memberIds.some((entityId) => hass.states[entityId]?.state === "on") | ||
| ? "adjust" | ||
| : "turn_on"; |
There was a problem hiding this comment.
Recurse into nested light groups before falling back
The new direct-member check still misses partially-on nested light groups: if a group contains another all: true light group whose own aggregate state is off while one of its child lights is on, none of the immediate memberIds are on, so this returns turn_on and the subsequent brightness/color adjustment wakes the off grandchildren. This leaves the same “partial group turns on everything” regression for users who organize light groups hierarchically; the active-member test needs to expand member groups recursively or otherwise defer the decision to the backend adjust semantics.
Useful? React with 👍 / 👎.
Summary
Updates HA light group UI controls to call
light.adjustfor attribute-only changes when interacting with active Home Assistant light groups.This keeps current behavior for off targets:
light.adjustlight.turn_onlight.turn_onsemanticsThis PR is paired with the backend implementation in core:
The user-facing rationale and proposal shape were described in the recent architecture discussion comment:
Why
The more-info and Lovelace light controls currently express a user intent closer to "adjust the lights that are already active in this group" than "turn on every light in the group".
Without a more precise backend action, sliders and color controls on partially-on groups end up waking lights that are off. This PR switches those group-only attribute controls to the new
light.adjustaction, which matches the intended semantics.What Changed
computeLightAttributeServicehelper insrc/data/light.tslight.adjustfor Home Assistant light groups that exposeattributes.entity_idlight.turn_onbehavior for off/all-off groups and non-group lightsEdge Cases Resolved
light.turn_onsemantics so power-on UX remains unchangedall: truegroup flows are aligned with the backend adjust semantics and current active-member selectionRelation To Core
This frontend change depends on the new
light.adjustservice/action from the companion core PR. The two PRs are intentionally linked and should be reviewed together.The backend/core PR defines the semantics:
Testing
test/data/light.test.tsReferences