Fix preservation of homekit fan speed on toggle (#34971)

This commit is contained in:
J. Nick Koston authored and Paulus Schoutsen committed 2020-04-30 22:37:57 -07:00
1 parent b68228c7e8
commit de18207ca3
3 files changed
+30 -2

No files matched your search

@@ -165,7 +165,9 @@ class Fan(HomeAccessory):
self.char_direction.set_value(hk_direction)
# Handle Speed
if self.char_speed is not None:
if self.char_speed is not None and state != STATE_OFF:
# We do not change the homekit speed when turning off
# as it will clear the restore state
speed = new_state.attributes.get(ATTR_SPEED)
hk_speed_value = self.speed_mapping.speed_to_homekit(speed)
if hk_speed_value is not None and self.char_speed.value != hk_speed_value:
+1 -1
View File
@@ -200,7 +200,7 @@ class HomeKitSpeedMapping:
if speed is None:
return None
speed_range = self.speed_ranges[speed]
return speed_range.target
return round(speed_range.target)
def speed_to_states(self, speed):
"""Map HomeKit speed to Home Assistant speed state."""