Skip to content

Commit

Permalink
feat: Improvement to W599001 Smoke Alarm (#8393)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattbyte authored Dec 3, 2024
1 parent 286d454 commit 098daba
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 25 deletions.
52 changes: 27 additions & 25 deletions src/devices/schneider_electric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
deviceEndpoints,
electricityMeter,
enumLookup,
iasZoneAlarm,
identify,
illuminance,
light,
Expand All @@ -21,6 +22,7 @@ import {
onOff,
ScaleFunction,
setupConfigureForReading,
temperature,
} from '../lib/modernExtend';
import * as reporting from '../lib/reporting';
import {DefinitionWithExtend, Fz, KeyValue, ModernExtend, Tz} from '../lib/types';
Expand Down Expand Up @@ -1725,32 +1727,32 @@ const definitions: DefinitionWithExtend[] = [
model: 'W599001',
vendor: 'Schneider Electric',
description: 'Wiser smoke alarm',
fromZigbee: [fz.temperature, fz.battery, fz.ias_enroll, fz.ias_smoke_alarm_1],
toZigbee: [],
ota: true, // local OTA updates are untested
exposes: [
e.smoke(),
e.test(),
e.battery_low(),
e.tamper(),
e.battery(),
e.battery_voltage(),
// the temperature readings are unreliable and may need more investigation.
e.temperature(),
extend: [
battery({voltage: true, voltageReporting: true}),
temperature(),
iasZoneAlarm({
zoneType: 'smoke',
zoneAttributes: ['alarm_1', 'tamper', 'battery_low', 'test'],
zoneStatusReporting: true,
manufacturerZoneAttributes: [
{
bit: 1,
name: 'heat',
valueOn: true,
valueOff: false,
description: 'Indicates whether the device has detected high temperature',
},
{
bit: 11,
name: 'hush',
valueOn: true,
valueOff: false,
description: 'Indicates whether the device is in hush mode',
entityCategory: 'diagnostic',
},
],
}),
],
configure: async (device, coordinatorEndpoint) => {
const endpoint = device.getEndpoint(20);
const binds = ['msTemperatureMeasurement', 'ssIasZone', 'genPowerCfg'];
await reporting.bind(endpoint, coordinatorEndpoint, binds);
await reporting.batteryPercentageRemaining(endpoint);
await reporting.batteryVoltage(endpoint);
await reporting.temperature(endpoint);
await endpoint.read('msTemperatureMeasurement', ['measuredValue']);
await endpoint.read('ssIasZone', ['iasCieAddr', 'zoneState', 'zoneStatus', 'zoneId']);
await endpoint.read('genPowerCfg', ['batteryVoltage', 'batteryPercentageRemaining']);
device.powerSource = 'Mains (single phase)';
device.save();
},
whiteLabel: [
{vendor: 'Schneider Electric', model: 'W599501', description: 'Wiser smoke alarm', fingerprint: [{modelID: 'W599501'}]},
{vendor: 'Schneider Electric', model: '755WSA', description: 'Clipsal Wiser smoke alarm', fingerprint: [{modelID: '755WSA'}]},
Expand Down
22 changes: 22 additions & 0 deletions src/lib/modernExtend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1403,12 +1403,21 @@ export type iasZoneAttribute =
| 'test'
| 'trouble'
| 'battery_defect';
export type manufacturerZoneAttribute = {
bit: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15;
name: string;
valueOn: string | boolean;
valueOff: string | boolean;
description: string;
entityCategory?: 'config' | 'diagnostic';
};
export interface IasArgs {
zoneType: iasZoneType;
zoneAttributes: iasZoneAttribute[];
alarmTimeout?: boolean;
zoneStatusReporting?: boolean;
description?: string;
manufacturerZoneAttributes?: manufacturerZoneAttribute[];
}
export function iasZoneAlarm(args: IasArgs): ModernExtend {
const exposes: Expose[] = [];
Expand Down Expand Up @@ -1450,6 +1459,13 @@ export function iasZoneAlarm(args: IasArgs): ModernExtend {
});
}

if (args.manufacturerZoneAttributes)
args.manufacturerZoneAttributes.map((attr) => {
let expose = e.binary(attr.name, ea.STATE, attr.valueOn, attr.valueOff).withDescription(attr.description);
if (attr.entityCategory) expose = expose.withCategory(attr.entityCategory);
exposes.push(expose);
});

const timeoutProperty = `${args.zoneType}_timeout`;

const fromZigbee: Fz.Converter[] = [
Expand Down Expand Up @@ -1500,6 +1516,7 @@ export function iasZoneAlarm(args: IasArgs): ModernExtend {
if (args.zoneAttributes.includes('battery_defect')) {
payload = {battery_defect: (zoneStatus & (1 << 9)) > 0, ...payload};
}

let alarm1Payload = (zoneStatus & 1) > 0;
let alarm2Payload = (zoneStatus & (1 << 1)) > 0;

Expand All @@ -1517,6 +1534,11 @@ export function iasZoneAlarm(args: IasArgs): ModernExtend {
payload = {[alarm2Name]: alarm2Payload, ...payload};
}

if (args.manufacturerZoneAttributes)
args.manufacturerZoneAttributes.map((attr) => {
payload = {[attr.name]: (zoneStatus & (1 << attr.bit)) > 0, ...payload};
});

return payload;
}
},
Expand Down

0 comments on commit 098daba

Please sign in to comment.