Switch the light group automatically but make manual switching possible

Hi there,

I despair again and would appreciate help.

I have the following light group that I want to switch:

# Gruppe Ambientlicht Küche
  - platform: group
    name: Ambientlicht Küche
    entities:
      - light.iluminize_hk_zd_rgbcct_a_5878befe_level_light_color_on_off
      - light.iluminize_hk_zd_rgbcct_a_44ada7fe_level_light_color_on_off

With the following automation I would like to achieve that the lighting group switches automatically. This also works, but not completely:

- id: '1630568859691'
  alias: 'Licht Ambient Küche bei Bewegung schalten '
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_8190c306_ias_zone
    to: 'on'
    id: 'ON'
  - platform: state
    entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_8190c306_ias_zone
    to: 'off'
    for: 00:00:10
    id: 'OFF'
  condition: []
  action:
  - choose:
    - conditions:
      - condition: trigger
        id: 'ON'
      - condition: state
        entity_id: light.ambientlicht_kuche
        state: 'off'
      - condition: numeric_state
        entity_id: sensor.lumi_lumi_sensor_motion_aq2_8190c306_illuminance
        below: '1000'
      sequence:
      - service: light.turn_on
        target:
          entity_id:
          - light.ambientlicht_kuche
        data: {}
    default:
    - service: light.turn_off
      target:
        entity_id:
        - light.ambientlicht_kuche
  mode: single

Two questions / problems:

  1. If one of the lights in the lighting group is switched on and the automation is triggered, the entire lighting group first goes off instead of on.
    Where is the error?

  2. How can I switch a light or a group of lights via Lovelace without it going off again due to the automation mentioned above?

Hope you can help me again.

Greetings Werner

Try using this-

trigger:
  - platform: state
    entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_8190c306_ias_zone
    id: 'ON'
    to: 'on'
  - platform: state
    entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_8190c306_ias_zone
    to: 'off'
    for: '00:10:00'
    id: 'OFF'
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: 'ON'
          - condition: numeric_state
            entity_id: sensor.lumi_lumi_sensor_motion_aq2_8190c306_illuminance
            below: '1000'
        sequence:
          - service: light.turn_on
            target:
              entity_id: light.ambientlicht_kuche
      - conditions:
          - condition: trigger
            id: 'OFF'
        sequence:
          - service: light.turn_off
            target:
              entity_id: light.ambientlicht_kuche
    default: []

I think it’s because when one of your entities in the group is ON, the group state will be ON. When the sensor is triggered (ON), the first choose condition where it needs light.ambientlicht_kuche to be OFF is not satisfied. Therefore, it goes to the default action.

You can find more information here-

1 Like

Hello and thank you very much.

That works great.
Now there is only my second problem:

I would like to have a switch in the Lovelace that does the following when switched on:
This automation and another automation (name: “LIcht-Arbeitsplatte”) should be switched to inactive for 3 hours and 30 minutes, after which they should be automatically reactivated.

Is that also possible?

Thanks again.

Create an input_boolean-

input_boolean:
  light_automation_manual_override:
    name: Light Automation Manual Override

Create a button card in your lovelace dashboard with tap action of input_boolean.turn_on targeted to input_boolean. light_automation_manual_override. When you want to override your automation, you press the button card on your lovelace.

Create an automation to turn off the input_boolean after they are ON for 3.30 hours-

trigger:
  - platform: state
    entity_id: input_boolean.light_automation_manual_override
    to: 'on'
    for: '03:30:00'
condition: []
action:
  - service: input_boolean.turn_off
    target:
      entity_id: input_boolean.light_automation_manual_override

Lastly, on your light automation, add a condition-

condition:
  - condition: state
    state: 'off'
    entity_id: input_boolean.light_automation_manual_override

Hi there,

that doesn’t work yet, I probably inserted the condition (input_boolean.lichtautomation_kuche_aus) in the wrong place.

It looks like this for me now:

