local device = {} device.model = "TS0601_bed_presence_sensor" device.vendor = "Tuya" device.description = "Pressure Sensing Strap/Bed 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 = "numeric", name = "illuminance", property = "illuminance", access = 1, unit = "lux", min = 0, max = 10000, value_step = 1, description = "Raw pressure value", }, { type = "enum", name = "sensitivity", property = "sensitivity", access = 7, description = "Sensitivity", values = { "low", "middle", "high" }, }, { type = "numeric", name = "interval_time", property = "interval_time", access = 7, unit = "min", min = 5, max = 720, value_step = 5, description = "Sampling interval", }, { type = "numeric", name = "presence_delay", property = "presence_delay", access = 7, unit = "s", min = 0, max = 3600, value_step = 1, description = "Delay to report no presence", }, { type = "numeric", name = "presence_time", property = "presence_time", access = 7, unit = "s", min = 0, max = 3600, value_step = 1, description = "Delay to report presence", }, { type = "enum", name = "work_state", property = "work_state", access = 1, description = "Summary of the state of the device", values = { "presence", "none", "presence_5min", "presence_30min", "none_5min", "none_30min" }, }, { 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", "illuminance" } device.tuyaDatapoints = { { dp = 1, name = "occupancy", converter = "trueFalse0" }, { dp = 4, name = "battery", converter = "raw" }, { dp = 9, name = "sensitivity", converter = "lookup", lookup = { low = 0, middle = 1, high = 2 } }, { dp = 12, name = "illuminance", converter = "raw" }, { dp = 101, name = "interval_time", converter = "raw" }, { dp = 102, name = "presence_delay", converter = "raw" }, { dp = 103, name = "presence_time", converter = "raw" }, { dp = 104, name = "work_state", converter = "lookup", lookup = { presence = 0, none = 1, presence_5min = 2, presence_30min = 3, none_5min = 4, none_30min = 5 } }, } device.configure = { bind = { "msOccupancySensing", "ssIasZone", "genPowerCfg", "msIlluminanceMeasurement" }, 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, }, { cluster = "msIlluminanceMeasurement", attribute = "measuredValue", min = 10, max = 3600, change = 5, }, }, } device.fingerprint = { { model = "TS0601", manufacturer = "_TZE200_seq9cm6u", }, } return device