My automation will not start

Hi!
I’m new to this, I have been reading about automation’s in HA today
and started typing my own after looking at some YAML-code examples.

This is what I came up with for my last attempted:


- id: turn-on-lamp-for-1h-at-bedroom-window
  alias: 'Turn on lamp for 1h at bedroom window'
  initial_state: 'on'
  trigger:
    platform: time
    at: '18:57:00'
  action:
    service: switch.turn_on
    entity_id: switch.fonstersovrum
#    data:
      # 900 seconds = 15 minutes 3600 = 1h
#      transition: 180

I puched the buttom “update automations” and the file passed the validations test
and I can see the id in my list of “plugs” and “automation” but the lamp will not turn on… What am I missing or doing wrong?? :sob::laughing::stuck_out_tongue_closed_eyes::grimacing:

Thanks in advance! :slight_smile:

//Sandra

This is how I do mine:  
      - alias: 'Turn On Garage Light At 06:00'
        trigger:
          platform: time
          at: '06:00:00'
        action:
          service: switch.turn_on
          entity_id: 
            - switch.garage_light

is the automation showing in your list of automations in the dev panel? (<>) I didn’t think that dashes would be accepted in the id, generally only underscores are allowed, but I could well be wrong there.

Any errors in the log?

Don’t use dashes.

id: turn_on_lamp_for_1h_at_bedroom_window

Have you tried restarting home assistant?

Thank you! I will try that! :slight_smile:

It showes up on the panel, and I have seen both syntaxes. But it never hurts to try it out! Thank you!

Yes, both updated and restart and no error, HA tells me it’s all good… that’s what I find strange. It has to be something missing or something that passes the test but still doesn’t go well with the backend… :confused:

It works now! :star_struck: I changed the entity_id to a list. Think it must be in a list when one only uses one switch that are not in a group. :slight_smile:
Another thing that I noticed was that my Pi 3b is one hour off. So in order for the lamp to turn on at 7:00 in the morning I need to set it at 6:00. Might be something with the timezone, maybe. :sweat_smile:

Here is my final code.
####################################################
# Lampan i sovrumsfönstret #
####################################################
# tänds vardagar kl 07:00 och släcks efter en timma
- id: turn_on_lamp_for_1h_at_bedroom_window
alias: ‘Turn on lamp for 1h at bedroom window’
initial_state: ‘on’
trigger:
platform: time
at: ‘06:00:00’
condition:
condition: time
weekday:
- mon
- tue
- wed
- thu
- fri
action:
service: switch.turn_on
entity_id:
- switch.fonstersovrum
data:
# 900 seconds = 15 minutes 3600 = 1h
transition: 3600

And for future reference it’s best to get in the habit of posting your code in the proper format per the blue box at the top of the page.

1 Like