I’m finally getting around to my first custom component, which has been a bit daunting, and have a question.
In my system I have a need to turn on a switch and then wait for between 1 and 3 minutes to turn on a second switch. I know I can add standard Python waits into the code but it seems like this is suboptimal since it would leave the script in a hung state while it waits.
What is the prescribed best case for doing this kind of thing?
Something like this:
await self._hass.services.async_call(
"switch", "turn_on", {"entity_id": self._switch_entity}
)
... wait for 1 to 3 minute(s)
await self._hass.services.async_call(
"switch", "turn_on", {"entity_id": self._second_switch_entity}
)
In Py I have several ways to delay, but for example:
threading.Event().wait(60)