Skip to content

Commit 8ea3db6

Browse files
committed
fix: delete scenes on endpoint removal from group
1 parent 74c1a35 commit 8ea3db6

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/controller/model/endpoint.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,24 +1202,31 @@ export class Endpoint extends ZigbeeEntity {
12021202
* to zigbee-herdsman.
12031203
*/
12041204
public async removeFromGroup(group: Group | number): Promise<void> {
1205-
await this.zclCommand(
1206-
"genGroups",
1207-
"remove",
1208-
{groupid: group instanceof Group ? group.groupID : group},
1209-
undefined,
1210-
undefined,
1211-
true,
1212-
Zcl.FrameType.SPECIFIC,
1213-
);
1205+
const groupId = group instanceof Group ? group.groupID : group;
1206+
await this.zclCommand("genGroups", "remove", {groupid: groupId}, undefined, undefined, true, Zcl.FrameType.SPECIFIC);
12141207

12151208
if (group instanceof Group) {
12161209
group.removeMember(this);
12171210
}
1211+
1212+
// per spec, remove associated scenes
1213+
for (const [key] of this.scenes) {
1214+
if (key.endsWith(`_${groupId}`)) {
1215+
this.scenes.delete(key);
1216+
}
1217+
}
12181218
}
12191219

12201220
public async removeFromAllGroups(): Promise<void> {
12211221
await this.zclCommand("genGroups", "removeAll", {}, {disableDefaultResponse: true}, undefined, false, Zcl.FrameType.SPECIFIC);
12221222
this.removeFromAllGroupsDatabase();
1223+
1224+
// per spec, remove all scenes associated with a group
1225+
for (const [key] of this.scenes) {
1226+
if (!key.endsWith("_0")) {
1227+
this.scenes.delete(key);
1228+
}
1229+
}
12231230
}
12241231

12251232
public removeFromAllGroupsDatabase(): void {

0 commit comments

Comments
 (0)