Custom automation

I have two loads that I want to cycle on and off for a short period of time, and do not want them to be on at the same time. I want the cycles to start at certain times of the day. Also, I plan to have push buttons or motion sensors to turn on a specific load for a period of time, and ensure the other is off.

Can anyone provide a link to literature or videos on how to develop this custom automation?
I see plenty of resources for turning on the lights when the sun goes down. I am thinking that this is a bit beyond that. I found this link but as it states in the intro, who knows what is still relevant with the pace of changes.


Have a look at this… but honestly you can create what you are asking very easily with normal automations. The concept is very similar to my irrigation system run by HA whereby I can adjust the start times, run times and no two stations run at the same time.

Your irrigation system is a great example. I looked through that. I will need to learn the syntax. I am well versed in object oriented programming, and know if I am not able to translate into English, which includes learning the syntax, I will not be able to use examples to walk up the learning curve.

I am thinking I should play with the simple automations first. I am trying to use the Hass UI to turn on a tasmota sonoff dual relay with the trigger being the other relay turning off. I think I created the trigger as that is selecting in the UI - except for the “For” line at the end. Is there an explanation of this anywhere?

And I do not know the syntax for the “Service Data” in Action. I am assuming I use ‘MQTT:publish’ for the Service, but I also see ‘Switch.turn_on’.
Is there a link that describes these settings in detail?

I found this link, but it is has little information and seems focused on the yaml files, which is confusing.
Here is another that looks similar, but is a couple years old.

If you plan on doing relatively complex automations later, I would stay well away from the GUI automation editor. It messes with the layout and formatting of the code such that it doesn’t match that in the docs. This can then be confusing. Also, the GUI editor doesn’t have all options available.

See the docs here.

I don’t have experience with Sonoffs but I would imagine since you are using MQTT that you could either publish the data directly or if you create an MQTT switch, then you could turn that on/off. Also, you be aware that you can use ESPhome on Sonoffs which then integrates with a HA API, thus not requiring MQTT at all.

I would prefer that because I like to see the code that runs the automation.

What I run into now, is do I reverse course and create my sonoff/tasmota devices in the yaml files, or do I use what the GUI set up (and is already running)? and if GUI, is there a mapping of the GUI interface info to what is shown in the tutorials?

I’m not 100% on how the GUI automations are saved these days, it used to be in YAML but I think it’s JSON now, so a bit harder to ‘translate’. I would suggest just going straight for editing YAML yourself. You will be able to create the automations easier and in line with the docs, plus have all features rather than being limited