mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Prevent homekit fans from going to 100% than speed when turning on (#34875)
This commit is contained in:
parent
5516063f46
commit
6ce0819287
@ -94,13 +94,13 @@ class Fan(HomeAccessory):
|
|||||||
_LOGGER.debug("Fan _set_chars: %s", char_values)
|
_LOGGER.debug("Fan _set_chars: %s", char_values)
|
||||||
if CHAR_ACTIVE in char_values:
|
if CHAR_ACTIVE in char_values:
|
||||||
if char_values[CHAR_ACTIVE]:
|
if char_values[CHAR_ACTIVE]:
|
||||||
is_on = False
|
# If the device supports set speed we
|
||||||
state = self.hass.states.get(self.entity_id)
|
# do not want to turn on as it will take
|
||||||
if state and state.state == STATE_ON:
|
# the fan to 100% than to the desired speed.
|
||||||
is_on = True
|
#
|
||||||
# Only set the state to active if we
|
# Setting the speed will take care of turning
|
||||||
# did not get a rotation speed or its off
|
# on the fan if SUPPORT_SET_SPEED is set.
|
||||||
if not is_on or CHAR_ROTATION_SPEED not in char_values:
|
if not self.char_speed or CHAR_ROTATION_SPEED not in char_values:
|
||||||
self.set_state(1)
|
self.set_state(1)
|
||||||
else:
|
else:
|
||||||
# Its off, nothing more to do as setting the
|
# Its off, nothing more to do as setting the
|
||||||
|
@ -419,8 +419,7 @@ async def test_fan_set_all_one_shot(hass, hk_driver, cls, events):
|
|||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
acc.speed_mapping.speed_to_states.assert_called_with(42)
|
acc.speed_mapping.speed_to_states.assert_called_with(42)
|
||||||
assert call_turn_on
|
assert not call_turn_on
|
||||||
assert call_turn_on[0].data[ATTR_ENTITY_ID] == entity_id
|
|
||||||
assert call_set_speed[0]
|
assert call_set_speed[0]
|
||||||
assert call_set_speed[0].data[ATTR_ENTITY_ID] == entity_id
|
assert call_set_speed[0].data[ATTR_ENTITY_ID] == entity_id
|
||||||
assert call_set_speed[0].data[ATTR_SPEED] == "ludicrous"
|
assert call_set_speed[0].data[ATTR_SPEED] == "ludicrous"
|
||||||
@ -430,11 +429,11 @@ async def test_fan_set_all_one_shot(hass, hk_driver, cls, events):
|
|||||||
assert call_set_direction[0]
|
assert call_set_direction[0]
|
||||||
assert call_set_direction[0].data[ATTR_ENTITY_ID] == entity_id
|
assert call_set_direction[0].data[ATTR_ENTITY_ID] == entity_id
|
||||||
assert call_set_direction[0].data[ATTR_DIRECTION] == DIRECTION_REVERSE
|
assert call_set_direction[0].data[ATTR_DIRECTION] == DIRECTION_REVERSE
|
||||||
assert len(events) == 4
|
assert len(events) == 3
|
||||||
|
|
||||||
assert events[1].data[ATTR_VALUE] is True
|
assert events[0].data[ATTR_VALUE] is True
|
||||||
assert events[2].data[ATTR_VALUE] == DIRECTION_REVERSE
|
assert events[1].data[ATTR_VALUE] == DIRECTION_REVERSE
|
||||||
assert events[3].data[ATTR_VALUE] == "ludicrous"
|
assert events[2].data[ATTR_VALUE] == "ludicrous"
|
||||||
|
|
||||||
hass.states.async_set(
|
hass.states.async_set(
|
||||||
entity_id,
|
entity_id,
|
||||||
@ -482,7 +481,7 @@ async def test_fan_set_all_one_shot(hass, hk_driver, cls, events):
|
|||||||
# and we set a fan speed
|
# and we set a fan speed
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
acc.speed_mapping.speed_to_states.assert_called_with(42)
|
acc.speed_mapping.speed_to_states.assert_called_with(42)
|
||||||
assert len(events) == 7
|
assert len(events) == 6
|
||||||
assert call_set_speed[1]
|
assert call_set_speed[1]
|
||||||
assert call_set_speed[1].data[ATTR_ENTITY_ID] == entity_id
|
assert call_set_speed[1].data[ATTR_ENTITY_ID] == entity_id
|
||||||
assert call_set_speed[1].data[ATTR_SPEED] == "ludicrous"
|
assert call_set_speed[1].data[ATTR_SPEED] == "ludicrous"
|
||||||
@ -526,7 +525,7 @@ async def test_fan_set_all_one_shot(hass, hk_driver, cls, events):
|
|||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert len(events) == 8
|
assert len(events) == 7
|
||||||
assert call_turn_off
|
assert call_turn_off
|
||||||
assert call_turn_off[0].data[ATTR_ENTITY_ID] == entity_id
|
assert call_turn_off[0].data[ATTR_ENTITY_ID] == entity_id
|
||||||
assert len(call_set_speed) == 2
|
assert len(call_set_speed) == 2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user