Skip to content
This repository has been archived by the owner on Jul 1, 2023. It is now read-only.

Commit

Permalink
Fix number entity min/max/step handling for HA 2021.12 (#78)
Browse files Browse the repository at this point in the history
* Change number entity min/max/step handling

* fix release in comment
  • Loading branch information
cgarwood authored Dec 28, 2021
1 parent 38e976d commit e24ca6e
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions custom_components/fullykiosk/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,16 @@
NumberEntityDescription(
key="timeToScreensaverV2",
name="Screensaver Timer",
step=1,
min_value=0,
max_value=9999,
entity_category=EntityCategory.CONFIG,
),
NumberEntityDescription(
key="screensaverBrightness",
name="Screensaver Brightness",
min_value=0,
max_value=255,
entity_category=EntityCategory.CONFIG,
),
NumberEntityDescription(
key="timeToScreenOffV2",
name="Screen Off Timer",
min_value=0,
max_value=9999,
entity_category=EntityCategory.CONFIG,
),
)
Expand Down Expand Up @@ -65,6 +58,15 @@ def __init__(self, coordinator, description: NumberEntityDescription):
"configuration_url": f"http://{self.coordinator.data['ip4']}:2323",
}

# Min, max, and step are not available in EntityDescription until HA 2022.2 release.
self._attr_step = 1
self._attr_min_value = 0

if self._key in ["timeToScreensaverV2", "timeToScreenOffV2"]:
self._attr_max_value = 9999
if self._key == "screensaverBrightness":
self._attr_max_value = 255

@property
def state(self):
"""Return the state of the number entity."""
Expand Down

0 comments on commit e24ca6e

Please sign in to comment.