Closed petepal closed 8 months ago
Here are some entries from the log:
Debug 2024-01-19 15:49:06Received Zigbee message from '0xa4c1389acca76e05', type 'commandDataReport', cluster 'manuSpecificTuya', data '{"dpValues":[{"data":{"data":[0,0,0,111],"type":"Buffer"},"datatype":2,"dp":9}],"seq":29184}' from endpoint 1 with groupID 0
Debug 2024-01-19 15:49:06No converter available for 'TS0601' with cluster 'manuSpecificTuya' and type 'commandDataReport' and data '{"dpValues":[{"data":{"data":[0,0,0,111],"type":"Buffer"},"datatype":2,"dp":9}],"seq":29184}'
Debug 2024-01-19 15:49:07Received Zigbee message from '0xa4c1389acca76e05', type 'commandDataReport', cluster 'manuSpecificTuya', data '{"dpValues":[{"data":{"data":[0,0,0,122],"type":"Buffer"},"datatype":2,"dp":9}],"seq":29440}' from endpoint 1 with groupID 0
Debug 2024-01-19 15:49:07No converter available for 'TS0601' with cluster 'manuSpecificTuya' and type 'commandDataReport' and data '{"dpValues":[{"data":{"data":[0,0,0,122],"type":"Buffer"},"datatype":2,"dp":9}],"seq":29440}'
Debug 2024-01-19 15:49:09Received Zigbee message from '0xa4c1389acca76e05', type 'commandDataReport', cluster 'manuSpecificTuya', data '{"dpValues":[{"data":{"data":[0,0,0,123],"type":"Buffer"},"datatype":2,"dp":9}],"seq":29696}' from endpoint 1 with groupID 0
Debug 2024-01-19 15:49:09No converter available for 'TS0601' with cluster 'manuSpecificTuya' and type 'commandDataReport' and data '{"dpValues":[{"data":{"data":[0,0,0,123],"type":"Buffer"},"datatype":2,"dp":9}],"seq":29696}'
Debug 2024-01-19 15:49:11Received Zigbee message from '0xa4c1389acca76e05', type 'commandDataReport', cluster 'manuSpecificTuya', data '{"dpValues":[{"data":{"data":[0,0,0,112],"type":"Buffer"},"datatype":2,"dp":9}],"seq":29952}' from endpoint 1 with groupID 0
Debug 2024-01-19 15:49:11No converter available for 'TS0601' with cluster 'manuSpecificTuya' and type 'commandDataReport' and data '{"dpValues":[{"data":{"data":[0,0,0,112],"type":"Buffer"},"datatype":2,"dp":9}],"seq":29952}'
Debug 2024-01-19 15:49:12Received Zigbee message from '0xa4c1389acca76e05', type 'commandDataReport', cluster 'manuSpecificTuya', data '{"dpValues":[{"data":{"data":[0,0,0,117],"type":"Buffer"},"datatype":2,"dp":9}],"seq":30208}' from endpoint 1 with groupID 0
Debug 2024-01-19 15:49:12No converter available for 'TS0601' with cluster 'manuSpecificTuya' and type 'commandDataReport' and data '{"dpValues":[{"data":{"data":[0,0,0,117],"type":"Buffer"},"datatype":2,"dp":9}],"seq":30208}'
Debug 2024-01-19 15:49:14Received Zigbee message from '0xa4c1389acca76e05', type 'commandDataReport', cluster 'manuSpecificTuya', data '{"dpValues":[{"data":{"data":[0,0,0,201],"type":"Buffer"},"datatype":2,"dp":9}],"seq":30464}' from endpoint 1 with groupID 0
Debug 2024-01-19 15:49:14No converter available for 'TS0601' with cluster 'manuSpecificTuya' and type 'commandDataReport' and data '{"dpValues":[{"data":{"data":[0,0,0,201],"type":"Buffer"},"datatype":2,"dp":9}],"seq":30464}'
I believe I managed to make it work ;) It seems the device is reporting almost everything correctly.
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 globalStore = require('zigbee-herdsman-converters/lib/store');
const e = exposes.presets;
const ea = exposes.access;
const customTrueFalseConverter = {
key: ['presence'],
convertSet: (entity, key, value, meta) => {
// Your conversion logic
const presence = value === 1 ? true : false;
return {state: {presence}};
},
convertGet: (entity, key, meta) => {
// Convert the state value from Home Assistant to the appropriate Zigbee value
const zigbeeValue = meta.state.presence ? 1 : 0;
return {state: zigbeeValue};
},
};
const definition = {
fingerprint: tuya.fingerprint('TS0601', ['_TZE204_ztqnh5cg']),
model: 'HPS',
vendor: 'iHseno',
description: 'Human Presence Sensor',
fromZigbee: [tuya.fz.datapoints],
toZigbee: [tuya.tz.datapoints],
exposes: [
e.illuminance_lux(), e.presence(),
e.numeric('target_distance', ea.STATE).withDescription('Distance to target').withUnit('m'),
e.numeric('radar_sensitivity', ea.STATE_SET).withValueMin(0).withValueMax(9).withValueStep(1)
.withDescription('sensitivity of the radar'),
e.numeric('minimum_range', ea.STATE_SET).withValueMin(0).withValueMax(9.5).withValueStep(0.15)
.withDescription('Minimum range').withUnit('m'),
e.numeric('maximum_range', ea.STATE_SET).withValueMin(0).withValueMax(9.5).withValueStep(0.15)
.withDescription('Maximum range').withUnit('m'),
e.numeric('detection_delay', ea.STATE_SET).withValueMin(0).withValueMax(10).withValueStep(0.1)
.withDescription('Detection delay').withUnit('s'),
e.numeric('fading_time', ea.STATE_SET).withValueMin(0.5).withValueMax(1500).withValueStep(1)
.withDescription('Fading time').withUnit('s'),
],
meta: {
tuyaDatapoints: [
[1, 'presence', customTrueFalseConverter],
[9, 'target_distance', tuya.valueConverter.divideBy100],
[104, 'illuminance_lux', tuya.valueConverter.raw],
[2, 'radar_sensitivity', tuya.valueConverter.raw],
[4, 'maximum_range', tuya.valueConverter.divideBy100],
[3, 'minimum_range', tuya.valueConverter.divideBy100],
[102, 'fading_time', tuya.valueConverter.divideBy10],
[101, 'detection_delay', tuya.valueConverter.divideBy10],
],
},
};
module.exports = definition;
I got the following errors:
Error 2024-01-24 07:39:36Exception while calling fromZigbee converter: Value '1' is not allowed, expected one of true,false}
Debug 2024-01-24 07:39:36Error: Value '1' is not allowed, expected one of true,false at Object.from (/app/node_modules/zigbee-herdsman-converters/src/lib/tuya.ts:435:27) at Object.convert (/app/node_modules/zigbee-herdsman-converters/src/lib/tuya.ts:1307:57) at Receive.onDeviceMessage (/app/lib/extension/receive.ts:153:51) at EventEmitter.wrappedCallback (/app/lib/eventBus.ts:174:23) at EventEmitter.emit (node:events:529:35) at EventBus.emitDeviceMessage (/app/lib/eventBus.ts:108:22) at Controller.<anonymous> (/app/lib/zigbee.ts:115:27)
After adding customTrueFalseConverter (thanks, GPT!) it didn't happen again, but still the presence states returns 0 or 1:
{
"detection_delay": 0.1,
"fading_time": 30,
"illuminance_lux": 42,
"linkquality": 144,
"maximum_range": 3,
"minimum_range": 0.1,
"presence": 1,
"radar_sensitivity": 7,
"target_distance": 0.95
}
Would you mind creating a PR for this?
For mine, I found changing [1, 'presence', customTrueFalseConverter] to [1, 'presence', tuya.valueConverter.trueFalse1] gave me presence with Ture or False.
{ "detection_delay": 0.1, "fading_time": 9.5, "illuminance_lux": 1, "linkquality": 54, "maximum_range": 3, "minimum_range": 0.45, "presence": false, "radar_sensitivity": 6, "target_distance": 0 }
@Koenkk, done! Changed the file according to what @ademobile said and it works like a charm.
Hi! I've just got this device from Aliexpress and just came across this post. Optimistically, I copied petepal's ts-file and thought I finally could make this sensor work.
But, z2m did not even start!
Can this be explained by my use of the docker-image (koenkk/zigbee2mqtt:latest) e.g. older version?
Hi! I've just got this device from Aliexpress and just came across this post. Optimistically, I copied petepal's ts-file and thought I finally could make this sensor work.
But, z2m did not even start! Can this be explained by my use of the docker-image (koenkk/zigbee2mqtt:latest) e.g. older version?
arb2040, it should work out of the box, as it was added as ZY-M100-S_2
's whitelabel. Remove the custom converter, update zigbee2mqtt and it should work.
petepal, thank you for your response!
Changed docker image to: koenkk/zigbee2mqtt:latest-dev Made some progress with this and the external converter, but puzzled by 'presence' now is always 'true' and 'target_distance' seems unreliable/random.
Did you manage to have your device working properly?
I also have a _TZE204_ztqnh5cg and it was not detected supported by Zigbee2MQTT (1.35.3-dev commit: a5a87a79)
After using some external converters, I managed to add the device but not all the features (e.g. presence) are working correctly.
Link
https://aliexpress.com/item/1005006344138708.html?spm=a2g0o.order_list.order_list_main.23.3d991c24DUN406&gatewayAdapt=glo2pol
Database entry
{"id":22,"type":"Router","ieeeAddr":"0xa4c1389acca76e05","nwkAddr":9012,"manufId":4417,"manufName":"_TZE204_ztqnh5cg","powerSource":"Mains (single phase)","modelId":"TS0601","epList":[1,242],"endpoints":{"1":{"profId":260,"epId":1,"devId":81,"inClusterList":[4,5,61184,0],"outClusterList":[25,10],"clusters":{"genBasic":{"attributes":{"stackVersion":0,"dateCode":""}}},"binds":[],"configuredReportings":[],"meta":{}},"242":{"profId":41440,"epId":242,"devId":97,"inClusterList":[],"outClusterList":[33],"clusters":{},"binds":[],"configuredReportings":[],"meta":{}}},"appVersion":74,"stackVersion":0,"hwVersion":1,"dateCode":"","zclVersion":3,"interviewCompleted":true,"meta":{},"lastSeen":1705667020052}
Comments
Please, add support for this device.
External defintion