Same automation with differenct conditions

Hi guys,

by now I’m having two automations to turn off the lights depending on the brightness in my living room:

alias: Licht aus bei Helligkeit
description: ''
trigger:
  - type: value
    platform: device
    device_id: 021d216e8342c03ed4abdb83abf3623b
    entity_id: sensor.bh1750_lichtsensor
    domain: sensor
    above: 60
condition:
  - condition: sun
    after: sunrise
action:
  - scene: scene.alle_lichter_aus
  - scene: scene.status_leds_50
mode: restart

This one turns all lights off when the brigtness is too low.

alias: Licht aus bei Helligkeit - "Kochen" aktiviert
description: ''
trigger:
  - type: value
    platform: device
    device_id: 021d216e8342c03ed4abdb83abf3623b
    entity_id: sensor.bh1750_lichtsensor
    domain: sensor
    above: 60
condition:
  - condition: sun
    after: sunrise
  - condition: state
    entity_id: input_boolean.kochen
    state: 'on'
action:
  - scene: scene.alle_lichter_aus_ausser_kuchenzeile
  - scene: scene.status_leds_50
mode: single

This one turns all lights off when the brigtness is too low. Exception: I’m cooking => the kitchen light should stay on.

Obviously the second one is more important because I don’t want to stand in the darkness while cooking => is it correct to set automation1 with the scene action to restart and automation2 to single (so the single one is not “overwritten” by the restart one)?

Isn’t this possible with only one automation with a condition like this?

if  
  - condition: sun
    after: sunrise
then
    if
      - condition: state
        entity_id: input_boolean.kochen
        state: 'on'
    then call scene.alle_lichter_aus_ausser_kuchenzeile
    else
        call scene.alle_lichter_aus
    endif
endif

You can use the choose type action. It can accommodate these two automations into one like below.

alias: Licht aus bei Helligkeit
description: ''
trigger:
  - type: value
    platform: device
    device_id: 021d216e8342c03ed4abdb83abf3623b
    entity_id: sensor.bh1750_lichtsensor
    domain: sensor
    above: 60
condition:
  - condition: sun
    after: sunrise
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: input_boolean.kochen
            state: 'on'
        sequence:
          - scene: scene.alle_lichter_aus_ausser_kuchenzeile
          - scene: scene.status_leds_50
    default:
      - scene: scene.alle_lichter_aus
      - scene: scene.status_leds_50
mode: restart

You can try this:

action: 
  - condition: sun
    after: sunrise
  - scene: scene.alle_lichter_aus_ausser_kuchenzeile
  - condition: state
    entity_id: input_boolean.kochen
    state: 'off'
  - scene: scene.alle_lichter_aus

Yet another way:

alias: Licht aus bei Helligkeit
description: ''
trigger:
  - type: value
    platform: device
    device_id: 021d216e8342c03ed4abdb83abf3623b
    entity_id: sensor.bh1750_lichtsensor
    domain: sensor
    above: 60
condition:
  - condition: sun
    after: sunrise
action:
  - service: scene.turn_on
    target:
      entity_id:
        - "scene.alle_lichter_aus{{ '_ausser_kuchenzeile' if is_state('input_boolean.kochen', 'on') else '' }}"
        - scene.status_leds_50

Looks pretty nice and like something I thought of. I’ll test it tonight when I’m back home. Thanks for your quick response, I’ll give a feedback about it!

Also very nice! Need to test this tonight.