Skip to content

Commit

Permalink
fix: Improvements for Bosch 8750001213 Twinguard (#7383)
Browse files Browse the repository at this point in the history
* fix: Minor corrections

* fix: Restore basic functionality for BWA-1

* fix: Format converters

* fix: Lint, be happy

* fix: Lint, remove currently unused code

* fix: Minor changes to exposes & bindings

* fix: Reintroduce `alarm_on_motion`

* fix: Use tzLocal & fzLocal

* fix: Minor typo

Where did that ! come from???

* fix: Improve `configure` for BSD-2 & BWA-1

* fix: Update required bindings & `configure`

* fix: Lint, it's fine

* hotfix: Always bind `ssIasZone` to BWA-1

* hotfix: Remove `manufacturerOptions` from BSD-2

No `manufacturerOptions` used by BSD-2 when interacting with the `ssIasZone` cluster.

* fix: Tweak `configure` step for BWA-1

* hotfix: Use correct `write` payload format

* fix: Use cluster/attribute names instead of IDs
  • Loading branch information
burmistrzak committed Apr 11, 2024
1 parent 7727e11 commit 06458b1
Showing 1 changed file with 16 additions and 24 deletions.
40 changes: 16 additions & 24 deletions src/devices/bosch.ts
Expand Up @@ -552,18 +552,18 @@ const tzLocal = {
convertSet: async (entity, key, value, meta) => {
if (key === 'sensitivity') {
const index = utils.getFromLookup(value, smokeSensitivity);
await entity.write('manuSpecificBosch', {0x4003: {value: index, type: 0x21}}, manufacturerOptions);
await entity.write('manuSpecificBosch', {sensitivity: index}, manufacturerOptions);
return {state: {sensitivity: value}};
}
if (key === 'pre_alarm') {
const index = utils.getFromLookup(value, stateOffOn);
await entity.write('manuSpecificBosch5', {0x4001: {value: index, type: 0x18}}, manufacturerOptions);
await entity.write('manuSpecificBosch5', {pre_alarm: index}, manufacturerOptions);
return {state: {pre_alarm: value}};
}
if (key === 'heartbeat') {
const endpoint = meta.device.getEndpoint(12);
const index = utils.getFromLookup(value, stateOffOn);
await endpoint.write('manuSpecificBosch7', {0x5005: {value: index, type: 0x18}}, manufacturerOptions);
await endpoint.write('manuSpecificBosch7', {heartbeat: index}, manufacturerOptions);
return {state: {heartbeat: value}};
}
if (key === 'self_test') {
Expand Down Expand Up @@ -593,17 +593,17 @@ const tzLocal = {
convertGet: async (entity, key, meta) => {
switch (key) {
case 'sensitivity':
await entity.read('manuSpecificBosch', [0x4003], manufacturerOptions);
await entity.read('manuSpecificBosch', ['sensitivity'], manufacturerOptions);
break;
case 'pre_alarm':
await entity.read('manuSpecificBosch5', [0x4001], manufacturerOptions);
await entity.read('manuSpecificBosch5', ['pre_alarm'], manufacturerOptions);
break;
case 'heartbeat':
await meta.device.getEndpoint(12).read('manuSpecificBosch7', [0x5005], manufacturerOptions);
await meta.device.getEndpoint(12).read('manuSpecificBosch7', ['heartbeat'], manufacturerOptions);
break;
case 'alarm':
case 'self_test':
await meta.device.getEndpoint(12).read('manuSpecificBosch8', [0x5000], manufacturerOptions);
await meta.device.getEndpoint(12).read('manuSpecificBosch8', ['alarm_status'], manufacturerOptions);
break;
default: // Unknown key
throw new Error(`Unhandled key toZigbee.bosch_twinguard.convertGet ${key}`);
Expand Down Expand Up @@ -700,9 +700,8 @@ const fzLocal = {
type: ['attributeReport', 'readResponse'],
convert: (model, msg, publish, options, meta) => {
const result: KeyValue = {};
const data = msg.data;
if (data.hasOwnProperty('alarmOnMotion')) {
result.alarm_on_motion = (Object.keys(stateOffOn)[data['alarmOnMotion']]);
if (msg.data.hasOwnProperty('alarmOnMotion')) {
result.alarm_on_motion = (Object.keys(stateOffOn)[msg.data['alarmOnMotion']]);
}
return result;
},
Expand Down Expand Up @@ -806,8 +805,8 @@ const fzLocal = {
type: ['attributeReport', 'readResponse'],
convert: (model, msg, publish, options, meta) => {
const result: KeyValue = {};
if (msg.data.hasOwnProperty(0x4003)) {
result.sensitivity = (Object.keys(smokeSensitivity)[msg.data[0x4003]]);
if (msg.data.hasOwnProperty('sensitivity')) {
result.sensitivity = (Object.keys(smokeSensitivity)[msg.data['sensitivity']]);
}
return result;
},
Expand Down Expand Up @@ -888,7 +887,6 @@ const fzLocal = {
0x00200081: 'fire',
0x00200040: 'silenced',
};

if (msg.data.hasOwnProperty('alarm_status')) {
result.self_test = (msg.data['alarm_status'] & 1<<24) > 0;
result.smoke = (msg.data['alarm_status'] & 1<<7) > 0;
Expand Down Expand Up @@ -1404,15 +1402,9 @@ const definitions: Definition[] = [
await reporting.bind(device.getEndpoint(12), coordinatorEndpointB, ['manuSpecificBosch8']);
await device.getEndpoint(1).read('manuSpecificBosch5', ['unknown_attribute'], manufacturerOptions); // Needed for pairing
await device.getEndpoint(12).command('manuSpecificBosch7', 'pairingCompleted', manufacturerOptions); // Needed for pairing
await device.getEndpoint(1).write('manuSpecificBosch', {
sensitivity: {value: 0x0002, type: Zcl.DataType.uint16},
}, manufacturerOptions); // Setting defaults
await device.getEndpoint(1).write('manuSpecificBosch5', {
pre_alarm: {value: 0x01, type: Zcl.DataType.bitmap8},
}, manufacturerOptions); // Setting defaults
await device.getEndpoint(12).write('manuSpecificBosch7', {
heartbeat: {value: 0x01, type: Zcl.DataType.bitmap8},
}, manufacturerOptions); // Setting defaults
await device.getEndpoint(1).write('manuSpecificBosch', {sensitivity: 0x0002}, manufacturerOptions); // Setting defaults
await device.getEndpoint(1).write('manuSpecificBosch5', {pre_alarm: 0x01}, manufacturerOptions); // Setting defaults
await device.getEndpoint(12).write('manuSpecificBosch7', {heartbeat: 0x01}, manufacturerOptions); // Setting defaults
await device.getEndpoint(1).read('manuSpecificBosch', ['sensitivity'], manufacturerOptions);
await device.getEndpoint(1).read('manuSpecificBosch5', ['pre_alarm'], manufacturerOptions);
await device.getEndpoint(12).read('manuSpecificBosch7', ['heartbeat'], manufacturerOptions);
Expand All @@ -1430,8 +1422,8 @@ const definitions: Definition[] = [
e.text('siren_state', ea.STATE).withDescription('Siren state'),
e.binary('self_test', ea.ALL, true, false).withDescription('Initiate self-test'),
e.enum('sensitivity', ea.ALL, Object.keys(smokeSensitivity)).withDescription('Sensitivity of the smoke alarm'),
e.enum('pre_alarm', ea.ALL, Object.keys(stateOffOn)).withDescription('Enable/disable pre-alarm'),
e.enum('heartbeat', ea.ALL, Object.keys(stateOffOn)).withDescription('Enable/disable heartbeat'),
e.binary('pre_alarm', ea.ALL, 'ON', 'OFF').withDescription('Enable/disable pre-alarm'),
e.binary('heartbeat', ea.ALL, 'ON', 'OFF').withDescription('Enable/disable heartbeat'),
],
},
{
Expand Down

0 comments on commit 06458b1

Please sign in to comment.