Could anyone help with how to have an automation run at particular times of day?
I have a simple Motion activated lights automation that only runs when the illuminance condition is met. I don’t want this to run overnight so I created a second condition. Using a time helper I set on and off to 0700 to 2300. The condition in the automation is set to look to see if the State of the helper is on or off. The automation fails to run whatever time of day.
Is this this right approach? Any ideas why it doesn’t work. I’m new to HA and don’t use YAML.
Yes using time conditions would be the way to go. You’ll need to set the after, before and days you want it to run.
It is possible in the UI. Can you share a screenshot of what you have so far and we will try see why it’s not doing what you want, please?
It should be when added the condition in the first place you want to select ‘And’, which will then allow you to add 2 conditions for it to have to match within that block.
Hey there, your use case sounds awfully similar to something a popular blueprint can do.
Will highly recommend taking a look at this awesome blueprint.
Motion activated lights, with an optional time condition and many other bells and whistles.
Adam, many thanks for your reply. I’m hoping the screenshot is visible. I did have two separate conditions but have now taken your suggestion to make the automation test to see if both conditions are met, one being the times of day helper. It seems to be working! Thank you
I have a separate automation to turn the lights back off as couldn’t think hope to combine them. That’s working fine.
Thanks again for your reply, new to HA and have found automations harder to pick up than Hubitat.
While in the Automation Editor, click the overflow menu in the upper right corner (three dots) and switch the editor to YAML mode. Copy the displayed YAML and paste it into your forum post. Format it using the </> icon
As suggested after my last comment, there does look to be a new blueprint that could be used to simply turn it on and off, however, doesn’t look to have time conditions on it.
Is the binary_sensor (that’s on at 7:00 and off at 23:00) used elsewhere or only in this automation?
NOTE
For future reference, only certain types of entities fall into the category of “Helper”. For example Input Boolean, Timer, Input Select, Counter, etc. Currently, a Binary Sensor isn’t a member of the “Helper” category. I mention this only because in your first post you wrote:
However the automation’s YAML shows the State Condition is checking a Binary Sensor’s state (which isn’t a Helper).
FWIW, in the past, the Helpers category contained few members and was largely composed of the “Input” integrations such as Input Boolean, Input Text, etc plus Counter, Timer, etc . However, it recently expanded to include many other integrations such as Min/Max, Utility, Threshold, Times of Day, Schedule, etc. Effectively, it has become a catch-all for miscellaneous integrations (that support creating their entities via the UI).
Perhaps in the future, the Helper category will include the Template integration thereby allowing a Template Binary Sensor to be referred to as a “Helper”.
It’s only used in the this automation. I was planning to perhaps use it in more than one. I’m trying to stop my dog setting off the lights multiple times in the middle of the night!
If you should ever want the ability to easily adjust the time range (via the UI), or to specify on which days of the week it’s applicable, consider replacing the Binary Sensor with a Schedule.