Automation gone wrong

Hi guys,

I’ve created an automation to turn a few things off at a certain time, while it runs it stops after the first and doesn’t contine. Any ideas what changes i require?

- id: weekday_off_11pm
  alias: 'Weekday everything off 11PM'
  trigger:
    platform: time
    at: '23:00:00'
  condition:
    condition: time
    weekday:
     - sun
     - mon
     - tue
     - wed
     - thu
  action:
    service: homeassistant.turn_off
    entity_id:
     - switch.front_room_tv 
     - switch.front_room_light
     - switch.front_room_heater
     - switch.kitchen_lightsdown
     - switch.kitchen_lightsup 
     - switch.garden_lights

That makes sense, thanks zarthan i’ll give that a go.

I edited my response and added.

I just thought,

would a

entity_id: group.all_devices

fix it as well?

I had a go with a couple of options, the first i get issues with the first.

Configuration invalidError loading /config/configuration.yaml: while parsing a block mapping in “/config/automations.yaml”, line 114, column 5 expected , but found ‘-’ in “/config/automations.yaml”, line 118, column 5

# Working Week Everything off at 01:00
- id: weekday_off_1AM
  alias: 'Weekday everything off 1AM'
  trigger:
    platform: time
    at: '01:00:00'
  condition:
    condition: time
    weekday:
     - fri
     - sat
    - platform: state
      entity_id: 
       - switch.front_room_tv
       - switch.front_room_heater
       - switch.front_room_light 
       - switch.kitchen_lightsdown 
       - switch.kitchen_lightsup
       - switch.garden_lights         
      to: 'home'
  condition:
    - condition: state
      entity_id: group.all_devices
      state: 'home'
  action:
    service: homeassistant.turn_off
    entity_id: 
     - switch.front_room_tv
     - switch.front_room_heater
     - switch.front_room_light 
     - switch.kitchen_lightsdown 
     - switch.kitchen_lightsup
     - switch.garden_lights    

The 2nd does seem to be accepted, but if you check the automation in HA then it doens’t show the indavidual switches so i don’t have much faith in it working correctly.

# Working Week Everything off at 01:00
- id: weekday_off_11pm
  alias: 'Weekday everything off 1AM'
  trigger:
    platform: time
    at: '01:00:00'
  condition:
    condition: time
    weekday:
     - sun
     - fri
     - sat
  action:
    service: homeassistant.turn_off
    entity_id: switch.front_room_tv
  action:
    service: homeassistant.turn_off
    entity_id: switch.front_room_heater
  action:
    service: homeassistant.turn_off
    entity_id: switch.front_room_light 
  action:
    service: homeassistant.turn_off
    entity_id: switch.kitchen_lightsdown 
  action:
    service: homeassistant.turn_off
    entity_id: switch.kitchen_lightsup
  action:
    service: homeassistant.turn_off
    entity_id: switch.garden_lights

Looks like your entries following the entity_id line are only intended 1 space instead of 2

  action:
    service: homeassistant.turn_off
    entity_id:
     - switch.front_room_tv 
     - switch.front_room_light
     - switch.front_room_heater
     - switch.kitchen_lightsdown
     - switch.kitchen_lightsup 
     - switch.garden_lights

Hi chairstacker, thanks for helping.

It did accept zarthan’s entries but i didn’t test the automation yet. I’ll have a look at yours, i ended up using some groups rather than individual switches, so i’m hoping that will also work to make the code a bit easier to read. I’ll play around with it later on.

I’m still confused about your underlying issue. The code looks correct and I would expect it to shut your lights off every night at 11 pm.

Are you saying that it only shuts it off on the first night? Or are you saying that it should continually shut off after 11pm?

Hi Pedro, i’ve just fixed this actually so i can explain the issue.

The automation would run, but only the first entity would switch from on to off, but the rest would not.

It actually turned out to be a really simple issue. Under the entines i had the below;

service: homeassistant.turn_off
entity_id:
 - switch.front_room_lamp
 - switch.garden_lights
 - switch.kitchen_lightsup
 - switch.kitchen_lightsdown
 - switch.front_room_tv
 - switch.electric_heater_fr

While this looks correct, it is only slightly wrong (the worst kind) and i had a space before the dash, for i guess all but one of the entries. When i removed this dash, the automation run in full, and all devices switched off. Like below;

service: homeassistant.turn_off
entity_id:
- switch.front_room_lamp
- switch.garden_lights
- switch.kitchen_lightsup
- switch.kitchen_lightsdown
- switch.front_room_tv
- switch.electric_heater_fr