Shower Door Trigger Light Help

Hi there -

I’ve been struggling with an automation for a few days now and can not figure it out. This is due to my lack of knowledge and experience with HA, so I greatly appreciate any advice.

I have a contact sensor on our shower door that triggers the shower fan/light. I want to run it for 20 minutes once the door has opened and not re-trigger when opening it once finished in the shower.

This automation works most of the time by checking if the light is in an “off state” before running the animation, but this also causes the automation to stop and not switch off the light.

Below with a couple of screengrabs and code.

Thank you in advance.

id: '1644759371723'
alias: Door - Shower
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.door_shower
    from: 'off'
    to: 'on'
condition:
  - condition: state
    entity_id: light.lights_shower
    state: 'Off'
    for:
      hours: 0
      minutes: 5
      seconds: 0
action:
  - service: light.turn_on
    target:
      entity_id: light.lights_shower
  - delay:
      hours: 0
      minutes: 20
      seconds: 0
      milliseconds: 0
  - service: light.turn_off
    target:
      entity_id: light.lights_shower
mode: single


state: 'off'

Case matters.

Ha! Thank you, I’ll update it and try that.

It seems that when you open the door after using the shower, the “light off” condition aborts the automation and then doesn’t switch it off after 20 min. See screengrab below:

Any ideas on how to run the 20 mins timer once - when opening the door? If I remove the “light on” condition it will simply run again once getting out of the shower.

:thinking:

id: '1644759371723'
alias: Door - Shower
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.door_shower
    from: 'off'
    to: 'on'
action:
  - service: light.turn_on
    target:
      entity_id: light.lights_shower
    data: {}
  - wait_for_trigger:
      - platform: state
        entity_id: binary_sensor.door_shower
        from: 'off'
        to: 'on'
    continue_on_timeout: false
  - delay:
      hours: 0
      minutes: 20
      seconds: 0
      milliseconds: 0
  - service: light.turn_off
    target:
      entity_id: light.lights_shower
    data: {}
mode: single

Will this only run once and not start all over again when opening the for after the shower?

Thank you in advance.

I’m not sure why you are seeing the results that you are.

the “mode: single” should prevent the automation from re-triggering while the 20 minute wait timer is running.

But since it isn’t working as expected then I can offer another suggestion to see if it works better…

create an automation that uses the door sensor opening to turn on an input_boolean.

then in your automation above you will use the boolean turning on to trigger the automation

then as the last step of the automation above turn off the boolean.

alias: Door - Shower - Boolean
trigger:
  - platform: state
    entity_id: binary_sensor.door_shower
    from: 'off'
    to: 'on'
condition:
  - condition: state
    entity_id: input_boolean.some_boolean_name
    state: 'off'
action:
  - service: input_boolean.turn_on
    target:
      entity_id: input_boolean.some_boolean_name
mode: single

id: '1644759371723'
alias: Door - Shower
description: ''
trigger:
  - platform: state
    entity_id: input_boolean.some_boolean_name
    to: 'on'
action:
  - service: light.turn_on
    target:
      entity_id: light.lights_shower
  - delay:
      hours: 0
      minutes: 20
      seconds: 0
      milliseconds: 0
  - service: light.turn_off
    target:
      entity_id: light.lights_shower
  - service: input_boolean.turn_off
    target:
      entity_id: input_boolean.some_boolean_name
mode: single

that way it doesn’t matter what you do with the door. you can open it as many times as you want and it will only turn the boolean on if it’s off and all of the other stuff is controlled by the state of the bollean.

You’re totally awesome. I know understand helpers. Thank you so much!

1 Like