Dont look for motion, if humidity is high

Hello.
First post, so if I am doing something wrong according to the rules, just let me know.

I am trying to automate the lights on our bathroom. Right now it is just a motion sensor. And thats fine. Untill you shower. Then it cant see you, and after 10 min it turns of the light. (Got teenagers in the house, so +10 min bath is a thing :sweat_smile:).
I have bought a temp+hum sensor. The idea is, that the motion sensor should not work (pause) if the humidity in the room is above, lets say 65%.

My yaml are as follow:

alias: Lys pƄ toilettet via sensor og fugtmƄling
description: ''
trigger:
  - type: motion
    platform: device
    device_id: c596df1b9e60693cc64eb5f970f9dedc
    entity_id: binary_sensor.0x00158d0007759e46_occupancy
    domain: binary_sensor
condition: []
action:
  - service: light.turn_on
    data: {}
    target:
      entity_id:
        - light.gruppe_toilet_lys
  - wait_for_trigger:
      - type: no_motion
        platform: device
        device_id: c596df1b9e60693cc64eb5f970f9dedc
        entity_id: binary_sensor.0x00158d0007759e46_occupancy
        domain: binary_sensor
        for:
          hours: 0
          minutes: 10
          seconds: 0
  - service: light.turn_off
    data: {}
    target:
      entity_id:
        - light.gruppe_toilet_lys
mode: restart

How do I set that condition right? The motion sensor has to be activ any other time, when no 1 is in the shower.

You donot have a condition set yet.
The order seems fine. the trigger is ALWAYS the motion detector and with the additonal condition you will add you can add state of humidity sensor to be below 65
However, if one kid showered and humidity is above 65% and the second person wants to showerā€¦ the light will not turn onā€¦think about that use-case too :slight_smile:

Doing something similar in my bathroom with this automation:

- alias: Badkamer_Occupancy_Lights_day_on
  description: 'Badkamerverlichting overdag op basis van motion en occupancy'
  mode: single
  max_exceeded: silent
  trigger:
    - entity_id: binary_sensor.master_bath_sensors
      platform: state
      to: 'on'
    - entity_id: binary_sensor.badkamer_pir_occupancy
      platform: state
      to: 'on'
  condition:
    condition: and
    conditions:
      - condition: time
        after: '9:00'
        before: '23:30'
      - condition: state
        entity_id: light.hue_ambiance_spot_3
        state: 'off'
      - condition: or
        conditions:
        - condition: state
          entity_id: input_boolean.bedweightdetected
          state: 'off'
        - condition: state
          entity_id: light.shellydimmer2_e8db84d3086e
          state: 'on'
  action:
    - service: scene.turn_on
      entity_id: scene.hele_badkamer_ontspannenhoog
    - service: light.turn_on
      data:
        entity_id: light.shellyrgbw2_1e03d3_channel_1
        brightness: 200

The master bath sensor is a templated sensor like this (in configuration.yaml):

  - platform: template
    sensors:
      master_bath_sensors:
        friendly_name: "Master Bath Sensors"
        value_template: >-
          {{ is_state('input_boolean.net_gedouched', 'on')
             or is_state('binary_sensor.badkamer_pir_occupancy', 'on') }}

This template lets sensors work together as one, I also use a temp/humidity sensor, but on an average that switches a boolean. That boolean is called ā€˜input_boolean.net_gedouchedā€™

Lights are switched off based on this automation;

# Lichten uit als timer is afgelopen 
- alias: timer_badkamer_done
  mode: single
  max_exceeded: silent
  trigger:
  - entity_id: binary_sensor.master_bath_sensors
    for: '00:15:00'
    platform: state
    to: 'off'
  condition:
      - condition: state
        entity_id: binary_sensor.master_bath_sensors
        state: 'off'
  action:
    - service: light.turn_off
      data:
        entity_id:
        - light.hele_badkamer
        - light.shellyrgbw2_1e03d3_channel_1

Maybe a but elaborate for what you want, the reason behind this, is that I also turn on the ventilation based on these input booleans. Sky is the limit :wink:

Yeah. That case is my main problem. To set a condition is not that hard. But I cant get my head around how to solve the waiting time untill the humidity is low again.

Question: why would you not want the lights to switch when the humidity is high?
And, imo you donot have to calculate waiting time because the sensor will indicate when % is low(er) again

God question. I dont want them to switch. I want them to stay on.
I have been looking at it again, and the idea is, that if the light is on, because of motion, then it shall not turn of after 10 min (like normal) if the humidity is high.

Makes sense?

The problem is a wait condition doesnā€™t offer much flexibility.

Use a timer:

On ā€œmotionā€, Cancel the timer, turn on the lights.

On ā€œno motionā€, start the timer with a 5 (or whatever) minute timeout.

On timer.finished, If humidity above threshold restart the timer. If below threshold turn off the lights.

Below was extracted and cleaned up from my automation. It may not be 100% functional, but should give an idea of what Iā€™m doing:

