local device = {} device.model = "TS0601_temperature_humidity_sensor_1" device.vendor = "Tuya" device.description = "Temperature & humidity sensor" device.fingerprint = { { model = "TS0601", manufacturer = "_TZE200_bq5c8xfe", }, { model = "TS0601", manufacturer = "_TZE200_qyflbnbj", }, { model = "TS0601", manufacturer = "_TZE200_44af8vyi", }, { model = "TS0601", manufacturer = "_TZE204_qyflbnbj", }, { model = "TS0601", manufacturer = "_TZE284_qyflbnbj", }, } device.exposes = { { type = "numeric", name = "temperature", property = "temperature", access = 1, unit = "°C", description = "Measured temperature value", }, { type = "numeric", name = "humidity", property = "humidity", access = 1, unit = "%", description = "Measured relative humidity", }, { type = "numeric", name = "battery", property = "battery", access = 1, unit = "%", min = 0, max = 100, description = "Remaining battery in %, can take up to 24 hours before reported", category = "diagnostic", }, { type = "binary", name = "battery_low", property = "battery_low", access = 1, value_on = true, value_off = false, description = "Indicates if the battery of this device is almost empty", category = "diagnostic", }, { type = "enum", name = "battery_level", property = "battery_level", access = 1, description = "Battery level state", values = { "low", "middle", "high" }, }, { type = "binary", name = "occupancy", property = "occupancy", access = 1, value_on = true, value_off = false, description = "Indicates whether the device detected occupancy", }, { type = "binary", name = "contact", property = "contact", access = 1, value_on = false, value_off = true, description = "Indicates if the contact is closed or open", }, { type = "binary", name = "tamper", property = "tamper", access = 1, value_on = true, value_off = false, description = "Indicates whether the device is tampered", }, } device.fromZigbee = { "temperature", "humidity", "battery", "ias_zone" } device.tuyaDatapoints = { { dp = 1, name = "temperature", converter = "divideBy10" }, { dp = 2, name = "humidity", converter = "raw" }, { dp = 3, name = "battery_level", converter = "lookup", lookup = { low = 0, middle = 1, high = 2 } }, { dp = 4, name = "battery", converter = "raw" }, } device.configure = { bind = { "msTemperatureMeasurement", "msRelativeHumidity", "genPowerCfg", "ssIasZone" }, 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, }, }, } return device