local device = {} device.model = "ZG-303Z" device.vendor = "HOBEIAN" device.description = "Soil moisture sensor" device.exposes = { { type = "enum", name = "water_warning", property = "water_warning", access = 1, description = "Water shortage warning", values = { "none", "alarm" }, }, { 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 = "soil_moisture", property = "soil_moisture", access = 1, unit = "%", description = "Measured soil moisture value", }, { type = "enum", name = "temperature_unit", property = "temperature_unit", access = 3, description = "Temperature unit", values = { "celsius", "fahrenheit" }, }, { type = "numeric", name = "temperature_calibration", property = "temperature_calibration", access = 3, unit = "°C", min = -2, max = 2, value_step = 0.1, description = "Temperature calibration", }, { type = "numeric", name = "humidity_calibration", property = "humidity_calibration", access = 3, unit = "%", min = -30, max = 30, value_step = 1, description = "Humidity calibration", }, { type = "numeric", name = "soil_calibration", property = "soil_calibration", access = 3, unit = "%", min = -30, max = 30, value_step = 1, description = "Soil Humidity calibration", }, { type = "numeric", name = "temperature_sampling", property = "temperature_sampling", access = 3, unit = "s", min = 5, max = 3600, value_step = 1, description = "Air temperature and humidity sampling", }, { type = "numeric", name = "soil_sampling", property = "soil_sampling", access = 3, unit = "s", min = 5, max = 3600, value_step = 1, description = "Soil humidity sampling", }, { type = "numeric", name = "soil_warning", property = "soil_warning", access = 3, unit = "%", min = 0, max = 100, value_step = 1, description = "Soil water shortage humidity value", }, { 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", }, } device.fromZigbee = { "temperature", "humidity", "battery" } device.tuyaDatapoints = { { dp = 1, name = "water_warning", converter = "lookup", lookup = { none = 0, alarm = 1 } }, { dp = 103, name = "temperature", converter = "divideBy10" }, { dp = 109, name = "humidity", converter = "raw" }, { dp = 107, name = "soil_moisture", converter = "raw" }, { dp = 108, name = "battery", converter = "raw" }, { dp = 106, name = "temperature_unit", converter = "temperatureUnit" }, { dp = 104, name = "temperature_calibration", converter = "localTempCalibration3" }, { dp = 105, name = "humidity_calibration", converter = "localTempCalibration2" }, { dp = 102, name = "soil_calibration", converter = "localTempCalibration2" }, { dp = 111, name = "temperature_sampling", converter = "raw" }, { dp = 112, name = "soil_sampling", converter = "raw" }, { dp = 110, name = "soil_warning", converter = "raw" }, } device.configure = { bind = { "msTemperatureMeasurement", "msRelativeHumidity", "genPowerCfg" }, 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, }, }, } device.fingerprint = { { model = "TS0601", manufacturer = "_TZE200_wqashyqo", }, } return device