Automation with Condition Driving Me To the Mad House

I would like to get my living room lights to turn on on weekdays only. I’ve tried several different suggestions I’ve found and none seem to get me there. I’m sure it’s something silly, but I could use some help from the community.

- alias: LR On Morning
  initial_state: 'on'
  trigger:
    platform: time
    at: '05:30:00'
    condition: time
    weekday:
      mon
      tue
      wed
      thu
      fri
  action:
    entity_id: scene.livingroomon
    service: scene.turn_on

You need to add condition: and use proper formatting and spacing as in the docs

Try this:

- alias: LR On Morning
  initial_state: 'on'
  trigger:
    platform: time
    at: '05:30:00'
  condition:
    condition: time
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
  action:
    entity_id: scene.livingroomon
    service: scene.turn_on

Your request for help is fairly ambiguous, as it doesn’t say what’s not working. That said, your condition isn’t complete.

It should be

trigger:
  platform: time
  at: '05:30:00'
condition:
  condition: time
    weekday:
      - mon
      ...etc.

More here: https://home-assistant.io/docs/scripts/conditions/

When I do it as sjee suggests and have Home Assistant check config, this is the error reported.

Invalid config for [automation]: [condition] is an invalid option for [automation]. Check: automation->trigger->0->condition. (See /home/homeassistant/.homeassistant/configuration.yaml, line 166). Please check the docs at https://home-assistant.io/components/automation/

When I do it as mconway suggests, this is the error reported

[homeassistant.util.yaml] mapping values are not allowed here  in "/home/homeassistant/.homeassistant/automation.yaml", line 30, column 14

These are the two errors I was getting and I’ve read all the docs, tried indenting every way I could think of.

Maybe try this?

- alias: LR On Morning
  initial_state: 'on'
  trigger:
    platform: time
    at: "05:30:00"
  condition:
    condition: time
    after: "05:29:59"
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
  action:
    entity_id: scene.livingroomon
    service: scene.turn_on

It’s not elegant, but I think the ‘after’ or ‘before’ part is missing from the time condition.

Check config came back good. I restarted Home Assistant with this and it seems to not complain. I’ll let you know the results tomorrow. Thank you all.

1 Like

That got it! The living room lights stayed off this morning. I’ve been trying to get this working off and on for a while now. Looking at what it took, it makes sense but you’re right, it isn’t elegant at all.

1 Like