As the topic implies, is it possible to prevent a restart if a sensor is in a certain state or automations are currently running?
I doubt very much that this is possible, at least not with the standard restart button, but am curious what the pro’s come up with.
OTOH: you can create a script to restart instead of the standard restart button and at least check the state of a sensor and maybe also the state of your automations.
What is causing HA to restart?
Is it crashing?
Is somebody pressing the restart button?
Is it during an update? Is it a manual or automatic update?
Is it called from a script/automation?
That’s and excellent idea, just might be solutions.
By pressing the restart button after configuration changes, and after manual updates.
I do not think Supervisor can help here.
Of course it does, IF they are running the right version of HA, to issue the reboot for starters.
After that they need to add the conditons from sensors & automations.
It looks like Supervisor only can restart the host.
The action to restart HA core would be homeassistant.restart, which I think is a HA core action.
Will the following work?
triggers:
- trigger: state
entity_id:
- input_boolean.ha_restart
conditions:
- condition: and
conditions:
- condition: state
entity_id: switch.01
state: "off"
- condition: state
entity_id: switch.02
state: "off"
- condition: state
entity_id: switch.03
state: "off"
- condition: template
value_template: "{{ states('automation.*') == 'running' }}"
actions:
- action: homeassistant.restart
metadata: {}
data: {}
Not sure what you expect here.
Do you want it to run when the automations are running?
If you want it to run when no automation is running then it will by definition always fail since it is an automation itself.
I don’t think a boolean is the best option to trigger it, you could use a button, or even better make it a script.
Automations are menat to run by themselves, this is an automation that you trigger by human control, that is what scripts are for.
And lastly conditions are and by default so the and is not needed
Seems like the editor ate some of your characters.
How would you toggle that boolean?!
With a button!
That’s why I wrote:
If you haven’t done so yet, learn to use scripts.
Yes, it should have been {{not is_state('automation.*', 'running')}}
Thanks, was not aware of that.
That was the plan, so I can have a button on the frontend.
Will the following work without any issues?
sequence:
- condition: state
entity_id: switch.01
state: "off"
- condition: state
entity_id: switch.02
state: "off"
- condition: state
entity_id: switch.03
state: "off"
- condition: template
value_template: "{{not is_state('automation.*', 'running')}}"
- action: homeassistant.restart
Come on, be a little adventurous and test it on your system, albeit with a boolean as a test so your system will not start and with the traces you see what happens!
What characters?
Seems to work.
Atta boy (or girl, it, they, … whatever currently inclusive type of description is needed to not be accused of anything)
Ohh, I read it as something missing in between “are” and “and”, when in fact you meant conditions are using “and” by default.