From abaafd3e96110078998913019b40fc4a3e1f4895 Mon Sep 17 00:00:00 2001 From: osk2 Date: Tue, 13 Jul 2021 14:22:05 +0800 Subject: [PATCH] Add unit for number entity instead using label --- custom_components/panasonic_smart_app/const.py | 10 +++++++--- .../panasonic_smart_app/number.py | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/custom_components/panasonic_smart_app/const.py b/custom_components/panasonic_smart_app/const.py index d619c1c..3b8a4ff 100644 --- a/custom_components/panasonic_smart_app/const.py +++ b/custom_components/panasonic_smart_app/const.py @@ -108,9 +108,13 @@ LABEL_CLIMATE = "" LABEL_TANK = "水箱滿水" LABEL_HUMIDITY = "環境溼度" -LABEL_DEHUMIDIFIER_ON_TIMER = "定時開機(時)" -LABEL_DEHUMIDIFIER_OFF_TIMER = "定時關機(時)" +LABEL_DEHUMIDIFIER_ON_TIMER = "定時開機" +LABEL_DEHUMIDIFIER_OFF_TIMER = "定時關機" LABEL_CLIMATE_ON_TIMER = "定時開機(分)" -LABEL_CLIMATE_OFF_TIMER = "定時關機(分)" +LABEL_CLIMATE_ON_TIMER = "定時開機" +LABEL_CLIMATE_OFF_TIMER = "定時關機" LABEL_OUTDOOR_TEMPERATURE = "室外溫度" LABEL_PM25 = "PM2.5" + +UNIT_HOUR = "小時" +UNIT_MINUTE = "分鐘" diff --git a/custom_components/panasonic_smart_app/number.py b/custom_components/panasonic_smart_app/number.py index f14f125..1e861be 100644 --- a/custom_components/panasonic_smart_app/number.py +++ b/custom_components/panasonic_smart_app/number.py @@ -14,6 +14,8 @@ LABEL_DEHUMIDIFIER_OFF_TIMER, LABEL_CLIMATE_ON_TIMER, LABEL_CLIMATE_OFF_TIMER, + UNIT_HOUR, + UNIT_MINUTE, ICON_ON_TIMER, ICON_OFF_TIMER, CLIMATE_ON_TIMER_MIN, @@ -147,6 +149,10 @@ def min_value(self) -> int: def max_value(self) -> int: return DEHUMIDIFIER_ON_TIMER_MAX + @property + def unit_of_measurement(self) -> str: + return UNIT_HOUR + async def async_set_value(self, value: float) -> None: await self.client.set_command(self.auth, 213, int(value)) await self.coordinator.async_request_refresh() @@ -184,6 +190,10 @@ def min_value(self) -> int: def max_value(self) -> int: return DEHUMIDIFIER_OFF_TIMER_MAX + @property + def unit_of_measurement(self) -> str: + return UNIT_HOUR + async def async_set_value(self, value: float) -> None: await self.client.set_command(self.auth, 130, int(value)) await self.coordinator.async_request_refresh() @@ -221,6 +231,10 @@ def min_value(self) -> int: def max_value(self) -> int: return CLIMATE_ON_TIMER_MAX + @property + def unit_of_measurement(self) -> str: + return UNIT_MINUTE + async def async_set_value(self, value: float) -> None: await self.client.set_command(self.auth, 139, int(value)) await self.coordinator.async_request_refresh() @@ -258,6 +272,10 @@ def min_value(self) -> int: def max_value(self) -> int: return CLIMATE_OFF_TIMER_MAX + @property + def unit_of_measurement(self) -> str: + return UNIT_MINUTE + async def async_set_value(self, value: float) -> None: await self.client.set_command(self.auth, 140, int(value)) await self.coordinator.async_request_refresh()