Koenkk / zigbee2mqtt

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

[New device support]: ZG-204ZM similar to ZG-204ZL #21919

Open kravemir opened 5 months ago

kravemir commented 5 months ago

Link

https://www.aliexpress.com/item/1005006492967626.html

Database entry

{"id":37,"type":"EndDevice","ieeeAddr":"0xa4c13835d225271e","nwkAddr":21969,"manufId":4098,"manufName":"_TZE200_2aaelwxk","powerSource":"Battery","modelId":"TS0601","epList":[1],"endpoints":{"1":{"profId":260,"epId":1,"devId":1026,"inClusterList":[0,3,1280,1,1024],"outClusterList":[],"clusters":{"genBasic":{"attributes":{"modelId":"TS0601","manufacturerName":"_TZE200_2aaelwxk"}},"ssIasZone":{"attributes":{"iasCieAddr":"0xe0798dfffed3b030","zoneState":0}},"genPowerCfg":{"attributes":{"batteryPercentageRemaining":200,"batteryVoltage":26}},"msIlluminanceMeasurement":{"attributes":{"measuredValue":32546}}},"binds":[],"configuredReportings":[],"meta":{}}},"appVersion":144,"stackVersion":2,"hwVersion":1,"swBuildId":"0122052017","zclVersion":3,"interviewCompleted":true,"meta":{},"lastSeen":1711218578185}

Comments

I ordered both variants, the PIR Infrared variant and the 24GHz radar variant from the AliExpress link.


Common manual for both specifies ZG-204ZS/ZG-204ZM as model names. And, that only ZG-204ZM has 24GHz sensor.

I disassembled both, and both of them have written ZG-204ZS on the PCB, but the 24GHz variant has got extra circuitry attached to it, looks like the 24GHz radar.


The PIR Infrared variant (ZG-204ZS) is detected as ZG-204ZL in Zigbee2MQTT.

The 24GHz radar variant (ZG-204ZM) is not yet supported by Zigbee2MQTT.


Now, the confusing part

At first, I tried to base definition on ZL-204ZL - https://github.com/Koenkk/zigbee-herdsman-converters/blob/14dffaa06511876d096aa72e669df4b032f4cf33/src/devices/tuya.ts#L5627-L5655, and nothing worked, not even illuminance report.

Then, I tried to base definition ZG-205Z/A (_TZE200_2aaelwxk), and illuminance and motion state started to work.

It works somewhat okay-ish with two obvious caveats:

I am also not sure, if configuration options have any effect.

External definition

const {} = require('zigbee-herdsman-converters/lib/modernExtend');
// Add the lines below
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 {} = 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 definition = {
    zigbeeModel: ['TS0601'],
    model: 'TS0601',
    vendor: 'TuYa',
    description: 'Luminance motion sensor',
    fromZigbee: [tuya.fz.datapoints],
    toZigbee: [tuya.tz.datapoints],
    exposes: [
        e.presence(), e.illuminance().withUnit('lx'),
        e.numeric('large_motion_detection_sensitivity', ea.STATE_SET).withValueMin(0).withValueMax(10).withValueStep(1).withUnit('x')
            .withDescription('Motion detection sensitivity'),
        e.numeric('large_motion_detection_distance', ea.STATE_SET).withValueMin(0).withValueMax(10).withValueStep(0.01).withUnit('m')
            .withDescription('Motion detection distance'),
        e.enum('motion_state', ea.STATE, ['none', 'small', 'medium', 'large']).withDescription('State of the motion'),
        e.numeric('fading_time', ea.STATE_SET).withValueMin(0).withValueMax(28800).withValueStep(1).withUnit('s')
            .withDescription('For how much time presence should stay true after detecting it'),
        e.numeric('medium_motion_detection_distance', ea.STATE_SET).withValueMin(0).withValueMax(6).withValueStep(0.01).withUnit('m')
            .withDescription('Medium motion detection distance'),
        e.numeric('medium_motion_detection_sensitivity', ea.STATE_SET).withValueMin(0).withValueMax(10).withValueStep(1).withUnit('x')
            .withDescription('Medium motion detection sensitivity'),
        e.binary('indicator', ea.STATE_SET, 'ON', 'OFF').withDescription('LED Indicator'),
        e.numeric('small_detection_distance', ea.STATE_SET).withValueMin(0).withValueMax(6).withValueStep(0.01).withUnit('m')
            .withDescription('Small detection distance'),
        e.numeric('small_detection_sensitivity', ea.STATE_SET).withValueMin(0).withValueMax(10).withValueStep(1).withUnit('x')
            .withDescription('Small detection sensitivity'),
    ],
    meta: {
        tuyaDatapoints: [
            [1, 'presence', tuya.valueConverter.trueFalse1],
            [2, 'large_motion_detection_sensitivity', tuya.valueConverter.raw],
            [4, 'large_motion_detection_distance', tuya.valueConverter.divideBy100],
            [101, 'motion_state', tuya.valueConverterBasic.lookup(
                {'none': tuya.enum(0), 'large': tuya.enum(1), 'medium': tuya.enum(2), 'small': tuya.enum(3)})],
            [102, 'fading_time', tuya.valueConverter.raw],
            [104, 'medium_motion_detection_distance', tuya.valueConverter.divideBy100],
            [105, 'medium_motion_detection_sensitivity', tuya.valueConverter.raw],
            [106, 'illuminance', tuya.valueConverter.raw],
            [107, 'indicator', tuya.valueConverter.onOff],
            [108, 'small_detection_distance', tuya.valueConverter.divideBy100],
            [109, 'small_detection_sensitivity', tuya.valueConverter.raw],
            // Not exposed DPs/untested
            // [103, 'motion_false_detection', tuya.valueConverter.raw],
            // [113, 'breathe_false_detection', tuya.valueConverter.raw],
            // [3, 'mov_minimum_distance', tuya.valueConverter.raw],
            // [110, 'micro_minimum_distance', tuya.valueConverter.raw],
            // [111, 'motionless_minimum_distance', tuya.valueConverter.raw],
            // [112, 'reset_setting', tuya.valueConverter.raw],
            // [114, 'time', tuya.valueConverter.raw],
            // [115, 'alarm_time', tuya.valueConverter.raw],
            // [116, 'alarm_volume', tuya.valueConverterBasic.lookup(
            //  {'low': tuya.enum(0), 'medium': tuya.enum(1), 'high': tuya.enum(2), 'mute': tuya.enum(3)})],
            // [117, 'working_mode', tuya.valueConverterBasic.lookup(
            // {'arm': tuya.enum(0), 'off': tuya.enum(1), 'alarm': tuya.enum(2),  'doorbell': tuya.enum(3)})],
            // [118, 'auto1', tuya.valueConverter.raw],
            // [119, 'auto2', tuya.valueConverter.raw],
            // [120, 'auto3', tuya.valueConverter.raw],
        ],
    },
};

