local device = {} device.model = "TS0201-z" device.vendor = "Tuya" device.description = "Temperature & Humidity Sensor (pvxx/ZigbeeTLc)" device.zigbeeModel = { "TS0201-z", "TS0201-bz", "TH03Z-z", "TH03Z-bz", "ZTH01-z", "ZTH01-bz", "ZTH02-z", "ZTH02-bz", "ZY-ZTH02-z", } device.exposes = { { type = "numeric", name = "temperature", property = "temperature", access = 5, unit = "°C", description = "Measured temperature value", }, { type = "numeric", name = "humidity", property = "humidity", access = 5, unit = "%", description = "Measured relative humidity", }, { type = "numeric", name = "temperature_calibration", property = "temperature_calibration", access = 7, unit = "°C", min = -50, max = 50, value_step = 0.01, description = "Offset to add/subtract to the reported temperature (default 0°C).", }, { type = "numeric", name = "humidity_calibration", property = "humidity_calibration", access = 7, unit = "%", min = -50, max = 50, value_step = 0.01, description = "Offset to add/subtract to the reported relative humidity (default 0%).", }, { type = "numeric", name = "measurement_interval", property = "measurement_interval", access = 7, unit = "s", min = 3, max = 255, description = "Configure sensor measurement interval (default 10 seconds).", }, { type = "numeric", name = "battery", property = "battery", access = 5, unit = "%", min = 0, max = 100, description = "Remaining battery in %", category = "diagnostic", }, { type = "numeric", name = "voltage", property = "voltage", access = 5, unit = "mV", description = "Reported battery voltage in millivolts", category = "diagnostic", }, } device.fromZigbee = { "temperature", "humidity", "battery", "electrical" } device.configure = { bind = { "msTemperatureMeasurement", "msRelativeHumidity", "genPowerCfg", "haElectricalMeasurement" }, reporting = { { cluster = "msTemperatureMeasurement", attribute = "measuredValue", min = 10, max = 3600, change = 100, }, { cluster = "msRelativeHumidity", attribute = "measuredValue", min = 10, max = 3600, change = 100, }, { cluster = "genPowerCfg", attribute = "batteryPercentageRemaining", min = 3600, max = 65000, change = 0, }, { cluster = "genPowerCfg", attribute = "batteryVoltage", min = 3600, max = 65000, change = 0, }, { cluster = "haElectricalMeasurement", attribute = "activePower", min = 5, max = 3600, change = 1, }, { cluster = "haElectricalMeasurement", attribute = "rmsVoltage", min = 5, max = 3600, change = 5, }, { cluster = "haElectricalMeasurement", attribute = "rmsCurrent", min = 5, max = 3600, change = 100, }, }, } return device