im new to HA and have some trouble with one automation:
This automation should turn on a light on after sunset and should switch it off at 11pm. The part where the light is switched on works just fine. But the part where it should be switched off isn´t. Had it in one automation and followed the advise from some posts, to split it in 2 automations. Same result.
For me as a newbie, the genereated part in the YAML File looks fine (similiar to what i found in the forum). Any advice is appreciated
alias: 04 dining light off
description: ''
trigger:
- platform: time
at: '23:00:00'
condition: []
action:
- type: turn_off
device_id: 1a7af4433e1d044f196086c90b5bdff8
entity_id: light.l_iris_1
domain: light
mode: single
You and I are about on par with each other regarding automations. But I would like to see your working (turn on) automation.
Did you create the automation in the UI then change to “edit in YAML” to get the YAML that you posted? The reason I ask is because none of my automations made through the UI have a “device_id:”
Like you, I find separate automations to be a lot easier to understand.
Here is my automation to turn the porch light on five minutes before sunset:
alias: Porch Light On at sunset
description: ''
trigger:
- platform: sun
event: sunset
offset: '-00:05:00'
condition: []
action:
- service: switch.turn_on
data: {}
target:
entity_id: switch.porchlight
mode: single
And to turn it off four hours after subset:
alias: Porch Light Off at sunset+4
description: ''
trigger:
- platform: sun
event: sunset
offset: '+04:00:00'
condition: []
action:
- service: switch.turn_off
data: {}
target:
entity_id: switch.porchlight
mode: single
Yes, I use the UI to create the automations. As a noob, it’s easier for me right now. And the automations I have so far have not had to be touched in the YAML code so far.
Here’s my YAML code for it (changed the light for the auto turnoff to a light right beside my desk). And its genereating device IDs
I will try your approach to turn off the light. Its an nice idea for a less predictable “vacation mode”. I would like to have a specific time or i have to touch this automation many times a year
ok Thx, poor translation in the UI. Tried it, doesnt work as well. It seems like nothing with a time trigger will work or im just too dump to get it. Tried it with a device as well as an entity
Tried what?, which part doesn’t work as well, is your TZ set correctly?, you can add the “time_date” sensor to confirm your system is using the correct time, I have many time triggered automations that work as expected, have you checked your logs or the automation trace to see which part is failing?
One example:
alias: New Automation
description: ''
mode: single
trigger:
- platform: time
at: '23:00:00'
condition: []
action:
- service: light.turn_off
data: {}
target:
entity_id: light.blue_led
Thx, for your replies.
Switched to a new housing for my PI today and was shutting down the system completly. After that, its working now. Same Automation without any changes. Time Zone was set correctly.