I made automations and i would like to know if i did the right thing.
For the first, the differents steps are:
1 - At 11:00, i start this automation
2 - I check the color of the day
3 - if color is red, i am waiting 11h more and then i switch the tank to ON
4 - if color is different, i start immediatelly the switch the tank to ON
For the second:
1 - When the previous automation is executed, i start this one.
2 - I am waiting 30 minutes
3 - I repeat the action “check de sensor” until is status change
4 - If the status is changed since 30 minutes, i stop the tank’s switch
In your first automation, it isn’t a good idea to include a long delay like that. The state of the entities involved may change in the interim and a restart would stop the whole automation. A simpler approach would be to start a timer and have another automation fire when it reaches zero. Timers can be set to resume after a restart.
Also, in the action can’t you use the service switch.turn_on with the entity name of the switch? Device ids are best avoided if possible.
In the second automation, isn’t the trigger binary_sensor.capteur_seuil_chauffe_eau being turned on? Perhaps I’ve misunderstood it.
Edit: I’m not sure if daisychaining automations together like this is even possible, but I’m sure it’s a bad idea with unpredictable results - they’re supposed to respond to events in the system.
Also, in the action can’t you use the service switch.turn_on with the entity name of the switch? Device ids are best avoided if possible.
Ok, i don’t write it, i use the gui to make it. Home Assistant translate with the id. I will correct this.
In your first automation, it isn’t a good idea to include a long delay like that. The state of the entities involved may change in the interim and a restart would stop the whole automation. A simpler approach would be to start a timer and have another automation fire when it reaches zero. Timers can be set to resume after a restart.
To be sure, if i reboot HA, it will automatically pause and resume?
Edit: The problem with device ids is down the road a bit - if you ever have to replace a device, you will have to edit every automation and script it appears in to put in a new id. If you use entity names, you only have to give the new device the same name as the old one and everything will go on as before.
Another edit: I use the GUI too. In the action section you need to select “call a service”, then “switch.turn_on” and choose the name of your entity.
If I may throw in a different approach, not using timers or delays at all…
Automations:
At 11:00 in the morning you simply set a template sensor with the color value for the day.
If the template sensor is red, this triggers the automation to switch on.
At 22:00 you simply check the value of the template sensor and react on it.
Your second automation can be run at 11:30, and if I understand what it is doing, this can be put in here as well.
As you are doing things depending on the exact time of the day, it should not need any delays or timers, as you would use a time trigger at a specific time and check at that point what the circumstances are.
To avoid some nerve-wrecking along the road, you might want to post some of your automations to let them check by the community. Just in case.
The jeedom automation is different because when i created, i did’nt need to check the color of the day.
The logic of the first automation is:
start at 11:00
after 30 minutes, i check the power consumption. Until it is less than 50w and minimum of 2 hours after automation started, i turn off the tank.
(that means, the water is hot and tank is off but not the “Controlled Mechanical Ventilation”).
At 11:00, start tank only if days != red, else start it at 22:00
regardless of start time (11:00 or 22:00), wait 30 minutes and check power consumption and then stop it if power less 50W after 30 minutes.
PS: If i understand, you say, i can have only one automation for all of these steps. But i don’t understand how.
I recommend you consider implementing paddy0174’s suggestion. It leverages Home Assistant’s strengths. It can be implemented with a Trigger-based Binary Template Sensor and a single automation. It doesn’t use long delays, thereby reducing its vulnerability to restarts.
It’s possible to create a single automation to implement your application but it isn’t necessary. You’re free to create multiple automations, each handling a specific part of your overall application.