local device = {} device.model = "AR331Pro" device.vendor = "Tuya" device.description = "Thermostatic radiator valve" device.exposes = { { 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 = "binary", name = "battery_status", property = "battery_status", access = 1, value_on = true, value_off = false, description = "Battery low warning", }, { type = "binary", name = "preheat", property = "preheat", access = 1, value_on = "ON", value_off = "OFF", description = "Preheat/boost active (read-only status; use boost_heating to control)", }, { type = "binary", name = "child_lock", property = "child_lock", access = 3, value_on = "LOCK", value_off = "UNLOCK", description = "Enables/disables physical input on the device", }, { type = "climate", features = { { type = "enum", name = "preset", property = "preset", access = 3, description = "Mode of this device (similar to system_mode)", values = { "auto", "manual", "holiday", "comfort", "eco", "standby" }, }, { type = "numeric", name = "current_heating_setpoint", property = "current_heating_setpoint", access = 3, unit = "°C", min = 5, max = 40, value_step = 0.5, description = "Temperature setpoint", }, { type = "numeric", name = "local_temperature", property = "local_temperature", access = 1, unit = "°C", description = "Current temperature measured on the device", }, { type = "numeric", name = "local_temperature_calibration", property = "local_temperature_calibration", access = 3, unit = "°C", min = -7, max = 7, value_step = 0.5, description = "Offset to add/subtract to the local temperature", }, { type = "enum", name = "running_state", property = "running_state", access = 1, description = "The current running state", values = { "idle", "heat" }, }, }, }, { type = "binary", name = "summer_mode", property = "summer_mode", access = 3, value_on = "ON", value_off = "OFF", description = "Summer mode: disables heating, valve stays closed. Frost protection temperature remains active as safety net.", }, { type = "enum", name = "heating_cooling_mode", property = "heating_cooling_mode", access = 3, description = "Heating or cooling mode. In cooling mode valve is closed, works as temperature and window/door sensor.", values = { "heat", "cool" }, }, { type = "numeric", name = "eco_temperature", property = "eco_temperature", access = 3, unit = "°C", min = 5, max = 20, value_step = 0.5, description = "Eco temperature", }, { type = "numeric", name = "comfort_temperature", property = "comfort_temperature", access = 3, unit = "°C", min = 5, max = 40, value_step = 0.5, description = "Comfort temperature", }, { type = "text", name = "holiday_time", property = "holiday_time", access = 3, description = "Holiday start and end in format YYYY/MM/DD HH:MM | YYYY/MM/DD HH:MM", }, { type = "numeric", name = "frost_protection_temperature", property = "frost_protection_temperature", access = 3, unit = "°C", min = 0, max = 15, value_step = 0.5, description = "Frost protection: valve opens below this temperature", }, { type = "binary", name = "boost_heating", property = "boost_heating", access = 3, value_on = "ON", value_off = "OFF", description = "Boost heating: the device will enter boost heating mode.", }, { type = "numeric", name = "boost_time", property = "boost_time", access = 3, unit = "min", min = 0, max = 1440, value_step = 30, description = "Boost duration in minutes", }, { type = "binary", name = "window_detection", property = "window_detection", access = 3, value_on = "ON", value_off = "OFF", description = "Enable open-window detection", }, { type = "binary", name = "window_open", property = "window_open", access = 1, value_on = "open", value_off = "closed", description = "Window is currently detected as", }, { type = "numeric", name = "window_temp", property = "window_temp", access = 3, unit = "°C", min = 5, max = 40, value_step = 0.5, description = "Window detection: temperature drop threshold", }, { type = "numeric", name = "window_delay", property = "window_delay", access = 3, unit = "min", min = 0, max = 1440, value_step = 1, description = "Window detection: delay before triggering (minutes)", }, { type = "numeric", name = "window_close_delay", property = "window_close_delay", access = 3, unit = "min", min = 0, max = 1440, value_step = 1, description = "Window detection: minimum open time before valve closes (minutes)", }, { type = "binary", name = "valve_state", property = "valve_state", access = 1, value_on = "open", value_off = "close", description = "Current valve state (read-only)", }, { type = "numeric", name = "fault_code", property = "fault_code", access = 1, description = "Fault code bitmap (bit 0: program_fault, bit 1: low_battery, bit 2: sensor_fault)", }, { type = "enum", name = "screen_orientation", property = "screen_orientation", access = 3, description = "Display orientation", values = { "up", "right", "down", "left" }, }, { type = "numeric", name = "display_brightness", property = "display_brightness", access = 3, min = 1, max = 7, value_step = 1, description = "Display brightness (1–7)", }, { type = "binary", name = "override_active", property = "override_active", access = 3, value_on = "ON", value_off = "OFF", description = "Temporary manual override active", }, { type = "numeric", name = "override_temperature", property = "override_temperature", access = 3, unit = "°C", min = 5, max = 40, value_step = 0.5, description = "Temporary manual override temperature", }, { type = "text", name = "schedule_monday", property = "schedule_monday", access = 3, description = "Schedule for monday, example: \"00:00/16.0 06:00/20.5 09:00/18.0 12:00/21.0 14:00/18.0 17:00/21.0 22:00/16.0 23:00/16.0\"", }, { type = "text", name = "schedule_tuesday", property = "schedule_tuesday", access = 3, description = "Schedule for tuesday, example: \"00:00/16.0 06:00/20.5 09:00/18.0 12:00/21.0 14:00/18.0 17:00/21.0 22:00/16.0 23:00/16.0\"", }, { type = "text", name = "schedule_wednesday", property = "schedule_wednesday", access = 3, description = "Schedule for wednesday, example: \"00:00/16.0 06:00/20.5 09:00/18.0 12:00/21.0 14:00/18.0 17:00/21.0 22:00/16.0 23:00/16.0\"", }, { type = "text", name = "schedule_thursday", property = "schedule_thursday", access = 3, description = "Schedule for thursday, example: \"00:00/16.0 06:00/20.5 09:00/18.0 12:00/21.0 14:00/18.0 17:00/21.0 22:00/16.0 23:00/16.0\"", }, { type = "text", name = "schedule_friday", property = "schedule_friday", access = 3, description = "Schedule for friday, example: \"00:00/16.0 06:00/20.5 09:00/18.0 12:00/21.0 14:00/18.0 17:00/21.0 22:00/16.0 23:00/16.0\"", }, { type = "text", name = "schedule_saturday", property = "schedule_saturday", access = 3, description = "Schedule for saturday, example: \"00:00/16.0 06:00/20.5 09:00/18.0 12:00/21.0 14:00/18.0 17:00/21.0 22:00/16.0 23:00/16.0\"", }, { type = "text", name = "schedule_sunday", property = "schedule_sunday", access = 3, description = "Schedule for sunday, example: \"00:00/16.0 06:00/20.5 09:00/18.0 12:00/21.0 14:00/18.0 17:00/21.0 22:00/16.0 23:00/16.0\"", }, } device.fromZigbee = { "battery" } device.tuyaDatapoints = { { dp = 1, name = "preheat", converter = "onOff" }, { dp = 2, name = "preset", converter = "lookup", lookup = { auto = 0, manual = 1, holiday = 2, eco = 3, comfort = 4, standby = 5 } }, { dp = 3, name = "running_state", converter = "lookup", lookup = { heat = 0, idle = 1 } }, { dp = 6, name = "battery", converter = "raw" }, { dp = 7, name = "child_lock", converter = "lookup" }, { dp = 14, name = "window_detection", converter = "onOff" }, { dp = 15, name = "window_open", converter = "lookup", lookup = { open = 0, closed = 1 } }, { dp = 16, name = "window_temp", converter = "divideBy10" }, { dp = 18, name = "display_brightness", converter = "raw" }, { dp = 35, name = "fault_code", converter = "raw" }, { dp = 47, name = "local_temperature_calibration", converter = "localTempCalibration3" }, { dp = 49, name = "valve_state", converter = "lookup", lookup = { open = 0, close = 1 } }, { dp = 101, name = "boost_heating", converter = "onOff" }, { dp = 103, name = "eco_temperature", converter = "divideBy10" }, { dp = 104, name = "comfort_temperature", converter = "divideBy10" }, { dp = 107, name = "frost_protection_temperature", converter = "divideBy10" }, { dp = 109, name = "heating_cooling_mode", converter = "lookup" }, { dp = 110, name = "battery_status", converter = "raw" }, { dp = 111, name = "screen_orientation", converter = "lookup", lookup = { up = 0, right = 90, down = 180 } }, { dp = 113, name = "summer_mode", converter = "onOff" }, { dp = 115, name = "override_active", converter = "onOff" }, } device.configure = { bind = { "genPowerCfg" }, reporting = { { 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_nbv4tdaz", }, } return device