Advertisement
yurghie

Bathroom PIR + Humidity logic

May 5th, 2025
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.19 KB | None | 0 0
  1. automation:
  2.  #lights out when no activity and noone is showering or after 5 min of inactivity
  3.   - alias: bad - lys av inaktivitet
  4.     trigger:
  5.       - platform: state
  6.         entity_id: binary_sensor.bad_pir_occupancy
  7.         to: 'off'
  8.         for: '00:05:00'
  9.       - platform: event
  10.         event_type: timer.finished
  11.         event_data:
  12.           entity_id: timer.dusjtimer      
  13.     condition: "{{states('timer.dusjtimer') == 'idle' and states('binary_sensor.bad_pir_occupancy') == 'off'}}"
  14.     action:
  15.       - service: light.turn_off
  16.         entity_id: light.bad
  17.  
  18.   # start timer when the trend sensor triggers from rising humidity
  19.   - alias: bad lys på når noen dusjer
  20.     trigger:
  21.       platform: state
  22.       entity_id: binary_sensor.bad_noen_dusjer
  23.       to: 'on'
  24.     action:
  25.       - service: timer.start
  26.         entity_id: timer.dusjtimer
  27.     mode: single
  28.     max_exceeded: silent
  29.    
  30. binary_sensor:
  31.   - platform: trend
  32.     sensors:
  33.       bad_noen_dusjer:
  34.         max_samples: 3
  35.         entity_id: sensor.bad_klima_humidity
  36.         min_gradient: 0.025 # (3/(60*2))% meaning rising 3% in 2 minutes
  37.  
  38. timer:
  39.   dusjtimer:
  40.     duration: '00:20:00'
  41.     restore: true
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement