local device = {} device.model = "TS0601_heat_meter" device.vendor = "Tuya" device.description = "Ultrasonic heat meter" device.exposes = { { type = "numeric", name = "water_consumed", property = "water_consumed", access = 1, unit = "m³", min = 0, value_step = 0.001, description = "Total water consumption", }, { type = "numeric", name = "monthly_water_consumption", property = "monthly_water_consumption", access = 1, unit = "m³", min = 0, value_step = 0.001, description = "Monthly water consumption", }, { type = "numeric", name = "daily_water_consumption", property = "daily_water_consumption", access = 1, unit = "m³", min = 0, value_step = 0.001, description = "Daily water consumption", }, { type = "enum", name = "report_period", property = "report_period", access = 3, description = "Report period", values = { "1h", "2h", "3h", "4h", "6h", "8h", "12h", "24h", "48h", "72h", }, }, { type = "text", name = "fault", property = "fault", access = 1, description = "Alarm event status", }, { type = "binary", name = "prepayment_switch", property = "prepayment_switch", access = 3, value_on = "ON", value_off = "OFF", description = "Cumulative metering switch", }, { type = "numeric", name = "cumulative_heat", property = "cumulative_heat", access = 1, unit = "kWh", min = 0, value_step = 0.01, description = "Cumulative heat", }, { type = "text", name = "meter_id", property = "meter_id", access = 1, description = "Meter identification number", }, { type = "numeric", name = "instantaneous_flow_rate", property = "instantaneous_flow_rate", access = 1, unit = "m³/h", min = 0, value_step = 0.001, description = "Instantaneous flow rate", }, { type = "numeric", name = "inlet_water_temperature", property = "inlet_water_temperature", access = 1, unit = "°C", min = 0, value_step = 0.01, description = "Inlet water temperature", }, { type = "numeric", name = "outlet_water_temperature", property = "outlet_water_temperature", access = 1, unit = "°C", min = 0, value_step = 0.01, description = "Outlet water temperature", }, { type = "numeric", name = "voltage", property = "voltage", access = 1, unit = "mV", description = "Voltage of the battery in millivolts", category = "diagnostic", }, } device.fromZigbee = { "electrical" } device.tuyaDatapoints = { { dp = 1, name = "water_consumed", converter = "divideBy1000" }, { dp = 2, name = "monthly_water_consumption", converter = "waterConsumption" }, { dp = 3, name = "daily_water_consumption", converter = "waterConsumption" }, { dp = 4, name = "report_period", converter = "lookup", lookup = { 1h = 0, 2h = 1, 3h = 2, 4h = 3, 6h = 4, 8h = 5, 12h = 6, 24h = 7, 48h = 8, 72h = 9 } }, { dp = 6, name = "prepayment_switch", converter = "onOff" }, { dp = 7, name = "cumulative_heat", converter = "divideBy100" }, { dp = 16, name = "meter_id", converter = "raw" }, { dp = 21, name = "inlet_water_temperature", converter = "divideBy100" }, { dp = 22, name = "outlet_water_temperature", converter = "divideBy100" }, { dp = 24, name = "battery_voltage", converter = "multiplyBy10" }, } device.configure = { bind = { "haElectricalMeasurement" }, reporting = { { 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 = "_TZE200_jt50ea5d", }, } return device