Lights off when I leave home

No, do not get an error message, I will add the code of my sonoff.

switch:
  - platform: mqtt
    name: "keukenkastje"
    command_topic: "cmnd/keukenkastje/power"
    state_topic: "stat/keukenkastje/POWER"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    retain: true

Does this switch work if you trigger it manually?

Yes, I can manually switch the lamp on or off.

And your switch ā€˜keukenkastjeā€™ is included in the group switches ?

Guys, the name of the automation is invalid, it has a space in it.

People,

It works! I was unable to respond because I was new and had reached my response limit

This is the code:

automation 19:
  - alias: 'Rule 2 - Away Mode'
    trigger:
      platform: state
      entity_id: group.telefoon
      to: 'not_home'
    action:
      service: switch.turn_off
      entity_id: group.all_switches

But now I want the code that causes the lights to come on again when we get home, is only active between sunset and 11:30 PM. I tried everything but keep getting error messages.

Could you please your non-working code and the errors?

Try this:

automation 19:
  - alias: 'Rule 2 - Away Mode'
    trigger:
    - platform: state
      entity_id: group.telefoon
      to: 'not_home'
    condition:
    - condition: sun
      after: sunset
    - condition: time
      before: "23:30:00"
    action:
    - service: switch.turn_off
      entity_id: group.all_switches

You do not believe it but I put ā€˜conditionā€™ between you and suddenly no more error messages, very strange!

This is de code voor coming home:

automation 20:
  - alias: 'Rule 2 - Away Mode'
    trigger:
      platform: state
      entity_id: group.telefoon
      to: 'home'
    condition:
    - condition: sun
      after: sunset
    - condition: time
      before: "23:30:00"
    action:
      service: switch.turn_on
      entity_id: switch.staandelamptv, switch.staandelampbank, switch.keukenkastje, switch.eettafellamp

I donā€™t know what you mean with ā€œI put ā€˜conditionā€™ between youā€¦ā€ but Iā€™m glad it works now :slight_smile:

My thanks are very big, now on to the next problem haha, but Iā€™ll make a new topic for that!

I believe he was speaking about his first code didnā€™t have any conditions just trigger and action