Skip to content

Commit

Permalink
Wait on pending ops before comparing state
Browse files Browse the repository at this point in the history
  • Loading branch information
amitfin committed May 13, 2023
1 parent 0e0c020 commit c3e1521
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions custom_components/retry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,12 @@ async def async_check_entities() -> None:
for entity_id in service_entities:
if (ent_obj := get_entity(entity_id)) is None or not ent_obj.available:
raise InvalidStateError(f"{entity_id} is not available")
if expected_state and (state := ent_obj.state) != expected_state:
raise InvalidStateError(
f'{entity_id} state is "{state}" but expecting "{expected_state}"'
)
if expected_state:
await hass.async_block_till_done()
if (state := ent_obj.state) != expected_state:
raise InvalidStateError(
f'{entity_id} state is "{state}" but expecting "{expected_state}"'
)

@callback
async def async_retry(*_) -> bool:
Expand Down

0 comments on commit c3e1521

Please sign in to comment.