From 18f68d6c8d123f1e216b8a662f8f8c68a7fdc92a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BB=E9=AA=9A?= <200831913@qq.com> Date: Fri, 13 Oct 2023 02:16:27 +0800 Subject: [PATCH] feat(add): CTL-R1-TY-Zigbee (#6264) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Repair:The status displayed in the presence is opposite to the actual situation Repair: "detection_distance_max" The range of max should be 1.5-5.5 Repair: "detection_distance_min" The meaning of min should be target_distance * Repair: eslint error * Repair: eslint error * Add: Suppert "_TZE204_e9ajs4ft" 24G radar human presence motion sensor. * repair eslint error * Update tuya.ts * Update tuya.ts * Update tuya.ts * Update tuya.ts --------- Co-authored-by: Koen Kanters --- src/devices/tuya.ts | 48 +++++++++++++++++++++++++++++++++++++++++++++ src/lib/tuya.ts | 2 ++ 2 files changed, 50 insertions(+) diff --git a/src/devices/tuya.ts b/src/devices/tuya.ts index 2d3a9374a9398..3659bdbd63b21 100644 --- a/src/devices/tuya.ts +++ b/src/devices/tuya.ts @@ -6102,6 +6102,54 @@ const definitions: Definition[] = [ ], }, }, + { + fingerprint: tuya.fingerprint('TS0601', ['_TZE204_e9ajs4ft']), + model: 'CTL-R1-TY-Zigbee', + vendor: 'TuYa', + description: '24G radar human presence motion sensor.', + fromZigbee: [tuya.fz.datapoints], + toZigbee: [tuya.tz.datapoints], + exposes: [ + e.illuminance().withUnit('lx'), e.presence(), + e.numeric('presence_sensitivity', ea.STATE_SET).withValueMin(0).withValueMax(100).withValueStep(1).withUnit('%') + .withDescription('Presence sensitivity'), + e.numeric('detection_range', ea.STATE_SET).withValueMin(1.5).withValueMax(4.5).withValueStep(0.1).withUnit('m') + .withDescription('Detection range'), + e.numeric('detection_delay', ea.STATE_SET).withValueMin(1).withValueMax(600).withValueStep(1).withUnit('s') + .withDescription('Presence detection delay'), + e.numeric('illuminance_treshold_max', ea.STATE_SET).withValueMin(0).withValueMax(2000).withValueStep(1).withUnit('lx') + .withDescription('The max illumiance threshold to turn on the light'), + e.numeric('illuminance_treshold_min', ea.STATE_SET).withValueMin(0).withValueMax(2000).withValueStep(1).withUnit('lx') + .withDescription('The min illumiance threshold to turn on the light'), + e.binary('presence_illuminance_switch', ea.STATE_SET, true, false).withDescription( + `Whether to enable 'light_switch' illumination is between min/max threshold`), + e.binary('light_switch', ea.STATE, 'ON', 'OFF').withDescription( + 'This state will determine the light on/off based on the lighting threshold and presence sensing'), + e.binary('light_linkage', ea.STATE_SET, true, false).withDescription('Light linkage'), + e.enum('detection_method', ea.STATE_SET, ['only_move', 'exist_move']).withDescription( + `When 'only_move' is used, presence will only be triggered when there is movement`), + e.enum('indicator_light', ea.STATE_SET, ['presence', 'off', 'on']).withDescription('Controls when the indicator light is turned on'), + e.binary('identify', ea.STATE_SET, true, false) + .withDescription('After turning on, the indicator light quickly flashes, used to locate devices'), + ], + meta: { + tuyaDatapoints: [ + [1, 'presence', tuya.valueConverter.trueFalse1], + [2, 'presence_sensitivity', tuya.valueConverter.raw], + [4, 'detection_range', tuya.valueConverter.divideBy10], + [101, 'illuminance', tuya.valueConverter.raw], + [102, 'illuminance_treshold_max', tuya.valueConverter.raw], + [103, 'illuminance_treshold_min', tuya.valueConverter.raw], + [104, 'detection_delay', tuya.valueConverter.raw], + [109, 'presence_illuminance_switch', tuya.valueConverter.trueFalseEnum1], + [105, 'light_switch', tuya.valueConverter.onOff], + [106, 'light_linkage', tuya.valueConverter.trueFalseEnum1], + [107, 'indicator_light', tuya.valueConverterBasic.lookup({'presence': tuya.enum(0), 'off': tuya.enum(1), 'on': tuya.enum(2)})], + [108, 'detection_method', tuya.valueConverterBasic.lookup({'only_move': tuya.enum(0), 'exist_move': tuya.enum(1)})], + [113, 'find_switch', tuya.valueConverter.raw], + ], + }, + }, { fingerprint: tuya.fingerprint('TS0601', ['_TZE204_sbyx0lm6', '_TZE204_clrdrnya', '_TZE204_dtzziy1e']), model: 'MTG075-ZB-RL', diff --git a/src/lib/tuya.ts b/src/lib/tuya.ts index 1fae0b4cebcfa..0d5baa2e32bc2 100644 --- a/src/lib/tuya.ts +++ b/src/lib/tuya.ts @@ -865,6 +865,8 @@ const tuyaTz = { 'eco_mode', 'max_temperature_limit', 'min_temperature_limits', 'manual_modes', 'medium_motion_detection_sensitivity', 'small_detection_distance', 'small_detection_sensitivity', 'switch_type', 'ph_max', 'ph_min', 'ec_max', 'ec_min', 'orp_max', 'orp_min', 'free_chlorine_max', 'free_chlorine_min', 'target_distance', + 'illuminance_treshold_max', 'illuminance_treshold_min', 'presence_illuminance_switch', 'light_switch', 'light_linkage', + 'indicator_light', 'find_switch', 'detection_method', ], convertSet: async (entity, key, value, meta) => { // A set converter is only called once; therefore we need to loop