Skip to content

Instantly share code, notes, and snippets.

@ov1d1u
Last active October 19, 2022 17:41
Show Gist options
  • Save ov1d1u/b3829a0624d6974180d7a9e0827b8e9a to your computer and use it in GitHub Desktop.
Save ov1d1u/b3829a0624d6974180d7a9e0827b8e9a to your computer and use it in GitHub Desktop.
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 utils = require('zigbee-herdsman-converters/lib/utils');
const e = exposes.presets;
const ea = exposes.access;
const tuyaExposes = {
selfTest: () => exposes.binary('self_test', ea.STATE_SET, true, false).withDescription('Indicates whether the device is being self-tested'),
selfTestResult: () => exposes.enum('self_test_result', ea.STATE, ['checking', 'success', 'failure', 'others']).withDescription('Result of the self-test'),
faultAlarm: () => exposes.binary('fault_alarm', ea.STATE, true, false).withDescription('Indicates whether a fault was detected'),
silence: () => exposes.binary('silence', ea.STATE_SET, true, false).withDescription('Silence the alarm'),
}
const valueConverter = {
selfTestResult: tuya.valueConverterBasic.lookup({'checking': 0, 'success': 1, 'failure': 2, 'others': 3}),
}
const tzDataPoints = {
...tuya.tzDataPoints,
key: ['silence', 'self_test'],
}
const definition = {
fingerprint: tuya.fingerprint('TS0601', ['_TZE200_ggev5fsl', '_TZE200_u319yc66']),
model: 'TS0601_gas_sensor',
vendor: 'TuYa',
description: 'gas sensor',
fromZigbee: [tuya.fzDataPoints],
toZigbee: [tzDataPoints],
configure: tuya.configureMagicPacket,
exposes: [e.gas(), tuyaExposes.selfTest(), tuyaExposes.selfTestResult(), tuyaExposes.faultAlarm(), tuyaExposes.silence()],
meta: {
tuyaDatapoints: [
[1, 'gas', tuya.valueConverter.true0ElseFalse],
[8, 'self_test', tuya.valueConverter.raw],
[9, 'self_test_result', valueConverter.selfTestResult],
[11, 'fault_alarm', tuya.valueConverter.trueFalse],
[16, 'silence', tuya.valueConverter.raw],
],
},
}
module.exports = definition;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment