local device = {} device.model = "TS0601_water_valve" device.vendor = "Tuya" device.description = "Ultrasonic water meter valve" device.exposes = { { type = "switch", features = { { type = "binary", name = "state", property = "state", access = 3, value_on = "ON", value_off = "OFF", description = "On/off state of the switch", }, }, }, { type = "numeric", name = "water_consumed", property = "water_consumed", access = 1, unit = "L", min = 0, value_step = 0.001, description = "Total water consumption", }, { type = "numeric", name = "reverse_water_consumed", property = "reverse_water_consumed", access = 1, unit = "L", min = 0, value_step = 0.001, description = "Total reverse water consumption", }, { type = "numeric", name = "month_consumption", property = "month_consumption", access = 1, unit = "L", min = 0, value_step = 0.001, description = "month consumption", }, { type = "numeric", name = "daily_consumption", property = "daily_consumption", access = 1, unit = "L", min = 0, value_step = 0.001, description = "daily consumption", }, { type = "numeric", name = "flow_rate", property = "flow_rate", access = 1, unit = "L/h", description = "Instantaneous water flow rate", }, { type = "binary", name = "auto_clean", property = "auto_clean", access = 3, value_on = "ON", value_off = "OFF", description = "Auto clean", }, { type = "numeric", name = "temperature", property = "temperature", access = 1, unit = "°C", description = "Measured temperature value", }, { type = "numeric", name = "voltage", property = "voltage", access = 1, unit = "mV", description = "Voltage of the battery in millivolts", category = "diagnostic", }, { type = "text", name = "meter_id", property = "meter_id", access = 1, description = "Meter identification number", }, { type = "text", name = "faults", property = "faults", access = 1, description = "Active fault status", }, { type = "enum", name = "report_period", property = "report_period", access = 3, description = "Report period", values = { "1h", "2h", "3h", "4h", "6h", "8h", "12h", "24h", }, }, } device.fromZigbee = { "temperature", "electrical" } device.tuyaDatapoints = { { dp = 1, name = "water_consumed", converter = "raw" }, { dp = 4, name = "report_period", converter = "lookup", lookup = { 1h = 0, 2h = 1, 3h = 2, 4h = 3, 6h = 4, 8h = 5, 12h = 6, 24h = 7 } }, { dp = 13, name = "state", converter = "onOffNotStrict" }, { dp = 14, name = "auto_clean", converter = "onOff" }, { dp = 16, name = "meter_id", converter = "raw" }, { dp = 22, name = "temperature", converter = "divideBy100" }, { dp = 26, name = "battery_voltage", converter = "divideBy100" }, } device.configure = { bind = { "msTemperatureMeasurement", "haElectricalMeasurement" }, reporting = { { cluster = "msTemperatureMeasurement", attribute = "measuredValue", min = 10, max = 3600, change = 100, }, { cluster = "haElectricalMeasurement", attribute = "activePower", min = 5, max = 3600, change = 1, }, { cluster = "haElectricalMeasurement", attribute = "rmsVoltage", min = 5, max = 3600, change = 5, }, { cluster = "haElectricalMeasurement", attribute = "rmsCurrent", min = 5, max = 3600, change = 100, }, }, } device.fingerprint = { { model = "TS0601", manufacturer = "_TZE284_vuwtqx0t", }, { model = "TS0601", manufacturer = "_TZE200_vuwtqx0t", }, } return device