local device = {} device.model = "RB-SRAIN01" device.vendor = "Tuya" device.description = "Solar rain sensor" device.exposes = { { type = "numeric", name = "illuminance_raw", property = "illuminance_raw", access = 1, unit = "mV", description = "Raw measured illuminance", }, { type = "numeric", name = "illuminance_average_20min", property = "illuminance_average_20min", access = 1, unit = "mV", description = "Illuminance average for the last 20 minutes", }, { type = "numeric", name = "illuminance_maximum_today", property = "illuminance_maximum_today", access = 1, unit = "mV", description = "Illuminance maximum for the last 24 hours", }, { type = "binary", name = "cleaning_reminder", property = "cleaning_reminder", access = 1, value_on = true, value_off = false, description = "Cleaning reminder", }, { type = "numeric", name = "rain_intensity", property = "rain_intensity", access = 1, unit = "mV", description = "Rainfall intensity", }, { type = "binary", name = "rain", property = "rain", access = 1, value_on = true, value_off = false, description = "Indicates whether the device detected rainfall", }, { type = "numeric", name = "battery", property = "battery", access = 5, unit = "%", min = 0, max = 100, description = "Remaining battery in %", category = "diagnostic", }, { 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", }, { 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", }, } device.fromZigbee = { "ias_zone", "battery" } device.tuyaDatapoints = { { dp = 4, name = "battery", converter = "raw" }, { dp = 101, name = "illuminance_raw", converter = "raw" }, { dp = 102, name = "illuminance_average_20min", converter = "raw" }, { dp = 103, name = "illuminance_maximum_today", converter = "raw" }, { dp = 104, name = "cleaning_reminder", converter = "trueFalse0" }, { dp = 105, name = "rain_intensity", converter = "raw" }, } device.configure = { bind = { "ssIasZone", "genPowerCfg" }, reporting = { { cluster = "genPowerCfg", attribute = "batteryPercentageRemaining", min = 3600, max = 65000, change = 0, }, { cluster = "genPowerCfg", attribute = "batteryVoltage", min = 3600, max = 65000, change = 0, }, }, } device.fingerprint = { { model = "TS0207", manufacturer = "_TZ3210_tgvtvdoc", }, { model = "TS0207", manufacturer = "_TZ3210_p68kms0l", }, } return device