Run Automation Only During Certain Hours

Hi, I have an automation that I want to run only during certain hours. Currently I have it triggered every 5 minutes, with the time range as a condition.

That works but it means it’s triggered pointlessly outside those times which is inelegant. It also means that traces from the actual useful runs are lost.

Is there a better way?

Not that I know. You can create a workaround to fire an event in here, and listen for the event in the real automation if you want to save relevant traces. But for me the first question would be is: why a cron pattern? Is this really needed? They should be avoided if possible. I have next to none among hundres of automations.

You can create another automation that turns on/off the once-per-5-minutes automation at the specific times: Automation actions - Home Assistant

2 Likes

Thanks. I need to look into that idea.

As for why to run every five minutes I’m charging the battery up only to a predefined level. The Solaredge controls don’t allow that explicity, you switch mode to start it charging and it carries on until either the command time out, or you explicitly switch to a different mode.

So my high level logic is …
(1) Start of cheap rate switch battery effectively off, mode current mode and default mode.
(2) During the time i want to charge, test battery % and if below threshold issue (or reissue) command to set it charging. If above threshold then let the command timeout and mode revert to the default.
(3) End of cheap rate set battery back on

I’m certainly keen to know if there’s a better way of doing (2). The time range is critical, I don’t want to charge or switch the battery off or except during cheap rate.

I use scheduler and scheduler card from HACS for this sort of thing. It can control different entities

3 Likes

That might be easiest. I already have one-off automations changing storage default mode at the beginning and end of the cheap rate. I’ll see if I can get them to enable and disable the charging automation as well