- id: '1630568859691'
  alias: 'Licht Ambient Küche bei Bewegung schalten '
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_8190c306_ias_zone
    to: 'on'
    id: 'ON'
  - platform: state
    entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_8190c306_ias_zone
    to: 'off'
    for: 00:00:10
    id: 'OFF'
  condition: []
  action:
  - choose:
    - conditions:
      - condition: trigger
        id: 'ON'
      - condition: state
        entity_id: light.ambientlicht_kuche
        state: 'off'
      - condition: state
        state: 'off'
        entity_id: input_boolean.lichtautomation_kuche_aus
      - condition: numeric_state
        entity_id: sensor.lumi_lumi_sensor_motion_aq2_8190c306_illuminance
        below: '1000'
      sequence:
      - service: light.turn_on
        target:
          entity_id:
          - light.ambientlicht_kuche
        data: {}
    default:
    - service: light.turn_off
      target:
        entity_id:
        - light.ambientlicht_kuche
  mode: single
- id: '1630589206080'
  alias: Lichtautomation Küche aus
  description: Helfer (input_boolean.lichtautomation_kuche_aus) wird nach Zeit ausgeschalten
  trigger:
  - platform: state
    entity_id: input_boolean.lichtautomation_kuche_aus
    to: 'on'
    for: 00:10:00
  condition: []
  action:
  - service: input_boolean.turn_off
    target:
      entity_id: input_boolean.lichtautomation_kuche_aus
  mode: single

Or is it because I went into the room, the light went on automatically and only then did I press the Boolean switch?

Greetings Werner

trigger:
  - platform: state
    entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_8190c306_ias_zone
    id: 'ON'
    to: 'on'
  - platform: state
    entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_8190c306_ias_zone
    to: 'off'
    for: '00:10:00'
    id: 'OFF'
condition:
  - condition: state
    state: 'off'
    entity_id: input_boolean.light_automation_manual_override
action:
  - choose:
      - conditions:
          - condition: trigger
            id: 'ON'
          - condition: numeric_state
            entity_id: sensor.lumi_lumi_sensor_motion_aq2_8190c306_illuminance
            below: '1000'
        sequence:
          - service: light.turn_on
            target:
              entity_id: light.ambientlicht_kuche
      - conditions:
          - condition: trigger
            id: 'OFF'
        sequence:
          - service: light.turn_off
            target:
              entity_id: light.ambientlicht_kuche
    default: []
1 Like

I just can not manage it.

With this code:

- id: '1630568859691'
  alias: 'Licht Ambient Küche bei Bewegung schalten '
  description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_8190c306_ias_zone
    id: 'ON'
    to: 'on'
  - platform: state
    entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_8190c306_ias_zone
    to: 'off'
    for: '00:10:00'
    id: 'OFF'
condition:
  - condition: state
    state: 'off'
    entity_id: input_boolean.lichtautomation_kuche_aus
action:
  - choose:
      - conditions:
          - condition: trigger
            id: 'ON'
          - condition: numeric_state
            entity_id: sensor.lumi_lumi_sensor_motion_aq2_8190c306_illuminance
            below: '1000'
        sequence:
          - service: light.turn_on
            target:
              entity_id: light.ambientlicht_kuche
      - conditions:
          - condition: trigger
            id: 'OFF'
        sequence:
          - service: light.turn_off
            target:
              entity_id: light.ambientlicht_kuche
    default: []

I get the following error message:

end of the stream or a document separator is expected at line 421, column 1:
    trigger:
    ^

And is it correct with that new code

    default:
    - service: light.turn_off
      target:
        entity_id:
        - light.ambientlicht_kuche

by

    default: []

is replaced?

Note: I have given my input boolean the following name:

I’m sorry, I’m a complete beginner.

Greetings Werner

A moment please. The error message suddenly disappeared. I have to test, but my wife is out in the kitchen :slight_smile:

If you want to copy my code, go to Automation Editor UI —> Create Automation —> On the right hand side there are three dots —> Edit in YAML.

Correct. I moved it under the choose action by specifying the condition trigger OFF.

Hi there,

I have now inserted it via the user interface.
The automation works too.
But although the helper “input_boolean.lichtautomation_kuche_aus” is switched on, the light goes out.
The automation is considered not to be stopped.
I do not understand that.

Greetings Werner

Can you post here your exact code?

  1. Input Boolean
  2. Automation

I am very sorry.
The problem was that I hadn’t turned off the old automation.
It couldn’t work there.

I still have to test it a bit, but I think everything works.

Thanks again. Without people like you, I wouldn’t have a smart home.
Thanks !!!

Greetings Werner