Cant figure out how to config automations.yaml

Hi!
Im new here. I have set up Home Assistant and it is working fine.

But, when I try automations nothing goes as I want.

I want a lamp in my bedroom to light up at a certain time. But I cant manage this. Config test says it valid, but HA tells me that theres a configuration error. If I restart, HA wont start. It gives me a refused connection.

I have been playing around a lot with both these examples. But what am I doing wrong?

In automations.yaml: (Not both at once)

 - alias: "Sovrumslampa"
    trigger:
      - platform: time
      hours: 00
      minutes: 45
      seconds: 30
    action:
      - service: light.turn_on
        entity_id: light.bedroom_left
        
        
        
- alias: Sovrumslampa
  trigger:
    - platform: time
    after: "01:34:00"
  condition:
    - condition: time
    weekday:
      - mon
      - wed
      - fri
  action:
    service: light.turn_on
    entity_id: light.bedroom_left   

And in my configuration.yaml is:
automation: !include automations.yaml

Looks like both versions have spacing errors.
Try this one instead of your first option:.

- alias: "Sovrumslampa"
  trigger:
    platform: time
    hours: 00
    minutes: 45
    seconds: 30
  action:
    service: light.turn_on
    entity_id: light.bedroom_left

Some people even recommend putting single quotes around the numbers, e.g. ‘45’

Here’s an example with a condition that works fine in my config file:

- alias: Turn off living room light at 23:46h if nobody is home
  trigger:
    platform: time
    hours: 23
    minutes: 46
    seconds: 19
  condition: 
    condition: state
    entity_id: group.people
    state: 'not_home'
  action:
    service: homeassistant.turn_off
    entity_id: switch.hook_b3
1 Like

Thank you! Your example worked!
But if I in HA go to automations it says: We couldn’t find any editable automations.

I also wonder what spacing error is?

In order to be able to edit an automation in the HA frontend it needs to have a unique ID - for details see towards the bottom of this page: https://home-assistant.io/docs/automation/editor/

Re. the spacing error: YAML is very particular about the spaces you need to add for each indentation on each level.

I’m not very good at it, some I’m doing a lot of trial & error myself, but I’d try something like this

 - alias: Sovrumslampa
   trigger:
     platform: time
     after: "01:34:00"
   condition:
     condition: time
     weekday:
       - mon
       - wed
       - fri
   action:
     service: light.turn_on
     entity_id: light.bedroom_left

Hi.I’m new in here.Please,help me how to add a single time shedule for one light.i don’t know how can I do it.i want my light turn on at morning 05:00 and turn off at late night 23:00.thanks. :slight_smile:

You will need one automation for turning it on and one for turning it off.

Look at the examples above

thanks!i see what you say but I don’t understand too much. can you write me an example?please.sorry for my english if is bad.

there are literally 2 examples above…

ahhhh.I understand now.and working.i’m new on linux too.thanks!Home Assistant is the best!