Fix turn on without speed in homekit controller (#47597)

This commit is contained in:
J. Nick Koston 2021-03-08 08:43:22 -10:00 committed by GitHub
parent 32476a3fed
commit b315fcab11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 112 additions and 1 deletions

View file

@ -80,6 +80,13 @@ class BaseHomeKitFan(HomeKitEntity, FanEntity):
return features
@property
def speed_count(self):
"""Speed count for the fan."""
return round(
100 / max(1, self.service[CharacteristicsTypes.ROTATION_SPEED].minStep or 0)
)
async def async_set_direction(self, direction):
"""Set the direction of the fan."""
await self.async_put_characteristics(
@ -110,7 +117,7 @@ class BaseHomeKitFan(HomeKitEntity, FanEntity):
if not self.is_on:
characteristics[self.on_characteristic] = True
if self.supported_features & SUPPORT_SET_SPEED:
if percentage is not None and self.supported_features & SUPPORT_SET_SPEED:
characteristics[CharacteristicsTypes.ROTATION_SPEED] = percentage
if characteristics: