Hi All,
I would like a new set of eyes on this basic automation that is not working.
All I am tryng to do is turn off a light if it has been on for 30 minutes and if it is before 6pm (so basically during the day).
This is what I built via the UI.
alias: Bathroom Sink Lights OFF - 30 min.
description: ""
triggers:
- type: turned_on
device_id: 296026a564b3c26c9c1cc367b60e6258
entity_id: 3ca465a38596a6338f1aa63d80f91546
domain: light
trigger: device
for:
hours: 0
minutes: 30
seconds: 0
conditions:
- condition: time
before: "18:00:00"
actions:
- type: turn_off
device_id: 296026a564b3c26c9c1cc367b60e6258
entity_id: 3ca465a38596a6338f1aa63d80f91546
domain: light
mode: single
Thanks in advance for the help.
Dan
You should add an after time as well to the condition
I just tested your logic and it worked fine. Test it with a really short time like 15 seconds and see if you get the same results.
It will work with just the before condition
The OP said “during the day”. Without the after condition, it will run at night too anytime after midnight.
Sure but that’s not why it isn’t working
I forgot to mention one thing in case it could help explain why my code is not working. The “light” that I am turning off is a dual relay Z-Wave device.
I have automations running that turn it on or off at specific times of the day and those are working just fine.
Did you change the device type from it’s initial integration?
For example, was it a binary sensor or a switch you are displaying as a light?
I would guess is that it’s not reporting the active time ON to HA, but I am unfamiliar with those relays.
I changed the one of the two module using a “helper” to show the switch as a light.
The module #1 I did not touch (that is the sink light) and module #2 I changed to a light. I think I screwed up something during my initial config.
The dual relay is : switch.bathroom_dual_relay_module
Module #1 (relay 1 - sink light) is : light.bathroom_dual_relay_module_basic
Module # 2 (relay 2) is : light.bathroom_dual_relay_module_basic
Maybe that is my bug.
Solved ! Thanks for the guidance.
I ended up using the switch entity of the relay module rather than the light.
So the fact that I changed the device type with a helper seems to be what prevented the automation from working.