forked from rbaron/b-parasite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
b-parasite.js
47 lines (44 loc) · 1.73 KB
/
b-parasite.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// This is a zigbee2mqtt zigbee2mqtt.io converter for this sample.
// See https://www.zigbee2mqtt.io/advanced/support-new-devices/01_support_new_devices.html
// on how to use it.
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 e = exposes.presets;
const ea = exposes.access;
const definition = {
zigbeeModel: ['b-parasite'],
model: 'b-parasite',
vendor: 'b-parasite',
description: 'IoT development board - Zigbee sample',
fromZigbee: [fz.temperature, fz.humidity, fz.battery, fz.soil_moisture, fz.illuminance],
toZigbee: [],
exposes: [
e.temperature(),
e.humidity(),
e.battery(),
e.soil_moisture(),
e.illuminance_lux()],
configure: async (device, coordinatorEndpoint, logger) => {
const endpoint = device.getEndpoint(10);
await reporting.bind(
endpoint,
coordinatorEndpoint, [
'genPowerCfg',
'msTemperatureMeasurement',
'msRelativeHumidity',
'msSoilMoisture',
'msIlluminanceMeasurement',
]);
await reporting.batteryPercentageRemaining(endpoint);
// Not reportable :(
// await reporting.batteryVoltage(endpoint);
await reporting.temperature(endpoint);
await reporting.humidity(endpoint);
await reporting.soil_moisture(endpoint);
await reporting.illuminance(endpoint);
}
};
module.exports = definition;