local device = {} device.model = "TS0601_soil_2" device.vendor = "Tuya" device.description = "Soil sensor" device.exposes = { { type = "numeric", name = "soil_moisture", property = "soil_moisture", access = 1, unit = "%", description = "Measured soil moisture value", }, { type = "numeric", name = "temperature", property = "temperature", access = 1, unit = "°C", min = -10, max = 60, description = "Soil temperature", }, { type = "numeric", name = "temperature_f", property = "temperature_f", access = 1, unit = "°F", min = 14, max = 140, description = "Soil temperature", }, { type = "numeric", name = "temperature_sensitivity", property = "temperature_sensitivity", access = 3, unit = "°C", min = 0.3, max = 1, value_step = 0.1, description = "Temperature sensitivity", }, { type = "numeric", name = "humidity_sensitivity", property = "humidity_sensitivity", access = 3, unit = "%", min = 1, max = 5, description = "Humidity sensitivity", }, { type = "enum", name = "temperature_alarm", property = "temperature_alarm", access = 1, description = "Temperature alarm state", values = { "lower_alarm", "upper_alarm", "cancel" }, }, { type = "enum", name = "humidity_alarm", property = "humidity_alarm", access = 1, description = "Humidity alarm state", values = { "lower_alarm", "upper_alarm", "cancel" }, }, { type = "numeric", name = "max_temperature_alarm", property = "max_temperature_alarm", access = 3, unit = "°C", min = 0, max = 60, description = "Upper temperature limit", }, { type = "numeric", name = "min_temperature_alarm", property = "min_temperature_alarm", access = 3, unit = "°C", min = 0, max = 60, description = "Lower temperature limit", }, { type = "numeric", name = "max_humidity_alarm", property = "max_humidity_alarm", access = 3, unit = "%", min = 0, max = 100, description = "Upper humidity limit", }, { type = "numeric", name = "min_humidity_alarm", property = "min_humidity_alarm", access = 3, unit = "%", min = 0, max = 100, description = "Lower humidity limit", }, { type = "numeric", name = "schedule_periodic", property = "schedule_periodic", access = 3, unit = "min", min = 5, max = 60, description = "Report sensitivity", }, { 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 = "battery_state", property = "battery_state", access = 1, description = "State of the battery", values = { "low", "medium", "high" }, }, } device.fromZigbee = { "temperature", "battery" } device.tuyaDatapoints = { { dp = 101, name = "temperature_alarm", converter = "lookup", lookup = { lower_alarm = 0, upper_alarm = 1, cancel = 2 } }, { dp = 102, name = "humidity_alarm", converter = "lookup", lookup = { lower_alarm = 0, upper_alarm = 1, cancel = 2 } }, { dp = 3, name = "soil_moisture", converter = "raw" }, { dp = 5, name = "temperature", converter = "divideBy10" }, { dp = 110, name = "temperature_f", converter = "divideBy10" }, { dp = 107, name = "temperature_sensitivity", converter = "divideBy10" }, { dp = 108, name = "humidity_sensitivity", converter = "raw" }, { dp = 103, name = "max_temperature_alarm", converter = "divideBy10" }, { dp = 104, name = "min_temperature_alarm", converter = "divideBy10" }, { dp = 105, name = "max_humidity_alarm", converter = "raw" }, { dp = 106, name = "min_humidity_alarm", converter = "raw" }, { dp = 109, name = "schedule_periodic", converter = "raw" }, { dp = 15, name = "battery", converter = "raw" }, { dp = 14, name = "battery_state", converter = "batteryState" }, } device.configure = { bind = { "msTemperatureMeasurement", "genPowerCfg" }, reporting = { { cluster = "msTemperatureMeasurement", 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, }, }, } device.fingerprint = { { model = "TS0601", manufacturer = "_TZE284_g2e6cpnw", }, { model = "TS0601", manufacturer = "_TZE284_sgabhwa6", }, { model = "TS0601", manufacturer = "_TZE284_awepdiwi", }, } return device