mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Fix HomeKit window covering to support float numbers in the position (#31081)
* Fix HomeKit window covering to support float numbers in the position * Fix HomeKit window covering to cast current position to an integer value
This commit is contained in:
parent
bfea9863f1
commit
894b841a15
@ -119,7 +119,8 @@ class WindowCovering(HomeAccessory):
|
||||
def update_state(self, new_state):
|
||||
"""Update cover position after state changed."""
|
||||
current_position = new_state.attributes.get(ATTR_CURRENT_POSITION)
|
||||
if isinstance(current_position, int):
|
||||
if isinstance(current_position, (float, int)):
|
||||
current_position = int(current_position)
|
||||
self.char_current_position.set_value(current_position)
|
||||
if (
|
||||
self._homekit_target is None
|
||||
|
@ -151,6 +151,12 @@ async def test_window_set_cover_position(hass, hk_driver, cls, events):
|
||||
assert acc.char_target_position.value == 60
|
||||
assert acc.char_position_state.value == 1
|
||||
|
||||
hass.states.async_set(entity_id, STATE_OPENING, {ATTR_CURRENT_POSITION: 70.0})
|
||||
await hass.async_block_till_done()
|
||||
assert acc.char_current_position.value == 70
|
||||
assert acc.char_target_position.value == 70
|
||||
assert acc.char_position_state.value == 1
|
||||
|
||||
hass.states.async_set(entity_id, STATE_CLOSING, {ATTR_CURRENT_POSITION: 50})
|
||||
await hass.async_block_till_done()
|
||||
assert acc.char_current_position.value == 50
|
||||
|
Loading…
x
Reference in New Issue
Block a user