Simple automation - don't get it there

Hello,

I’m currently despair with an actually simple automation.
We have a helper every minute in the bathroom Ambior, a toilet suction and water recognition (if the shower is running) and switched it on again (I have taped the Alexa on this).
Oh and a motion detector.

Now the ambient should always go out when moving, and if 30 seconds are not a movement, go out again.
That also works.
In addition, however, I would like to be delayed that the Ambi -Red Bi -Red Bi -Redeing Ambiors have been delayed until the water recognition and the toilet suction have been out for at least one minute.
Reason: This is how it goes out when you don’t move on the toilet or disappear behind the shower pane.

I created this automation:

alias: Bad Ambientlicht per Bewegung
description: Küche Ambientlicht per Bewegung
triggers:
  - entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_8190c306_ias_zone
    id: "ON"
    to: "on"
    trigger: state
  - entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_8190c306_ias_zone
    to: "off"
    for:
      hours: 0
      minutes: 0
      seconds: 30
    id: "OFF"
    trigger: state
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id: "ON"
          - condition: numeric_state
            entity_id: sensor.lumi_lumi_sensor_motion_aq2_8190c306_illuminance
            below: "150"
        sequence:
          - target:
              entity_id:
                - light.iluminize_5110_40_level_light_color_on_off
            data: {}
            action: light.turn_on
      - conditions:
          - condition: trigger
            id: "OFF"
        sequence:
          - wait_for_trigger:
              - trigger: state
                entity_id:
                  - input_boolean.alexa_bad_wassergrausch_wurde_erkannt
                  - switch.bad_wc_absaugung_shelly1_mini_3g_switch_0
                to: "off"
                for:
                  hours: 0
                  minutes: 1
                  seconds: 0
            timeout:
              hours: 0
              minutes: 15
              seconds: 0
              milliseconds: 0
          - target:
              entity_id:
                - light.iluminize_5110_40_level_light_color_on_off
            data: {}
            action: light.turn_off
    default: []
mode: single

Unfortunately, the light remains.
I suspect that the automation is waiting for the two waiting conditions to be triggered. However, this will not happen if you are only briefly in the bathroom.

Please help me.

LG Werner

I don’t quite understand what your automation is supposed to be doing, but two recommendations:

  1. Do not intermingle automations from different platforms. It makes it exponentially harder to achieve predictable outcomes. Whatever your Alexa automation does, re-implement it in HASS.

  2. Replace the PIR motion sensor with a mmWave occupancy sensor. Much less chance of false negatives due to someone sitting too still on the toilet, and also detects presence through at least my glass shower pane. If you want to stick with a PIR sensor, increase the for parameter to way more than 30 seconds.

Thanks for the reply. I also had a occupancy sensor, but I didn’t find anyone without a network current.
But now I have the solution with chat cpt:

alias: Bad Ambientlicht per Bewegung inkl. WC und Dusche
description: Bad Ambientlicht per Bewegung
triggers:
  - entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_8190c306_ias_zone
    id: "ON"
    to: "on"
    trigger: state
  - entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_8190c306_ias_zone
    to: "off"
    for:
      hours: 0
      minutes: 0
      seconds: 30
    id: "OFF"
    trigger: state
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id: "ON"
          - condition: numeric_state
            entity_id: sensor.lumi_lumi_sensor_motion_aq2_8190c306_illuminance
            below: 150
        sequence:
          - target:
              entity_id: light.iluminize_5110_40_level_light_color_on_off
            action: light.turn_on
            data: {}
      - conditions:
          - condition: trigger
            id: "OFF"
        sequence:
          - wait_template: >
              {{ is_state('input_boolean.alexa_bad_wassergrausch_wurde_erkannt',
              'off') 
                 and is_state('switch.bad_wc_absaugung_shelly1_mini_3g_switch_0', 'off') 
                 and (now() - states.input_boolean.alexa_bad_wassergrausch_wurde_erkannt.last_changed).total_seconds() > 120
                 and (now() - states.switch.bad_wc_absaugung_shelly1_mini_3g_switch_0.last_changed).total_seconds() > 120 }}
          - target:
              entity_id: light.iluminize_5110_40_level_light_color_on_off
            action: light.turn_off
            data: {}
    default: []
mode: single

LG Werner

You’re very close! The problem is indeed that the wait_for_trigger is waiting for both conditions to become “off” simultaneously. Since you might leave the bathroom before the water/suction turn off, that combined condition is never met. You need to wait for either of them to be off for one minute. tellthebell