Koenkk / zigbee2mqtt

Zigbee 🐝 to MQTT bridge 🌉, get rid of your proprietary Zigbee bridges 🔨
https://www.zigbee2mqtt.io
GNU General Public License v3.0
12.21k stars 1.68k forks source link

[New device support]: TZE204_ex3rcdha presence and lux sensor #23705

Open djdevil opened 3 months ago

djdevil commented 3 months ago

Link

https://it.aliexpress.com/item/1005007335061248.html?gatewayAdapt=glo2ita

Database entry

{"id":54,"type":"Router","ieeeAddr":"0xa4c13887abb15e5d","nwkAddr":37763,"manufId":4417,"manufName":"_TZE204_ex3rcdha","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":1724348619720}

Comments

I purchased this new sensor, but even by modifying the converter it doesn't seem to work, is there anyone who can help me, thanks

External definition

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 legacy = require('zigbee-herdsman-converters/lib/legacy');
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 tzDatapoints = {
    ...tuya.tz.datapoints,
    key: [...tuya.tz.datapoints.key, 'minimum_range', 'maximum_range', 'detection_delay', 'fading_time']
}

const definition = {
    fingerprint: tuya.fingerprint('TS0601', ['_TZE204_ex3rcdha']),
    model: 'TS0601_smart_human_presence_sensor',
    vendor: 'TuYa',
    description: 'Smart Human presence sensor',
    fromZigbee: [tuya.fz.datapoints],
    toZigbee: [tzDatapoints],
    exposes: [
        e.illuminance_lux(), e.presence(),
        exposes.numeric('target_distance', ea.STATE).withDescription('Distance to target').withUnit('m'),
        exposes.numeric('radar_sensitivity', ea.STATE_SET).withValueMin(0).withValueMax(9).withValueStep(1)
            .withDescription('sensitivity of the radar'),
        exposes.numeric('minimum_range', ea.STATE_SET).withValueMin(0).withValueMax(9.5).withValueStep(0.15)
            .withDescription('Minimum range').withUnit('m'),
        exposes.numeric('maximum_range', ea.STATE_SET).withValueMin(0).withValueMax(9.5).withValueStep(0.15)
            .withDescription('Maximum range').withUnit('m'),
        exposes.numeric('detection_delay', ea.STATE_SET).withValueMin(0).withValueMax(10).withValueStep(0.1)
            .withDescription('Detection delay').withUnit('s'),
        exposes.numeric('fading_time', ea.STATE_SET).withValueMin(0.5).withValueMax(1500).withValueStep(1)
            .withDescription('Fading time').withUnit('s'),
    ],
    meta: {
        tuyaDatapoints: [
            [104, 'illuminance_lux', tuya.valueConverter.raw],
            [105, 'presence', tuya.valueConverter.trueFalse1],
            [106, 'radar_sensitivity', tuya.valueConverter.raw],
            [107, 'maximum_range', tuya.valueConverter.divideBy100],
            [108, 'minimum_range', tuya.valueConverter.divideBy100],
            [109, 'target_distance', tuya.valueConverter.divideBy100],
            [110, 'fading_time', tuya.valueConverter.divideBy10],
            [111, 'detection_delay', tuya.valueConverter.divideBy10],
        ],
    }
};

module.exports = definition;
draserver commented 3 months ago

And me too

therealchunkyd commented 2 months ago

Also following this one

BeastyBoy339 commented 2 months ago

Following

DougD1991 commented 2 months ago

Following

Yub0 commented 2 months ago

i have the same presence detector too, following

Koenkk commented 2 months ago

In order to add support for this Tuya device, we need to figure out what datapoints it uses. See this guide on how to do that

fabianteunissen commented 2 months ago

Not able to figure out the datapoints, but following!

tomas123 commented 2 months ago

I found here the datapoints for the ZY-HPS01-5.8G https://github.com/make-all/tuya-local/blob/main/custom_components/tuya_local/devices/zyhps01_human_presence_sensor.yaml

motezuki commented 2 months ago

Got this device working with illuminance and presence states, other parameters can be set but not read at first

