Automation question for multi actions

Hello, I would like to do an automation:
The trigger is based on a presence captor.

I would like to have a text played if the home presence is detected between 7 and 23h and
I would like to turn on light for 10 minutes if it is during the night.

Actually, the text is played but the light doesnt turn on.

I would like to write other automation with multi actions and conditions, so I have to unserstand how to do that …

Best regard
Thierry

https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371/4

Please post the automation in question.

The Choose action can be used to execute different action sequences based on specific conditions within a single automation.

Hello, I would like to do an automation:
The trigger is based on a presence captor.

I would like to have a text played if the home presence is detected between 7 and 23h and
I would like to turn on light for 10 minutes if it is during the night.

Actually, the text is played but the light doesnt turn on.

I would like to write other automation with multi actions and conditions, so I have to unserstand how to do that …

here is my actual code:

alias: "service_door_presence_automation"
trigger:
  - platform: state
    entity_id: binary_sensor.service_door_presence
    to: "on"
    for:
      seconds: 5

action:
  - condition: time
    after: "07:00:00"
    before: "23:00:00"

  - service: tts.google_say
    data:
      entity_id: media_player.cuisine
      message: "Il y a quelqu'un devant la porte de service."
      language: "fr"

  - condition: sun
    after: sunset
    before: sunrise

  - service: homeassistant.turn_on
    data:
      entity_id: switch.lampes_exterieurs_2

  - delay: "00:10:00"

  - service: homeassistant.turn_off
    data:
      entity_id: switch.lampes_exterieurs_2

Best regard
Thierry

Actions are executed in sequence, so in order for the “turn on” action to occur both the Time and Sunset/sunrise conditions would need to be true.

The way you have set up the Sunset/sunrise condition does not contain the required “Or” condition when trying to specify a “when-dark” state. Don’t blame yourself, the docs are poorly written and there have been multiple PR’s to change them, but those requests have been rejected. As written, it will always be false. That is why the light actions are not executing.

The condition before sunrise AND after sunset is never met… So the light cannot switch on…
You should have the following condition:

  condition: state  
  entity_id: sun.sun
  state: "below_horizon"

thanks for your reply.
I understand action is executed in sequence.

Is that possible to write an automation with action for several conditions ?
for example play text if time is between x and y and turn light on when sun is below horizon ?
So my question is that possible to have action for separate conditions ?

Many thanks for your help, it is very appreciated !

Sure, if I understand correctly your question, the following should answer it.
You can use more than one “choose” in a serie of actions, see the following documentation

You have to look at this example in the doc:

# Example with "if" and "if"
automation:
  - alias: "Turn lights on when the sun gets dim and if some room is occupied"
      trigger:
        - platform: numeric_state
          entity_id: sun.sun
          attribute: elevation
          below: 4
      action:
        # This must always apply
        - service: light.turn_on
          data:
            brightness: 255
            color_temp: 366
          target:
            entity_id:
              - light.porch
              - light.garden
        # IF a entity is ON
        - choose:
            - conditions:
                - condition: state
                  entity_id: binary_sensor.livingroom_tv
                  state: "on"
              sequence:
                - service: light.turn_on
                  data:
                    brightness: 255
                    color_temp: 366
                  target:
                    entity_id: light.livingroom
         # IF another entity not related to the previous, is ON
        - choose:
            - conditions:
                - condition: state
                  entity_id: binary_sensor.studio_pc
                  state: "on"
              sequence:
                - service: light.turn_on
                  data:
                    brightness: 255
                    color_temp: 366
                  target:
                    entity_id: light.studio

many thanks.
If I undestand the example you send me:

In all cases the sun elevation below 4 is the trigger.
In all cases, the porch light and garden light are turned on.

If the living room_tv is on the living room light will be turned on

if the studio pc is on the studio light will be turned on

@vormsty Correct…