module.exports = definition;
Klavishnik commented 1 month ago

Здравствуйте, у меня ZG-204ZM (_TZE200_kb5noeto) с прошивкой 0122052017, использующей Z2M 1.39.0-1. Обнаружение присутствия, похоже, вообще не работает, только в режиме PIR (который у меня уже есть). В комбинированном режиме он зависает в "статическом" состоянии. Если я переключу режим обнаружения на радар, он никогда не покажет движение/присутствие... Можно ли это решить с помощью упомянутой перепайки контактов? Или его просто невозможно заставить работать, поэтому мне следует поискать другой радар присутствия? Большое спасибо за ответ.

Моя текущая конфигурация «Обнаружение PIR работает» от Z2M: { "battery": 100, "fading_time": 30, "illuminance_lux": 0, "indicator": "ON", "linkquality": 96, "motion_detection_mode": "pir_and_radar", "motion_detection_sensitivity": 0, "motion_state": "none", "presence": false, "static_detection_distance": 8, "static_detection_sensitivity": 0 }

Same problem. Did you solve it?

kubonm commented 1 month ago

Здравствуйте, у меня ZG-204ZM (_TZE200_kb5noeto) с прошивкой 0122052017, использующей Z2M 1.39.0-1. Обнаружение присутствия, похоже, вообще не работает, только в режиме PIR (который у меня уже есть). В комбинированном режиме он зависает в "статическом" состоянии. Если я переключу режим обнаружения на радар, он никогда не покажет движение/присутствие... Можно ли это решить с помощью упомянутой перепайки контактов? Или его просто невозможно заставить работать, поэтому мне следует поискать другой радар присутствия? Большое спасибо за ответ. Моя текущая конфигурация «Обнаружение PIR работает» от Z2M: { "battery": 100, "fading_time": 30, "illuminance_lux": 0, "indicator": "ON", "linkquality": 96, "motion_detection_mode": "pir_and_radar", "motion_detection_sensitivity": 0, "motion_state": "none", "presence": false, "static_detection_distance": 8, "static_detection_sensitivity": 0 }

Same problem. Did you solve it?

Hello, it magically started working, there are few problems - sometimes presence detection not working, only motion, but overal it 70% works.. :D

JerryLutor commented 1 month ago

Hello. I have ZG-204ZS v2.1, how add support to zigbee2mqtt 1.39.1 ?

vision2003 commented 1 week ago

I’ve got the kb5noeto version one. Detection works quite well actually, but it takes forever (sometimes up to 5 minutes) before it clears “Presence” to false" and “Motion state” to none.

gargamelonly commented 7 hours ago

Replaced the batteries today. After 5 months it dropped to 10% so I guess 6 month battery life, as stated by the specification, is ok.

kevincaradant commented 6 hours ago

https://github.com/Koenkk/zigbee2mqtt/issues/21919#issuecomment-2351060870

I've needed to replace them almost every month until now. I used duracell and energizer with the same problem. Bad luck perhaps? There I switched to rechargeable batteries. They are almost 1 month old for now, it still works. I'll see if I make it to 2 months 🤣

Edit: Battery just die now , am I cursed ? Daim that's crazy. Just one month ( less battery with rechargeable batteries but at least they are rechargeable ) image