Edit Added fix from https://github.com/Koenkk/zigbee2mqtt/issues/23705#issuecomment-2345003744 and https://github.com/Koenkk/zigbee2mqtt/issues/23705#issuecomment-2345832981

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 modernExtend = require('zigbee-herdsman-converters/lib/modernExtend');
const e = exposes.presets;
const ea = exposes.access;
const tuya = require('zigbee-herdsman-converters/lib/tuya');

const definition = {
    fingerprint: [
        {
            modelID: 'TS0601',
            manufacturerName: '_TZE204_ex3rcdha',
        },
    ],
    model: 'TS0601_?',
    vendor: 'Tuya',
    description: 'mmWave radar ZY_HPS01 V1.2',
    fromZigbee: [tuya.fz.datapoints],
    toZigbee: [tuya.tz.datapoints],
    configure: tuya.configureMagicPacket,
    extend: [    ],
    exposes: [
        e.illuminance_lux(),
        e.occupancy(),
        exposes.numeric('presence_timeout', ea.STATE_SET).withValueMin(0).withValueMax(180).withValueStep(1)
            .withDescription('Presence timeout').withUnit('s'),
        exposes.numeric('move_sensitivity', ea.STATE_SET).withValueMin(0).withValueMax(10).withValueStep(1)
           .withDescription('sensitivity of the radar').withUnit('X'),
        exposes.numeric('move_minimum_range', ea.STATE_SET).withValueMin(0).withValueMax(600).withValueStep(10)
            .withDescription('Movement minimum range').withUnit('cm'),
        exposes.numeric('move_maximum_range', ea.STATE_SET).withValueMin(0).withValueMax(600).withValueStep(10)
            .withDescription('Movement maximum range').withUnit('cm'),
        exposes.numeric('breath_sensitivity', ea.STATE_SET).withValueMin(0).withValueMax(10).withValueStep(1)
            .withDescription('Breath sensitivity of the radar').withUnit('X'),
        exposes.numeric('breath_minimum_range', ea.STATE_SET).withValueMin(0).withValueMax(600).withValueStep(10)
            .withDescription('Breath minimum range').withUnit('cm'),
        exposes.numeric('breath_maximum_range', ea.STATE_SET).withValueMin(0).withValueMax(600).withValueStep(10)
            .withDescription('Breath maximum range').withUnit('cm'),

    ],
    meta: {
        tuyaDatapoints: [
            [12, 'illuminance_lux', tuya.valueConverter.raw],
            [101, 'occupancy', tuya.valueConverter.trueFalse0],
            [104, 'presence_timeout', tuya.valueConverter.raw],
            [105, 'move_sensitivity', tuya.valueConverter.raw],
            [107, 'breath_sensitivity', tuya.valueConverter.raw],
            [109, 'move_maximum_range', tuya.valueConverter.raw],
            [110, 'move_minimum_range', tuya.valueConverter.raw],
            [111, 'breath_maximum_range', tuya.valueConverter.raw],
            [112, 'breath_minimum_range', tuya.valueConverter.raw],

        ],
    }
};

module.exports = definition;
motezuki commented 2 months ago

Sorry I missed one edition on tuyaDatapoints

where is: [105, 'movesensitivity', tuya.valueConverter.raw],

should be: [105, 'move_sensitivity', tuya.valueConverter.raw],

I will fix on the post

Em qua., 11 de set. de 2024 às 14:35, djdevil @.***> escreveu:

Got this device working with illuminance and presence states, other parameters can be set but not read at first

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 modernExtend = require('zigbee-herdsman-converters/lib/modernExtend'); const e = exposes.presets; const ea = exposes.access; const tuya = require('zigbee-herdsman-converters/lib/tuya');

