Skip to content

Commit

Permalink
Add unit for number entity instead using label
Browse files Browse the repository at this point in the history
  • Loading branch information
osk2 committed Jul 13, 2021
1 parent 8bd54c9 commit abaafd3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
10 changes: 7 additions & 3 deletions custom_components/panasonic_smart_app/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "分鐘"
18 changes: 18 additions & 0 deletions custom_components/panasonic_smart_app/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()

0 comments on commit abaafd3

Please sign in to comment.