Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new tuya sensor #6084

Merged
merged 11 commits into from
Aug 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 98 additions & 20 deletions src/devices/tuya.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4296,7 +4296,7 @@ const definitions: Definition[] = [
},
{
fingerprint: tuya.fingerprint('TS0225', ['_TZE200_hl0ss9oa']),
model: 'TS0225',
model: 'ZG-205ZL',
vendor: 'TuYa',
description: '24Ghz human presence sensor',
fromZigbee: [tuya.fz.datapoints],
Expand All @@ -4305,7 +4305,7 @@ const definitions: Definition[] = [
e.presence(),
e.enum('motion_state', ea.STATE, ['none', 'large', 'small', 'static']).withDescription('Motion state'),
e.illuminance_lux(),
e.numeric('fading_time', ea.STATE_SET).withValueMin(0).withValueMax(600).withValueStep(1).withUnit('s')
e.numeric('fading_time', ea.STATE_SET).withValueMin(0).withValueMax(3600).withValueStep(1).withUnit('s')
.withDescription('Presence keep time'),
e.numeric('large_motion_detection_distance', ea.STATE_SET).withValueMin(0).withValueMax(10).withValueStep(0.01).withUnit('m')
.withDescription('Large motion detection distance'),
Expand All @@ -4319,7 +4319,7 @@ const definitions: Definition[] = [
.withDescription('Static detection distance'),
e.numeric('static_detection_sensitivity', ea.STATE_SET).withValueMin(0).withValueMax(10).withValueStep(1).withUnit('x')
.withDescription('Static detection sensitivity'),
e.enum('mode', ea.STATE_SET, ['off', 'arm', 'alarm']).withDescription('Alarm mode'),
e.enum('mode', ea.STATE_SET, ['off', 'arm', 'alarm', 'doorbell']).withDescription('Working mode'),
e.enum('alarm_volume', ea.STATE_SET, ['mute', 'low', 'medium', 'high']).withDescription('Alarm volume'),
e.numeric('alarm_time', ea.STATE_SET).withValueMin(1).withValueMax(60).withValueStep(1).withUnit('m').withDescription('Alarm time'),
e.binary('light_mode', ea.STATE_SET, 'ON', 'OFF').withDescription('LED indicator mode'),
Expand All @@ -4338,7 +4338,8 @@ const definitions: Definition[] = [
[16, 'small_motion_detection_sensitivity', tuya.valueConverter.raw],
[103, 'static_detection_distance', tuya.valueConverter.divideBy100],
[104, 'static_detection_sensitivity', tuya.valueConverter.raw],
[105, 'mode', tuya.valueConverterBasic.lookup({'arm': tuya.enum(0), 'off': tuya.enum(1), 'alarm': tuya.enum(2)})],
[105, 'mode', tuya.valueConverterBasic.lookup(
{'arm': tuya.enum(0), 'off': tuya.enum(1), 'alarm': tuya.enum(2), 'doorbell': tuya.enum(3)})],
[102, 'alarm_volume', tuya.valueConverterBasic.lookup({
'low': tuya.enum(0), 'medium': tuya.enum(1), 'high': tuya.enum(2), 'mute': tuya.enum(3),
})],
Expand Down Expand Up @@ -4378,21 +4379,7 @@ const definitions: Definition[] = [
.withDescription('Alarm humidity min'),
],
},
{
fingerprint: tuya.fingerprint('TS0601', ['_TZE200_3towulqd', '_TZE200_1ibpyhdc', '_TZE200_bh3n6gk8']),
model: 'ZG-204ZL',
vendor: 'TuYa',
description: 'Luminance motion sensor',
fromZigbee: [legacy.fromZigbee.ZG204ZL_lms],
toZigbee: [legacy.toZigbee.ZG204ZL_lms],
exposes: [
e.occupancy(), e.illuminance().withUnit('lx'), e.battery(),
e.enum('sensitivity', ea.ALL, ['low', 'medium', 'high'])
.withDescription('PIR sensor sensitivity (refresh and update only while active)'),
e.enum('keep_time', ea.ALL, ['10', '30', '60', '120'])
.withDescription('PIR keep time in seconds (refresh and update only while active)'),
],
},

{
fingerprint: [{modelID: 'TS004F', manufacturerName: '_TZ3000_kjfzuycl'},
{modelID: 'TS004F', manufacturerName: '_TZ3000_ja5osu5g'}],
Expand Down Expand Up @@ -4533,12 +4520,15 @@ const definitions: Definition[] = [
fromZigbee: [tuya.fz.datapoints],
toZigbee: [tuya.tz.datapoints],
configure: tuya.configureMagicPacket,
exposes: [e.contact(), e.illuminance().withUnit('lx'), e.battery()],
exposes: [e.contact(), e.illuminance().withUnit('lx'), e.battery(),
e.numeric('illuminance_interval', ea.STATE_SET).withValueMin(1).withValueMax(720).withValueStep(1).withUnit('minutes')
.withDescription('Brightness acquisition interval (refresh and update only while active)')],
meta: {
tuyaDatapoints: [
[1, 'contact', tuya.valueConverter.inverse],
[101, 'illuminance', tuya.valueConverter.raw],
[2, 'battery', tuya.valueConverter.raw],
[102, 'illuminance_interval', tuya.valueConverter.raw],
],
},
},
Expand All @@ -4558,6 +4548,94 @@ const definitions: Definition[] = [
],
},
},
{
fingerprint: tuya.fingerprint('TS0601', ['_TZE200_3towulqd', '_TZE200_1ibpyhdc', '_TZE200_bh3n6gk8']),
model: 'ZG-204ZL',
vendor: 'TuYa',
description: 'Luminance motion sensor',
fromZigbee: [tuya.fz.datapoints],
toZigbee: [tuya.tz.datapoints],
exposes: [
e.occupancy(), e.illuminance().withUnit('lx'), e.battery(),
e.enum('sensitivity', ea.STATE_SET, ['low', 'medium', 'high'])
.withDescription('PIR sensor sensitivity (refresh and update only while active)'),
e.enum('keep_time', ea.STATE_SET, ['10', '30', '60', '120'])
.withDescription('PIR keep time in seconds (refresh and update only while active)'),
e.numeric('illuminance_interval', ea.STATE_SET).withValueMin(1).withValueMax(720).withValueStep(1).withUnit('minutes')
.withDescription('Brightness acquisition interval (refresh and update only while active)'),
],
meta: {
tuyaDatapoints: [
[1, 'occupancy', tuya.valueConverter.trueFalse0],
[4, 'battery', tuya.valueConverter.raw],
[9, 'sensitivity', tuya.valueConverterBasic.lookup({'low': tuya.enum(0), 'medium': tuya.enum(1), 'high': tuya.enum(2)})],
[10, 'keep_time', tuya.valueConverterBasic.lookup(
{'10': tuya.enum(0), '30': tuya.enum(1), '60': tuya.enum(2), '120': tuya.enum(3)})],
[12, 'illuminance', tuya.valueConverter.raw],
[102, 'illuminance_interval', tuya.valueConverter.raw],

],
},
},
{
fingerprint: tuya.fingerprint('TS0225', ['_TZE200_2aaelwxk']),
model: 'ZG-205Z/A',
vendor: 'TuYa',
description: '24Ghz Human presence 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],
],
},
},
{
fingerprint: tuya.fingerprint('TS110E', ['_TZ3210_zxbtub8r', '_TZ3210_k1msuvg6']),
model: 'TS110E_1gang_1',
Expand Down
7 changes: 4 additions & 3 deletions src/lib/tuya.ts
Original file line number Diff line number Diff line change
Expand Up @@ -802,10 +802,11 @@ const tuyaTz = {
...[1, 2, 3, 4, 5, 6].map((no) => `schedule_slot_${no}`), 'minimum_range', 'maximum_range', 'detection_delay', 'fading_time',
'radar_sensitivity', 'entry_sensitivity', 'illumin_threshold', 'detection_range', 'shield_range', 'entry_distance_indentation',
'entry_filter_time', 'departure_delay', 'block_time', 'status_indication', 'breaker_mode', 'breaker_status',
'alarm', 'alarm_time', 'alarm_volume', 'type', 'volume', 'ringtone', 'duration',
'alarm', 'alarm_time', 'alarm_volume', 'type', 'volume', 'ringtone', 'duration', 'medium_motion_detection_distance',
'large_motion_detection_distance', 'large_motion_detection_sensitivity', 'small_motion_detection_distance',
'small_motion_detection_sensitivity', 'static_detection_distance', 'static_detection_sensitivity',
'motion_sensitivity', 'detection_distance_max', 'detection_distance_min', 'presence_sensitivity',
'small_motion_detection_sensitivity', 'static_detection_distance', 'static_detection_sensitivity', 'keep_time', 'indicator',
'motion_sensitivity', 'detection_distance_max', 'detection_distance_min', 'presence_sensitivity', 'sensitivity', 'illuminance_interval',
'medium_motion_detection_sensitivity', 'small_detection_distance', 'small_detection_sensitivity',
],
convertSet: async (entity, key, value, meta) => {
// A set converter is only called once; therefore we need to loop
Expand Down