Woox R7051 Z2M converter with siren volume,brightness,duration
controls exposed
r7051.js
:
const fz = require('zigbee-herdsman-converters/converters/fromZigbee');
const tz = require('zigbee-herdsman-converters/converters/toZigbee');
const exposes = require('zigbee-herdsman-converters/lib/exposes');
const reporting = require('zigbee-herdsman-converters/lib/reporting');
const extend = require('zigbee-herdsman-converters/lib/extend');
const ota = require('zigbee-herdsman-converters/lib/ota');
const tuya = require('zigbee-herdsman-converters/lib/tuya');
const {} = require('zigbee-herdsman-converters/lib/tuya');
const utils = require('zigbee-herdsman-converters/lib/utils');
const globalStore = require('zigbee-herdsman-converters/lib/store');
const e = exposes.presets;
const ea = exposes.access;
const woox = {
fz: {
siren_brightness: {
cluster: 'ssIasWd',
type: ['attributeReport', 'readResponse'],
convert: (model, msg, publish, options, meta) => {
const result = {};
if (msg.data.hasOwnProperty('1')) {
result['brightness'] = msg.data['1'];
}
return result;
},
},
siren_duration_volume: {
cluster: 'ssIasWd',
type: ['attributeReport', 'readResponse'],
convert: (model, msg, publish, options, meta) => {
const result = {};
if (msg.data.hasOwnProperty('maxDuration')) result['duration'] = msg.data.maxDuration;
if (msg.data.hasOwnProperty('2')) {
result['volume'] = msg.data['2'];
}
return result;
},
},
},
tz: {
ts0219_brightness: {
key: ['brightness'],
convertSet: async (entity, key, value, meta) => {
await entity.write('ssIasWd', {0x0001: {value: value, type: 0x20}});
},
convertGet: async (entity, key, meta) => {
await entity.read('ssIasWd', [0x0001]);
},
},
},
};
const definition = {
fingerprint: [{ modelID: 'TS0219', manufacturerName: '_TYZB01_ynsiasng' }],
zigbeeModel: ['TS0219'],
model: 'R7051',
vendor: 'Woox',
description: 'Smart Indoor Siren',
fromZigbee: [fz.battery, fz.power_source, fz.ias_alarm_only_alarm_1, woox.fz.siren_brightness, woox.fz.siren_duration_volume],
toZigbee: [tz.ts0216_alarm, woox.tz.ts0219_brightness, tz.ts0216_duration, tz.ts0216_volume],
exposes: [e.battery(), e.battery_voltage(), e.binary('alarm', ea.STATE, true, false),
e.binary('ac_connected', ea.STATE, true, false).withDescription('Is the device plugged in'),
e.binary('alarm', ea.STATE_SET, true, false).withDescription('Manual start of siren'),
e.numeric('volume', ea.ALL).withValueMin(0).withValueMax(100).withDescription('Volume of siren'),
e.numeric('duration', ea.ALL).withValueMin(0).withValueMax(3600).withDescription('Duration of siren'),
e.numeric('brightness', ea.ALL).withValueMin(0).withValueMax(100).withDescription('Brightness of siren')],
meta: { disableDefaultResponse: true },
configure: async (device, coordinatorEndpoint, logger) => {
const endpoint = device.getEndpoint(1);
const bindClusters = ['genPowerCfg'];
await reporting.bind(endpoint, coordinatorEndpoint, bindClusters);
await reporting.batteryVoltage(endpoint);
await reporting.batteryPercentageRemaining(endpoint);
if (device.powerSource == 'Mains (3 phase)') {
device.powerSource = 'Mains (single phase)';
} else if (device.powerSource == 'Emergency mains and transfer switch') {
device.powerSource = 'Battery';
}
},
};
module.exports = definition;
- Place
r7051.js
file inside thedata
folder (see external-converters for the details) - Add the following lines to the
configuration.yaml
:
external_converters:
- r7051.js
- Restart Z2M
To trigger your siren send the following payload to the respective z2m mqtt topic, like zigbee2mqtt/woox_buzzer/set
:
{"duration": 2, "brightness":50, "volume": 50, "alarm": true}
Ok, first one was my bad (typo). But now I get "Setup failed for 'external_converters': Integration not found." in the logs.
When I click on the log entry it further says "Logger: homeassistant.setup, Source: setup.py:221".
Any ideas?
EDIT: got it! Instead of in the normal config directory I had to place the file in the /share/zigbee2mqtt/ directory. I also added the converter name in the GUI, but I think that is the same as changing the configuration.yaml in THAT directory. WORKS! Thank you!
Now if we could get the different types of sounds that would be awesome ๐