So I have a heat pump, which is controllable via mqtt which is nice. It also reports it’s state on the mqtt as well, which I’m able to read and I have an indicator on the dashboard showing whether it’s running or not
I have a time trigger to turn it in at 5:30am and off at 8am - and once in a blue moon it’ll fail for a reason I’m not sure I’ll ever be able to ascertain. The aircon widget thinks it’s going, the state indicator knows it’s not.
Is there a way to have a trigger or automation that ensures it’s on after I’ve asked it to be on?
Quick and less dirty: issue the command, wait a few sec, have a condition that checks the sensor status and if no the right status issue the command again
something a bit more involved like a loop that will issue the command, wait, check the status rerun the loop if wrong status or exit the loop if correct status
he he no you can’t have a loop in an automation, hence me saying “something a bit more involved”
You can achieve a loop by having 2 scripts calling each other.
Here is an example that I use:
I wonder if you could call yourself - recurse until the condition is met. Like, check if the device is already on and if not attempt to turn on the device then wait a minute then call yourself.
Every time under normal conditions, the first check will always fail, causing the script to tell the device to turn on and call itself again. Then the check will succeed and the script unwinds.
If the device is already reporting itself as on, the script won’t even attempt to turn it on.
I’ll need two exit conditions. Either a retry count or a time exit condition, so it doesn’t run forever if the device won’t turn on for some reason.
that’s pretty much it. The key here is the condition in the first script. When that condition is false, the script stops.
So replace it with your sensor showing the device is not on so the one command is issued again
You can have loops in automation. It’s called “repeat”. It’s available via UI and via YAML as well. Leaving this for someone who’s searching for this next Here’s an example of my script for auto watering.