### Link
https://www.aliexpress.com/item/1005006492967626.html
### Database en…try
{"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](https://www.zigbee2mqtt.io/devices/ZG-204ZL.html#tuya-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)](https://github.com/Koenkk/zigbee-herdsman-converters/blob/14dffaa06511876d096aa72e669df4b032f4cf33/src/devices/tuya.ts#L5656-L5714), and illuminance and motion state started to work.
It works somewhat okay-ish with two obvious caveats:
- the presence attribute is always Nulls, even when motion state is large or small,
- the motion state is always large (something detected) or small, but based on the definition file, there should be also none and medium values.
I am also not sure, if configuration options have any effect.
### External definition
```shell
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;
```