-
-
Save sweepy-77/772f25eb2efca35689a5309377d0da93 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 extend = require('zigbee-herdsman-converters/lib/extend'); | |
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, 'minitemp_set', 'maxtemp_set', 'minihum_set', 'maxhum_set', 'temp_unit_convert', 'temp_periodic_report', 'hum_periodic_report'], | |
} | |
const definition = { | |
fingerprint: tuya.fingerprint('TS0601', ['_TZE200_vvmbj46n']), | |
model: 'TS0601_temperature_humidity_sensor_2', | |
vendor: 'TuYa', | |
description: 'Temperature and humidity sensor', | |
fromZigbee: [tuya.fz.datapoints], | |
toZigbee: [tzDatapoints], | |
onEvent: tuya.onEvent({queryOnDeviceAnnounce: true}), | |
configure: async (device, coordinatorEndpoint, logger) => { | |
await tuya.configureMagicPacket(device, coordinatorEndpoint, logger); | |
// Required to get the device to start reporting | |
await device.getEndpoint(1).command('manuSpecificTuya', 'dataQuery', {}); | |
}, | |
exposes: [e.temperature(), e.humidity(), | |
e.battery(), | |
e.enum('temp_unit_convert', ea.STATE_SET, ['celsius', 'fahrenheit']).withDescription('Temperature unit'), | |
e.numeric('maxtemp_set', ea.STATE_SET).withUnit('°C').withValueMin(-20).withValueMax(60).withDescription('Alarm temperature max'), | |
e.numeric('minitemp_set', ea.STATE_SET).withUnit('°C').withValueMin(-20).withValueMax(60).withDescription('Alarm temperature min'), | |
e.numeric('maxhum_set', ea.STATE_SET).withUnit('%').withValueMin(0).withValueMax(100).withDescription('Alarm humidity max'), | |
e.numeric('minihum_set', ea.STATE_SET).withUnit('%').withValueMin(0).withValueMax(100).withDescription('Alarm humidity min'), | |
e.enum('temp_alarm', ea.STATE_SET, ['lower alarm', 'upper alarm', 'cancel']).withDescription('Temperature alarm'), | |
e.enum('hum_alarm', ea.STATE_SET, ['lower alarm', 'upper alarm', 'cancel']).withDescription('Humidity alarm'), | |
e.numeric('temp_periodic_report', ea.STATE_SET).withUnit('%').withValueMin(0).withValueMax(100).withDescription('Temp periodic report'), | |
e.numeric('hum_periodic_report', ea.STATE_SET).withUnit('%').withValueMin(0).withValueMax(100).withDescription('Humidity periodic report'), | |
e.numeric('temp_sensitivity', ea.STATE_SET).withUnit('°C').withValueMin(3).withValueMax(10).withValueStep(1).withDescription('Sensitivity of temperature'), | |
e.numeric('hum_sensitivity', ea.STATE_SET).withUnit('%').withValueMin(3).withValueMax(10).withValueStep(1).withDescription('Sensitivity of humidity'), | |
], | |
meta: { | |
tuyaDatapoints: [ | |
[1, 'temperature', tuya.valueConverter.divideBy10], | |
[2, 'humidity', tuya.valueConverter.raw], | |
[4, 'battery', tuya.valueConverter.raw], | |
[9, 'temp_unit_convert', tuya.valueConverter.temperatureUnitEnum], | |
[10, 'maxtemp_set', tuya.valueConverter.divideBy10], | |
[11, 'minitemp_set', tuya.valueConverter.divideBy10], | |
[12, 'maxhum_set', tuya.valueConverter.raw], | |
[13, 'minihum_set', tuya.valueConverter.raw], | |
[14, 'temp_alarm', tuya.valueConverterBasic.lookup({'lower alarm' : tuya.enum(0), 'upper alarm' : tuya.enum(1), 'cancel' : tuya.enum(2)})], | |
[15, 'hum_alarm', tuya.valueConverterBasic.lookup({'lower alarm' : tuya.enum(0), 'upper alarm' : tuya.enum(1), 'cancel' : tuya.enum(2)})], | |
[17, 'temp_periodic_report', tuya.valueConverter.raw], | |
[18, 'hum_periodic_report', tuya.valueConverter.raw], | |
[19, 'temp_sensitivity', tuya.valueConverter.raw], | |
[20, 'hum_sensitivity', tuya.valueConverter.raw], | |
], | |
}, | |
whiteLabel: [ | |
tuya.whitelabel('TuYa', 'ZTH05Z', 'Temperature and humidity sensor', ['_TZE200_vvmbj46n']), | |
], | |
}; | |
module.exports = definition; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment