Lights off script not working

I want to create a script that turns off all of my lights and turns off some motion sensor automations. The automations turn off after executing the script but the lights stay on. Can anyone help me with this issue?

This is my cofig in scripts.YAML:

  alias: Morning
    service: automation.turn_on
       - group.all_automations
  alias: Night
    - service: automation.turn_off
      entity_id: group.all_automations
    - service: light.turn_off
      entity_id: group.all_lights

Maybe try:

    - service: light.turn_off
      entity_id: all

Nope! still doesn’t work :thinking:

There’s no reason I can see that it shouldn’t work. Have you checked the log for errors? Have you tried executing the service from the Services page?

I just fixed it! It was just a dumb mistake. I forgot that my sonoffs obviously count as switches so I just added a turn off switch service and now it works a treat.