local device = {} device.model = "TS0601_pir_solar" device.vendor = "Tuya" device.description = "Solar PIR occupancy sensor" device.exposes = { { type = "binary", name = "occupancy", property = "occupancy", access = 1, value_on = true, value_off = false, description = "Indicates whether the device detected occupancy", }, { 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 = "enum", name = "pir_sensitivity", property = "pir_sensitivity", access = 3, description = "PIR sensitivity (0=high, 1=low)", values = { "high", "low" }, }, { 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 = { "occupancy", "ias_zone", "battery" } device.tuyaDatapoints = { { dp = 1, name = "occupancy", converter = "trueFalse0" }, { dp = 4, name = "battery", converter = "raw" }, { dp = 9, name = "pir_sensitivity", converter = "lookup", lookup = { high = 0, low = 1 } }, } device.configure = { bind = { "msOccupancySensing", "ssIasZone", "genPowerCfg" }, reporting = { { cluster = "msOccupancySensing", attribute = "occupancy", min = 0, max = 3600, change = 0, }, { cluster = "genPowerCfg", attribute = "batteryPercentageRemaining", min = 3600, max = 65000, change = 0, }, { cluster = "genPowerCfg", attribute = "batteryVoltage", min = 3600, max = 65000, change = 0, }, }, } device.fingerprint = { { model = "TS0601", manufacturer = "_TZE284_tre6haif", }, } return device