Skip to content

Commit

Permalink
fix: Fix group state change for open/close devices (#24226)
Browse files Browse the repository at this point in the history
* Fix group state change if OPEN

* Runned Prettier
  • Loading branch information
Trexano99 authored Oct 6, 2024
1 parent 5c3f712 commit 076ada2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions lib/extension/groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,17 +228,22 @@ export default class Groups extends Extension {
}

private shouldPublishPayloadForGroup(group: Group, payload: KeyValue): boolean {
return group.options.off_state === 'last_member_state' || !payload || payload.state !== 'OFF' || this.areAllMembersOff(group);
return (
group.options.off_state === 'last_member_state' ||
!payload ||
(payload.state !== 'OFF' && payload.state !== 'CLOSE') ||
this.areAllMembersOffOrClosed(group)
);
}

private areAllMembersOff(group: Group): boolean {
private areAllMembersOffOrClosed(group: Group): boolean {
for (const member of group.zh.members) {
const device = this.zigbee.resolveEntity(member.getDevice())!;

if (this.state.exists(device)) {
const state = this.state.get(device);

if (state.state === 'ON') {
if (state.state === 'ON' || state.state === 'OPEN') {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/util/settings.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@
"title": "Group off state",
"default": "auto",
"requiresRestart": true,
"description": "Control when to publish state OFF for a group. 'all_members_off': only publish state OFF when all group members are in state OFF, 'last_member_state': publish state OFF whenever one of its members changes to OFF"
"description": "Control when to publish state OFF or CLOSE for a group. 'all_members_off': only publish state OFF/CLOSE when all group members are in state OFF/CLOSE, 'last_member_state': publish state OFF whenever one of its members changes to OFF"
},
"filtered_attributes": {
"type": "array",
Expand Down

0 comments on commit 076ada2

Please sign in to comment.