Automation not working | choose element not picking the right path

Hi,

I have the following automation to do a few actions:

  • Lights (hal beneden / boven) on when it is between 07:45 and 23:15 when daylight level is below 8lx for 5 min.
  • Then when the doorbell is pressed (detected) lights in hal beneden for 3 minutes to 100% when lights are on / illuminance level below 8
  • lights off at 23:15
  • when between 23:15 and 07:45 lights on for 3 minutes when motion is detected.

I most likely make an error in my thinking somewhere as it is not working as I expect.
When the doorbell is rang (detected) light do not go to 100%.
Lights also do not switch on when light level is below 8.

Would there be someone so kind to point me in the right direction?

Thank you very much.

Bernard

alias: Hal - Dynamic Lighting with Time and Motion - NEW
description: >-
  Controls lights based on time, illuminance, and motion, with varying
  behaviors.
triggers:
  - entity_id:
      - binary_sensor.voordeur_rzw33_doorbell
    trigger: state
    to: "on"
  - at: "07:45"
    trigger: time
  - at: "23:15"
    trigger: time
  - entity_id: >-
      sensor.hal_bewegingssenor_hal_boven_hal_bewegingssenor_hal_boven_illuminance
    below: 7
    for:
      hours: 0
      minutes: 5
      seconds: 0
    trigger: numeric_state
  - entity_id: >-
      sensor.hal_bewegingssenor_hal_boven_hal_bewegingssenor_hal_boven_illuminance
    above: 6
    for:
      minutes: 5
    trigger: numeric_state
  - entity_id: >-
      binary_sensor.hal_bewegingssenor_hal_boven_hal_bewegingssenor_hal_boven_motion_sensor_status
    to: "on"
    trigger: state
conditions: []
actions:
  - choose:
      - conditions:
          - condition: time
            after: "07:45"
            before: "23:15"
        sequence:
          - choose:
              - conditions:
                  - condition: state
                    entity_id: binary_sensor.voordeur_rzw33_doorbell
                    state: "on"
                  - condition: numeric_state
                    entity_id: >-
                      sensor.hal_bewegingssenor_hal_boven_hal_bewegingssenor_hal_boven_illuminance
                    below: 8
                  - condition: state
                    entity_id: >-
                      light.hal_verlichting_hal_beneden_hal_verlichting_hal_beneden_dimmer_1
                    state: "on"
                sequence:
                  - data:
                      message: Doorbell pressed - Trigger fired
                      level: info
                    action: system_log.write
                  - data:
                      message: "Time condition met: {{ now().strftime('%H:%M') }}"
                      level: info
                    action: system_log.write
                  - data:
                      brightness_pct: 100
                    target:
                      entity_id: >-
                        light.hal_verlichting_hal_beneden_hal_verlichting_hal_beneden_dimmer_1
                    action: light.turn_on
                  - delay:
                      minutes: 3
                  - data:
                      brightness_pct: 20
                    target:
                      entity_id: >-
                        light.hal_verlichting_hal_beneden_hal_verlichting_hal_beneden_dimmer_1
                    action: light.turn_on
              - conditions:
                  - condition: numeric_state
                    entity_id: >-
                      sensor.hal_bewegingssenor_hal_boven_hal_bewegingssenor_hal_boven_illuminance
                    below: 8
                sequence:
                  - data:
                      brightness_pct: 20
                    target:
                      entity_id:
                        - >-
                          light.hal_verlichting_hal_beneden_hal_verlichting_hal_beneden_dimmer_1
                        - >-
                          light.verlichting_hal_boven_hal_verlichting_hal_boven_dimmer_1
                    action: light.turn_on
              - conditions:
                  - condition: numeric_state
                    entity_id: >-
                      sensor.hal_bewegingssenor_hal_boven_hal_bewegingssenor_hal_boven_illuminance
                    above: 8
                sequence:
                  - target:
                      entity_id:
                        - >-
                          light.hal_verlichting_hal_beneden_hal_verlichting_hal_beneden_dimmer_1
                        - >-
                          light.verlichting_hal_boven_hal_verlichting_hal_boven_dimmer_1
                    action: light.turn_off
                    data: {}
      - conditions:
          - condition: time
            after: "23:15"
            before: "07:45"
          - condition: state
            entity_id: >-
              binary_sensor.hal_bewegingssenor_hal_boven_hal_bewegingssenor_hal_boven_motion_sensor_status
            state: "on"
        sequence:
          - data:
              brightness_pct: 10
            target:
              entity_id:
                - >-
                  light.hal_verlichting_hal_beneden_hal_verlichting_hal_beneden_dimmer_1
                - light.verlichting_hal_boven_hal_verlichting_hal_boven_dimmer_1
            action: light.turn_on
          - delay:
              minutes: 3
          - target:
              entity_id:
                - >-
                  light.hal_verlichting_hal_beneden_hal_verlichting_hal_beneden_dimmer_1
                - light.verlichting_hal_boven_hal_verlichting_hal_boven_dimmer_1
            action: light.turn_off
            data: {}
      - conditions:
          - condition: time
            after: "23:15"
        sequence:
          - target:
              entity_id:
                - >-
                  light.hal_verlichting_hal_beneden_hal_verlichting_hal_beneden_dimmer_1
                - light.verlichting_hal_boven_hal_verlichting_hal_boven_dimmer_1
            action: light.turn_off
            data: {}
mode: single

What are you trying to accomplish with this syntax?

That probably isn’t doing what you want. It should be:

                      entity_id:
                        - light.hal_verlichting_hal_beneden_hal_verlichting_hal_beneden_dimmer_1
                        - light.verlichting_hal_boven_hal_verlichting_hal_boven_dimmer_1

Also, you might find it a lot simpler to separate this into several automations. There isn’t anything wrong per se with having a complicated set of triggers and then a complicated set of choose statements to sort out which fired, but it can be pretty error-prone.

Thanks will try that, tomorrow! That is what the visual editor created.

That’s surprising! When I try to use that to define a list on my end, I … don’t get a list.

Changing the syntax as suggested does not solve issue. Did checks in log and see that doorbell push is received in HA, so it should then trigger the automation.
Will make a new automation with just this piece in it to check if that will work.

Separation of automation’s is not what I would like, will need to many and will end up in 50 automations when I could do with 7 or 8.

Thanks for the support, any other suggestions why this is not functioning as expected are off course welcome!

  • You have a time trigger at: "07:45" which does nothing. Remove it. You’re already using it as a condition.
  • Your time trigger at 23:15 is doing nothing since your conditions are checking that it is after that time.
  • You have at least 2 choose paths using the same condition (time after 23:15).
  • You are not making use of Trigger IDs, which would solve the previous point.

Like @d921 said, you’re trying to do too much, all at once. Break it down into 2 or 3 separate automations and learn to use choose and TriggerIds properly first. Use the automation traces to figure out where they’re not behaving as expected. Then, once you get comfortable with how it all works, you can start merging stuff into a single automation.

Thanks this is helpful! When I have a bit more time I will watch the TriggerID video in full. Looks like what I am looking for :slight_smile:
Will post the out come of my quest later.

1 Like

So I have re-written the automation using Trigger ID’s. That seems to work as I would expect.
General remark, my time triggers are needed as I want to switch off the lights at 23:15. When left out lights will not switch of as there change in conditions.

Thanks for helping out :slight_smile:

1 Like