From a64d3fe28d664786a968ab5d3140307b82d0d77b Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 14 Feb 2021 11:15:42 -1000 Subject: [PATCH] Make this a by more DRY by adding int_states_in_range util --- docs/core/entity/fan.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/core/entity/fan.md b/docs/core/entity/fan.md index dc408122..7fdadaa2 100644 --- a/docs/core/entity/fan.md +++ b/docs/core/entity/fan.md @@ -121,7 +121,7 @@ named_speed = percentage_to_ordered_list_item(ORDERED_NAMED_FAN_SPEEDS, 23) If the device has a numeric range of speeds: ```python -from homeassistant.util.percentage import ranged_value_to_percentage, percentage_to_ranged_value +from homeassistant.util.percentage import int_states_in_range, ranged_value_to_percentage, percentage_to_ranged_value SPEED_RANGE = (1, 255) # off is not included @@ -139,7 +139,7 @@ value_in_range = math.ceil(percentage_to_ranged_value(SPEED_RANGE, 50)) @property def speed_count(self) -> Optional[int]: """Return the number of speeds the fan supports.""" - return SPEED_RANGE[1] - SPEED_RANGE[0] + 1 + return int_states_in_range(SPEED_RANGE) ``` :::