M_St

ESPHome - How to use variable refresh interval for sensors

Jul 3rd, 2022 (edited)
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 0.80 KB | None | 0 0
  1. sensor:
  2.   - platform: pulse_counter
  3.     pin: D7
  4.     name: "Watering plants (flow)"
  5.     id: water_flow1
  6.     update_interval: 60s       # slow counter, will be overriden
  7.     filters:
  8.     - filter_out: nan
  9.     - lambda: return (x / 450.0) * 60.0;
  10.     unit_of_measurement: "L/hr"
  11.     icon: mdi:water
  12.  
  13. switch:
  14.   - platform: gpio
  15.     name: "Watering plants valve (transistor, 12V)"
  16.     pin: D6
  17.     id: water_valve1
  18.     restore_mode: ALWAYS_OFF
  19.     icon: mdi:water-pump
  20.  
  21. interval:
  22.   - interval: 5sec
  23.     then:
  24.       if:          # fast flow updates if valve is on OR if flow is detected at sensor interval
  25.         condition:
  26.           or:
  27.             - switch.is_on: water_valve1
  28.             - lambda: return id(water_flow1).state > 0.0;
  29.         then:
  30.           - component.update: water_flow1
  31.  
Add Comment
Please, Sign In to add comment