Skip to content

Commit

Permalink
feat: Expose broadcast_alarm for Bosch BSD-2 (Koenkk#7427)
Browse files Browse the repository at this point in the history
* fix: Basic (non-functional) implementation

Define required KeyValue set and implement basic `tzLocal` converter with only `SET` permissions.

* fix: Set @ts-expect-error

* fix: Move `tzLocal.broadcast_alarm` to `toZigbee`

The "tz" in `tzLocal` stands for `toZigbee`... Lol.

* fix: Prepare for `zigbee-herdsman` update

We'll need to wait for zigbee-herdsman#1028 to be merged, won't work without.

* fix: Prepare for new `zigbee-herdsman` capabilities

* More preparations for `zigbee-herdsman` update

Not working, yet. 😊

* Use `entity.zclCommandBroadcast` instead

* Rename `Zspec` to `ZSpec`

* Do not return `broadcast_alarm` on `/set`

* Fix minor typos

🤓

* Update bosch.ts

---------

Co-authored-by: Koen Kanters <[email protected]>
  • Loading branch information
burmistrzak and Koenkk authored Apr 28, 2024
1 parent bc8d371 commit bba8c0b
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 deletions src/devices/bosch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {identify, light, onOff, quirkCheckinInterval} from '../lib/modernExtend';
import {Zcl} from 'zigbee-herdsman';
import {Zcl, ZSpec} from 'zigbee-herdsman';
import * as exposes from '../lib/exposes';
import fz from '../converters/fromZigbee';
import tz from '../converters/toZigbee';
Expand Down Expand Up @@ -101,25 +101,33 @@ const displayedTemperature = {
'measured': 1,
};

// Smoke detector II bsd-2
// Smoke detector II BSD-2
const smokeAlarmState: KeyValue = {
'OFF': 0x0000,
'ON': 0x3c00, // 15360 or 46080 works
};

// Smoke detector II bsd-2
// Smoke detector II BSD-2
const burglarAlarmState: KeyValue = {
'OFF': 0x0001,
'ON': 0xb401, // 46081
};

// Smoke detector II bsd-2
// Smoke detector II BSD-2
const smokeDetectorSensitivity: KeyValue = {
'low': 0x0,
'medium': 0x1,
'high': 0x2,
};

// Smoke detector II BSD-2
const broadcastAlarmState: KeyValue = {
'smoke_off': 0x0000,
'smoke_on': 0x3c00,
'burglar_off': 0x0001,
'burglar_on': 0xb401,
};

// Radiator Thermostat II
const setpointSource = {
'manual': 0,
Expand Down Expand Up @@ -174,6 +182,21 @@ Example: 30ff00000102010001`;


const tzLocal = {
broadcast_alarm: {
key: ['broadcast_alarm'],
convertSet: async (entity, key, value, meta) => {
if (key === 'broadcast_alarm') {
const index = utils.getFromLookup(value, broadcastAlarmState);
utils.assertEndpoint(entity);
await entity.zclCommandBroadcast(
255, ZSpec.BroadcastAddress.SLEEPY,
Zcl.Clusters.ssIasZone.ID, 'boschSmokeDetectorSiren',
{data: index}, manufacturerOptions,
);
return;
}
},
} satisfies Tz.Converter,
bsd2: {
key: ['alarm_smoke', 'alarm_burglar', 'sensitivity'],
convertSet: async (entity, key, value: string, meta) => {
Expand Down Expand Up @@ -1029,13 +1052,14 @@ const definitions: Definition[] = [
zigbeeModel: ['RBSH-SD-ZB-EU'],
model: 'BSD-2',
vendor: 'Bosch',
description: 'Smoke alarm detector',
description: 'Smoke alarm II',
fromZigbee: [
fz.battery,
fzLocal.bsd2,
],
toZigbee: [
tzLocal.bsd2,
tzLocal.broadcast_alarm,
],
configure: async (device, coordinatorEndpoint) => {
const endpoint = device.getEndpoint(1);
Expand All @@ -1054,6 +1078,7 @@ const definitions: Definition[] = [
e.binary('alarm_burglar', ea.ALL, 'ON', 'OFF').withDescription('Toggle the burglar alarm on or off'),
e.binary('alarm_smoke', ea.ALL, 'ON', 'OFF').withDescription('Toggle the smoke alarm on or off'),
e.enum('sensitivity', ea.ALL, Object.keys(smokeDetectorSensitivity)).withDescription('Sensitivity of the smoke alarm'),
e.enum('broadcast_alarm', ea.SET, Object.keys(broadcastAlarmState)).withDescription('Set alarm state of all BSD-2 via broadcast'),
],
},
{
Expand Down

0 comments on commit bba8c0b

Please sign in to comment.