Skip to content

Commit

Permalink
fix: support AC of different current temp unit
Browse files Browse the repository at this point in the history
  • Loading branch information
rxwen committed Nov 6, 2023
1 parent 0f55c59 commit 505d4c5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion custom_components/terncy/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def new_entity(gateway, eid: str, description: TerncyEntityDescription):
K_AC_CURRENT_TEMPERATURE = "acCurrentTemperature" # 16~30
K_AC_TARGET_TEMPERATURE = "acTargetTemperature" # 16~30
K_AC_RUNNING = "acRunning" # 0 or 1
K_AC_TEMP_UNIT = "tempUnit" # 温度单位为1表示精度为0.1度,否则精度为1度


class TerncyClimate(TerncyEntity, ClimateEntity):
Expand All @@ -69,9 +70,13 @@ class TerncyClimate(TerncyEntity, ClimateEntity):
_attr_target_temperature_step: float | None = 1
# _attr_temperature_unit: str = UnitOfTemperature.CELSIUS
_attr_temperature_unit: str = TEMP_CELSIUS # <2022.11
_current_temp_unit: float = 1

def update_state(self, attrs):
# _LOGGER.debug("%s <= %s", self.eid, attrs)
if (temp_unit := get_attr_value(attrs, K_AC_TEMP_UNIT)) is not None:
if temp_unit == 1:
self._current_temp_unit: float = 10
if (ac_mode := get_attr_value(attrs, K_AC_MODE)) is not None:
if ac_mode == 1:
self._attr_hvac_mode = HVACMode.COOL
Expand Down Expand Up @@ -100,7 +105,7 @@ def update_state(self, attrs):
if (
current_temperature := get_attr_value(attrs, K_AC_CURRENT_TEMPERATURE)
) is not None:
self._attr_current_temperature = current_temperature
self._attr_current_temperature = current_temperature / self._current_temp_unit

if (
target_temperature := get_attr_value(attrs, K_AC_TARGET_TEMPERATURE)
Expand Down

0 comments on commit 505d4c5

Please sign in to comment.