diff --git a/homeassistant/components/homekit/type_covers.py b/homeassistant/components/homekit/type_covers.py index 807941c7a6d..d77ea22dc96 100644 --- a/homeassistant/components/homekit/type_covers.py +++ b/homeassistant/components/homekit/type_covers.py @@ -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 diff --git a/tests/components/homekit/test_type_covers.py b/tests/components/homekit/test_type_covers.py index fb73c132e30..87d4fbdcc2b 100644 --- a/tests/components/homekit/test_type_covers.py +++ b/tests/components/homekit/test_type_covers.py @@ -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