From 1a9248be413f680fe1794a7f850581573f918a98 Mon Sep 17 00:00:00 2001 From: Jonas Rodrigues Da Rocha Date: Fri, 22 Sep 2023 18:31:45 -0300 Subject: [PATCH] feat: implements mode UV nano for air conditioner RAC_056905_WW --- .../smartthinq_sensors/switch.py | 7 ++++++ .../smartthinq_sensors/wideq/const.py | 1 + .../smartthinq_sensors/wideq/devices/ac.py | 24 +++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/custom_components/smartthinq_sensors/switch.py b/custom_components/smartthinq_sensors/switch.py index ee4b4fdc..a81a3cf8 100644 --- a/custom_components/smartthinq_sensors/switch.py +++ b/custom_components/smartthinq_sensors/switch.py @@ -113,6 +113,13 @@ class ThinQSwitchEntityDescription(SwitchEntityDescription): turn_off_fn=lambda x: x.device.set_lighting_display(False), turn_on_fn=lambda x: x.device.set_lighting_display(True), ), + ThinQSwitchEntityDescription( + key=AirConditionerFeatures.MODE_UN_NANO, + name="UV Nano", + icon="mdi:alpha-u-box-outline", + turn_off_fn=lambda x: x.device.set_uv_nano(False), + turn_on_fn=lambda x: x.device.set_uv_nano(True), + ), ThinQSwitchEntityDescription( key=AirConditionerFeatures.MODE_AWHP_SILENT, name="Silent mode", diff --git a/custom_components/smartthinq_sensors/wideq/const.py b/custom_components/smartthinq_sensors/wideq/const.py index fa35f9b7..37b34df7 100644 --- a/custom_components/smartthinq_sensors/wideq/const.py +++ b/custom_components/smartthinq_sensors/wideq/const.py @@ -45,6 +45,7 @@ class AirConditionerFeatures(StrEnum): ROOM_TEMP = "room_temperature" WATER_IN_TEMP = "water_in_temperature" WATER_OUT_TEMP = "water_out_temperature" + MODE_UN_NANO = "mode_un_nano" class AirPurifierFeatures(StrEnum): diff --git a/custom_components/smartthinq_sensors/wideq/devices/ac.py b/custom_components/smartthinq_sensors/wideq/devices/ac.py index 608affe8..43790d19 100644 --- a/custom_components/smartthinq_sensors/wideq/devices/ac.py +++ b/custom_components/smartthinq_sensors/wideq/devices/ac.py @@ -62,6 +62,7 @@ STATE_MODE_AIRCLEAN = ["AirClean", "airState.wMode.airClean"] STATE_MODE_JET = ["Jet", "airState.wMode.jet"] STATE_LIGHTING_DISPLAY = ["DisplayControl", "airState.lightingState.displayControl"] +STATE_UV_NANO = ["UVNano", "airState.miscFuncState.Uvnano"] STATE_RESERVATION_SLEEP_TIME = ["SleepTime", "airState.reservation.sleepTime"] FILTER_TYPES = [ @@ -89,6 +90,7 @@ CMD_STATE_MODE_AIRCLEAN = [CTRL_BASIC, "Set", STATE_MODE_AIRCLEAN] CMD_STATE_MODE_JET = [CTRL_BASIC, "Set", STATE_MODE_JET] CMD_STATE_LIGHTING_DISPLAY = [CTRL_BASIC, "Set", STATE_LIGHTING_DISPLAY] +CMD_STATE_UV_NANO = [CTRL_BASIC, "Set", STATE_UV_NANO] CMD_RESERVATION_SLEEP_TIME = [CTRL_BASIC, "Set", STATE_RESERVATION_SLEEP_TIME] # AWHP Section @@ -127,6 +129,9 @@ LIGHTING_DISPLAY_OFF = "0" LIGHTING_DISPLAY_ON = "1" +UV_NANO_OFF = "0" +UV_NANO_ON = "1" + MODE_OFF = "@OFF" MODE_ON = "@ON" @@ -805,6 +810,12 @@ async def set_lighting_display(self, status: bool): lighting = LIGHTING_DISPLAY_ON if status else LIGHTING_DISPLAY_OFF await self.set(keys[0], keys[1], key=keys[2], value=lighting) + async def set_uv_nano(self, status: bool): + """Set the lighting display on or off.""" + keys = self._get_cmd_keys(CMD_STATE_UV_NANO) + state = UV_NANO_ON if status else UV_NANO_OFF + await self.set(keys[0], keys[1], key=keys[2], value=state) + async def set_mode_awhp_silent(self, value: bool): """Set the AWHP silent mode on or off.""" if not self.is_air_to_water: @@ -1219,6 +1230,18 @@ def lighting_display(self): False, ) + @property + def mode_uv_nano(self): + """Return display lighting status.""" + key = self._get_state_key(STATE_UV_NANO) + if (value := self.to_int_or_none(self._data.get(key))) is None: + return None + return self._update_feature( + AirConditionerFeatures.MODE_UN_NANO, + str(value) == UV_NANO_ON, + False, + ) + @property def filters_life(self): """Return percentage status for all filters.""" @@ -1338,6 +1361,7 @@ def _update_features(self): self.mode_airclean, self.mode_jet, self.lighting_display, + self.mode_uv_nano, self.water_in_current_temp, self.water_out_current_temp, self.mode_awhp_silent,