alias: Hall Bath Vacancy Start
description: ''
trigger:
  - platform: state
    entity_id:
      - binary_sensor.hall_bath_motion_detector
    from: 'on'
    to: 'off'
condition: []
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: binary_sensor.door_hall_bath_contact
            state: 'off'
        sequence:
          - service: timer.start
            data:
              duration: '00:10:00'
            target:
              entity_id: timer.hall_bath_motion
    default:
      - service: timer.start
        data:
          duration: '00:05:00'
        target:
          entity_id: timer.hall_bath_motion
mode: single


#------------------------------------------------------------------------------------


alias: Hall Bath Vacancy Timeout
description: ''
trigger:
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.hall_bath_motion
condition: []
action:
  - choose:
      - conditions:
          - condition: or
            conditions:
              - condition: state
                entity_id: light.hall_bath_lights
                state: 'on'
              - condition: state
                entity_id: switch.hall_bathroom_exhaust_fan
                state: 'on'
        sequence:
          - choose:
              - conditions:
                  - condition: numeric_state
                    entity_id: sensor.hall_bath_net_humidity
                    below: '6'
                sequence:
                  - service: light.turn_off
                    target:
                      area_id: hall_bathroom
                    data: {}
                  - service: switch.turn_off
                    target:
                      entity_id: switch.hall_bathroom_exhaust_fan
          - choose:
              - conditions:
                  - condition: numeric_state
                    entity_id: sensor.hall_bath_net_humidity
                    above: '5.99'
                    below: '15'
                sequence:
                  - service: light.turn_off
                    target:
                      area_id: hall_bathroom
                    data: {}
                  - service: timer.start
                    data:
                      duration: '00:05:00'
                    target:
                      entity_id: timer.hall_bath_motion
          - choose:
              - conditions:
                  - condition: numeric_state
                    entity_id: sensor.hall_bath_net_humidity
                    above: '14.99'
                sequence:
                  - service: timer.start
                    data:
                      duration: '00:05:00'
                    target:
                      entity_id: timer.hall_bath_motion
    default: []
mode: queued
max: 10
1 Like

So the assumption is that humidity means ā€˜in useā€™ and thus not switch offā€¦makes more sense to me :slight_smile:
Ideal would be to have the motion/presence sensor in the bathroom as then the only parameter is ā€˜motionā€™ (assuming people move in the bathroom), humidity or not would not be inmportantā€¦just the presence of someoneā€¦less sensors to check too

But not workable when someone is in the shower.

He could add a second PIR sensor inside the shower, or use a secondary parameter like humidity. Heā€™s already purchased the humidity sensor, as had I for fan control.

The mmwave sensors might solve the problem. I suspect the would see through a shower curtain. Curious to see if they see through glass.

Iā€™ve found my automation to be very reliable with no wife/kid/guest complaints.

My condition just dont turn light off when humidity is above 70

A condition based on humidity seems fragile. My daughters spend ages doing makeup at the mirror. I included a door sensor - when the door is closed, cancel the timer to turn the light off. Then when the door is opened, start the timer again (similarly if motion goes to off and the door is open, in case they never closed the door initially). This works for me because we always leave the bathroom door ajar when not in use.

How do you make such an condition
I cant seem to get it right

How about this one.
2 trickers.
If the humidity is above 70 = turn lights on
If the sensor see motion = turn lights on

If the humidity is under 70 = turn lights off after 2 min.
If sensor has no motion in 2 min = turn lights of.

Will that work?

If i dont move, but the humidity is above 70 (Standing in shower) the light will turn on
If the humidity drops below 70 but i am moving (Open window and me getting out of shower) lights will turn on.

Or will the two collide?

description: ''
trigger:
  - type: humidity
    platform: device
    device_id: a699e1dc52fe5b996bb92f8c09d8c89e
    entity_id: sensor.0x00124b00252134c7_humidity
    domain: sensor
    above: 70
  - type: motion
    platform: device
    device_id: c596df1b9e60693cc64eb5f970f9dedc
    entity_id: binary_sensor.0x00158d0007759e46_occupancy
    domain: binary_sensor
condition: []
action:
  - service: light.turn_on
    data: {}
    target:
      entity_id: light.gruppe_toilet_lys
  - wait_for_trigger:
      - type: humidity
        platform: device
        device_id: a699e1dc52fe5b996bb92f8c09d8c89e
        entity_id: sensor.0x00124b00252134c7_humidity
        domain: sensor
        below: 70
      - type: no_motion
        platform: device
        device_id: c596df1b9e60693cc64eb5f970f9dedc
        entity_id: binary_sensor.0x00158d0007759e46_occupancy
        domain: binary_sensor
        for:
          hours: 0
          minutes: 2
          seconds: 0
  - service: light.turn_off
    data: {}
    target:
      entity_id: light.gruppe_toilet_lys
mode: restart

Either trigger will complete the wait_for. The no_motion will trigger while your in the shower and turn off the lights.

Itā€™s been very robust here.

You canā€™t expect guests to to have the same habits.

Also depends on the situation. A door open/close condition would be completely useless for my master bath. That door is almost never closed.