It feels like to me having a trigger that says every ODD numbered day or something simple like this should be built into triggers. But I don’t see anything like that without doing some complex script with variables and such.
Is their an easy way to do this or an add-on that makes it simple?
The simplest method is probably to just flip a boolean back and forth.
But of course some day the automation that does this might fail.
And it won’t work for every third or similar.
My goal is to have a plug that comes on every other day at 9AM. It goes off once the current draw of what it is charging is done. So the off part I have figured out but the only coming on every other day i don’t have figured out.
Sure.
But I actually think Toms suggestion is a safer method.
This turns it on after being off for 48 hours, but if you restart HA or connection temporarily ia lost to the switch then this restarts the counter.
The off trigger might need to be a numeric below something instead.
description: ""
mode: single
triggers:
- trigger: state
entity_id:
- switch.something
to: "off"
id: "on"
for:
hours: 48
- trigger: state
entity_id:
- sensor.something
to: "0"
id: "off"
conditions: []
actions:
- action: "switch.turn_{{ trigger.id }}"
metadata: {}
data: {}
target:
entity_id: switch.something
This is the simplest way anyone has come up with that works flawlessly every time. There are no issues with reboots or resetting logic variables. It’s just a straightforward and easy-to-use solution.
The only thing I didn’t realize until after setting it up was that you can’t use one calendar to have events for multiple triggers.
When you trigger an event, you can only specify when an event happens in that specific calendar. You can’t say for events in the calendar named “X” to do one thing and for events called “Y” to do something else.
So, don’t use generic named calendars for automation purposes. Instead, name them based on the specific automation they’re intended for.
Once I understood this, I just created a new calendar with the correct name.
Thanks, Tom! This is a great solution to my problem.