Skip to content

Commit

Permalink
fix: Prevent IKEA PARASOLL and BADRING being stuck on a previously re…
Browse files Browse the repository at this point in the history
…ported state after it rapidly changes back and forth. (#8174)
  • Loading branch information
marazmarci authored Oct 26, 2024
1 parent 5ff3e9f commit 94e554b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
17 changes: 14 additions & 3 deletions src/devices/ikea.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {Zcl} from 'zigbee-herdsman';

import {repInterval} from '../lib/constants';
import {
addCustomClusterManuSpecificIkeaAirPurifier,
addCustomClusterManuSpecificIkeaUnknown,
Expand Down Expand Up @@ -608,7 +609,7 @@ const definitions: DefinitionWithExtend[] = [
// Enable reporting of powerDivisor, needs to change dynamically with the amount of power
// For details, see: https://github.com/Koenkk/zigbee2mqtt/issues/23961#issuecomment-2366733453
await endpoint.configureReporting('haElectricalMeasurement', [
{attribute: 'acPowerDivisor', minimumReportInterval: 10, maximumReportInterval: 65000, reportableChange: 1},
{attribute: 'acPowerDivisor', minimumReportInterval: 10, maximumReportInterval: repInterval.MAX, reportableChange: 1},
]);
},
},
Expand Down Expand Up @@ -926,7 +927,12 @@ const definitions: DefinitionWithExtend[] = [
addCustomClusterManuSpecificIkeaUnknown(),
deviceEndpoints({endpoints: {'1': 1, '2': 2}}),
bindCluster({cluster: 'ssIasZone', clusterType: 'input', endpointNames: ['2']}),
iasZoneAlarm({zoneType: 'contact', zoneAttributes: ['alarm_1']}),
iasZoneAlarm({
zoneType: 'contact',
zoneAttributes: ['alarm_1'],
// This is required to prevent the device's reported state being stuck after it quickly changed back and forth:
zoneStatusReporting: true,
}),
identify({isSleepy: true}),
battery(),
ikeaOta(),
Expand All @@ -940,7 +946,12 @@ const definitions: DefinitionWithExtend[] = [
extend: [
addCustomClusterManuSpecificIkeaUnknown(),
bindCluster({cluster: 'ssIasZone', clusterType: 'input'}),
iasZoneAlarm({zoneType: 'water_leak', zoneAttributes: ['alarm_1']}),
iasZoneAlarm({
zoneType: 'water_leak',
zoneAttributes: ['alarm_1'],
// This is required to prevent the device's reported state being stuck after it quickly changed back and forth:
zoneStatusReporting: true,
}),
identify({isSleepy: true}),
battery(),
ikeaOta(),
Expand Down
12 changes: 11 additions & 1 deletion src/lib/modernExtend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,7 @@ export interface IasArgs {
zoneType: iasZoneType;
zoneAttributes: iasZoneAttribute[];
alarmTimeout?: boolean;
zoneStatusReporting?: boolean;
description?: string;
}
export function iasZoneAlarm(args: IasArgs): ModernExtend {
Expand Down Expand Up @@ -1561,7 +1562,16 @@ export function iasZoneAlarm(args: IasArgs): ModernExtend {
},
];

return {fromZigbee, exposes, isModernExtend: true};
let configure: Configure[];
if (args.zoneStatusReporting) {
configure = [
async (device, coordinatorEndpoint) => {
await setupAttributes(device, coordinatorEndpoint, 'ssIasZone', [{attribute: 'zoneStatus', min: 'MIN', max: 'MAX', change: 0}]);
},
];
}

return {fromZigbee, exposes, isModernExtend: true, ...(configure && {configure})};
}

export interface IasWarningArgs {
Expand Down

0 comments on commit 94e554b

Please sign in to comment.