-
-
Save Koenkk/86ea747a683752fd6ff9390abf9fda55 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 definition = { | |
fingerprint: tuya.fingerprint('TS0601', ['_TZE200_yojqa8xn']), | |
model: 'TS0601_gas_sensor', | |
vendor: 'TuYa', | |
description: 'Gas sensor', | |
fromZigbee: [tuya.fzDataPoints], | |
toZigbee: [tuya.tzDataPoints], | |
configure: tuya.configureMagicPacket, | |
exposes: [e.gas()], | |
meta: { | |
tuyaDatapoints: [ | |
[1, 'gas', tuya.valueConverter.true0ElseFalse], | |
[2, 'detected_gas', tuya.valueConverter.raw], | |
[6, 'alarm_ringtone', tuya.valueConverter.raw], | |
[7, 'alarm_time', tuya.valueConverter.raw], | |
[8, 'auto_detect', tuya.valueConverter.raw], | |
[9, 'auto_detect_result', tuya.valueConverter.raw], | |
[11, 'preheat', tuya.valueConverter.raw], | |
], | |
}, | |
}; | |
module.exports = definition; |
Have following expose & entry in map for DP 13 in my external converter:
exposes: [
exposes.binary('alarm_switch', ea.STATE_SET, true, false), ...
],
meta: {
tuyaDatapoints: [
[13, 'alarm_switch', tuya.valueConverter.raw], ...
],
],
Unfortunately Z2M show "No converter available for 'alarm_switch (true)'"
As far I see that happens because tuyaTz.datapoints have strict set of keys it can process.....
tuyaFz.datapoints parse data for any DP defined in meta map.
IMHO would be nice toZigbee to process any key defined in meta map.
Thanks for looking into this, could you make a PR?
My current version for converter is:
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 tuya = require('zigbee-herdsman-converters/lib/tuya');
const definition = {
fingerprint: [{modelID: 'TS0601', manufacturerName: '_TZE200_yojqa8xn'}],
model: 'TS0601_gas_sensor',
vendor: 'TuYa',
description: 'Natural gas sensor',
fromZigbee: [tuya.fzDataPoints],
toZigbee: [tuya.tzDataPoints],
configure: tuya.configureMagicPacket,
exposes: [
exposes.binary('gas', ea.STATE, 'detected', 'not detected').withDescription('Indicates whether the device detected gas'),
exposes.numeric('gas_value', ea.STATE).withDescription('Measured gas concentration').withUnit('LEL'),
exposes.enum('alarm_ringtone', ea.STATE_SET, ['RingTone 1', 'RingTone 2', 'RingTone 3', 'RingTone 4', 'RingTone 5'])
.withDescription('Alarm RingTone'),
exposes.numeric('alarm_time', ea.STATE_SET).withValueMin(1).withValueMax(180).withValueStep(1)
.withUnit('s').withDescription('Alarm time'),
tuya.exposes.selfTest(), tuya.exposes.selfTestResult(),
exposes.binary('preheat', ea.STATE, true, false),
exposes.binary('alarm_switch', ea.STATE_SET, true, false),
tuya.exposes.silence()
],
meta: {
tuyaDatapoints: [
[1, 'gas', tuya.valueConverterBasic.lookup({'detected': tuya.enum(0),'not detected': tuya.enum(1)})],
[2, 'gas_value', tuya.valueConverter.divideBy10],
[6, 'alarm_ringtone', tuya.valueConverterBasic.lookup
({'RingTone 1': 0, 'RingTone 2': 1, 'RingTone 3': 2, 'RingTone 4': 3, 'RingTone 5': 4})],
[7, 'alarm_time', tuya.valueConverter.raw],
[8, 'self_test', tuya.valueConverter.raw],
[9, 'self_test_result', tuya.valueConverter.selfTestResult],
[10, 'preheat', tuya.valueConverter.raw],
[13, 'alarm_switch', tuya.valueConverter.raw],
[16, 'silence', tuya.valueConverter.raw],
],
},
};
module.exports = definition;
BUT, I have an issue f.e. with DP 13 'alarm_switch'.
When trying to send command , got in log:
debug 2022-12-01 21:45:53: Received MQTT message on 'zigbee2mqtt/sGas Boiler/set' with data '{"alarm_switch":true}'
error 2022-12-01 21:45:53: No converter available for 'alarm_switch' (true)
Tried to find where (in code) this error generated, but can't find.
Looks I can't use any other key not included in tuya.tuyaTz.datapoints.key !?!?!
I've created the pr, please check the comments: Koenkk/zigbee-herdsman-converters#5065
[1, 'gas', tuya.valueConverter.true0ElseFalse],
^^ as per my tests this is not working, because dp:1 have type:4 (enum).
Got in log:
Got it working with combination only:
exposes.binary('gas', ea.STATE, 'detected', 'not detected').withDescription('Indicates whether the device detected gas'),
&
[1, 'gas', tuya.valueConverterBasic.lookup({'detected': tuya.enum(0),'not detected': tuya.enum(1)})],
P.S.