Handle clamped fan maxValue in homekit_controller (#51088)

This commit is contained in:
J. Nick Koston 2021-05-25 16:06:17 -05:00 committed by GitHub
parent 3a6a1a4d6b
commit deb9135707
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 307 additions and 1 deletions

View file

@ -84,7 +84,8 @@ class BaseHomeKitFan(HomeKitEntity, FanEntity):
def speed_count(self):
"""Speed count for the fan."""
return round(
100 / max(1, self.service[CharacteristicsTypes.ROTATION_SPEED].minStep or 0)
min(self.service[CharacteristicsTypes.ROTATION_SPEED].maxValue or 100, 100)
/ max(1, self.service[CharacteristicsTypes.ROTATION_SPEED].minStep or 0)
)
async def async_set_direction(self, direction):