const definition = { fingerprint: [ { modelID: 'TS0601', manufacturerName: '_TZE204ex3rcdha', }, ], model: 'TS0601?', vendor: 'Tuya', description: 'mmWave radar ZY_HPS01 V1.2', fromZigbee: [tuya.fz.datapoints], toZigbee: [tuya.tz.datapoints], configure: tuya.configureMagicPacket, extend: [ ], exposes: [ e.illuminance_lux(), e.presence(), exposes.numeric('presence_timeout', ea.STATE_SET).withValueMin(0).withValueMax(180).withValueStep(1) .withDescription('Presence timeout').withUnit('s'), exposes.numeric('move_sensitivity', ea.STATE_SET).withValueMin(0).withValueMax(10).withValueStep(1) .withDescription('sensitivity of the radar').withUnit('X'), exposes.numeric('move_minimum_range', ea.STATE_SET).withValueMin(0).withValueMax(600).withValueStep(10) .withDescription('Movement minimum range').withUnit('cm'), exposes.numeric('move_maximum_range', ea.STATE_SET).withValueMin(0).withValueMax(600).withValueStep(10) .withDescription('Movement maximum range').withUnit('cm'), exposes.numeric('breath_sensitivity', ea.STATE_SET).withValueMin(0).withValueMax(10).withValueStep(1) .withDescription('Breath sensitivity of the radar').withUnit('X'), exposes.numeric('breath_minimum_range', ea.STATE_SET).withValueMin(0).withValueMax(600).withValueStep(10) .withDescription('Breath minimum range').withUnit('cm'), exposes.numeric('breath_maximum_range', ea.STATE_SET).withValueMin(0).withValueMax(600).withValueStep(10) .withDescription('Breath maximum range').withUnit('cm'),

],
meta: {
    tuyaDatapoints: [
        [12, 'illuminance_lux', tuya.valueConverter.raw],
        [101, 'presence', tuya.valueConverter.trueFalse0],
        [104, 'presence_timeout', tuya.valueConverter.raw],
        [105, 'movesensitivity', tuya.valueConverter.raw],
        [107, 'breath_sensitivity', tuya.valueConverter.raw],
        [109, 'move_maximum_range', tuya.valueConverter.raw],
        [110, 'move_minimum_range', tuya.valueConverter.raw],
        [111, 'breath_maximum_range', tuya.valueConverter.raw],
        [112, 'breath_minimum_range', tuya.valueConverter.raw],

    ],
}

};

the code gives me a syntax error and doesn't seem to function, as if we are missing

data const tzDatapoints = { ...tuya.tz.datapoints, key: Array.isArray(tuya.tz.datapoints.key) ? [...tuya.tz.datapoints.key, 'minimum_range', 'maximum_range', 'detection_delay', 'fading_time'] : ['minimum_range', 'maximum_range', 'detection_delay', 'fading_time'] };

— Reply to this email directly, view it on GitHub https://github.com/Koenkk/zigbee2mqtt/issues/23705#issuecomment-2344290398, or unsubscribe https://github.com/notifications/unsubscribe-auth/AW2H7KXONOU62DX36XUA6JTZWB5MNAVCNFSM6AAAAABM6UCOBKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBUGI4TAMZZHA . You are receiving this because you commented.Message ID: @.***>

tomas123 commented 2 months ago

I add this line for an external *.js script module.exports = definition;

and now the code works fine!

Koenkk commented 2 months ago

@motezuki could you submit a PR by clicking here?

Javisen commented 2 months ago

@motezuki Thank you very much for the work. It works fine for me. Is there any way to change the icon? edit: the illuminance don't work

motezuki commented 2 months ago

@Javisen maybe you have a slightly different device, with a different data point for illuminance. Could you verify the datapoints using these instructions?

The icons can be changed directly on the configuration of the entity card

Javisen commented 2 months ago

@Javisen maybe you have a slightly different device, with a different data point for illuminance. Could you verify the datapoints using these instructions?

The icons can be changed directly on the configuration of the entity card

I think it might be the device. When you bring a flashlight close to the sensor you get lux values but very low (25 lux). Also, I don't know how I can find the device on yours if I'm using it locally.

BeastyBoy339 commented 2 months ago

Thanks for al the work. It works but cant use the distance settings, getting an error like this "z2m: No converter available for 'move_minimum_range' (340)"

paulsijben commented 1 week ago

following. I was looking at my TS0601 quirk, and I do not see how I can add this code in.