Advertisement
thedeluxo

Untitled

Dec 1st, 2024 (edited)
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 2.23 KB | Source Code | 0 0
  1. time:
  2.   - platform: homeassistant
  3.     id: homeassistant_time
  4.   - platform: sntp
  5.     on_time:
  6.       - seconds: /20
  7.         minutes: "*"
  8.         then:
  9.           - switch.turn_on: soil
  10.           - delay: 10s
  11.           - switch.turn_off: soil
  12.  
  13. # Soil sensor setup
  14. sensor:
  15.   - platform: adc
  16.     id: soil_sensor
  17.     name: "Soil Sensor"
  18.     pin: GPIO35
  19.     update_interval: 1s
  20.     attenuation: 12db # or auto
  21.     unit_of_measurement: "%"
  22.     icon: "mdi:water-percent"
  23.     device_class: moisture
  24.     accuracy_decimals: 2
  25.     filters:
  26.       - clamp:
  27.           min_value: 1.5
  28.           max_value: 3.12
  29.           #ignore_out_of_range: true
  30.       #- lambda: |-
  31.       #    if (x == 0.142) return 0;
  32.       #    else return (x);
  33.       - calibrate_linear:
  34.          - 1.50 -> 100
  35.           #- 2.3 -> 50
  36.           - 3.12 -> 0
  37.     on_value:
  38.       then:
  39.         - if:
  40.             condition: # Check that the threshold value from HA UI is imported
  41.               sensor.in_range:
  42.                 id: moisture_set
  43.                 below: 100.0
  44.             then:
  45.               - if:
  46.                   condition:
  47.                     lambda: 'return id(soil_sensor).state < id(moisture_set).state;'
  48.                   then:
  49.                   - switch.turn_on: pump1
  50.                   - logger.log: "*** DELAY STARTED ***"
  51.                   - delay: 2s
  52.                   - logger.log: "*** DELAY ENDED ***"
  53.                   - switch.turn_off: pump1
  54.                   - sensor.template.publish: # Sending Timestamp of pumping to HA UI
  55.                       id: pump1_last_update
  56.                       state: !lambda 'return id(homeassistant_time).now().timestamp;'
  57.               - switch.turn_off: pump1
  58.  
  59.   - platform: homeassistant
  60.     name: "Moisture Set Point"
  61.     entity_id: input_number.desired_moisture1
  62.     id: moisture_set
  63.     accuracy_decimals: 2
  64.  
  65.   - platform: template
  66.     name: "Pump1 last watered"
  67.     device_class: timestamp
  68.     id: pump1_last_update
  69.  
  70. switch:
  71.   - platform: gpio
  72.     pin:
  73.       number: GPIO32
  74.       inverted: False
  75.     id: soil
  76.     name: "Soil Sensor Switch"
  77.   - platform: gpio
  78.     pin: GPIO33
  79.     id: pump1
  80.     name: "First water pump"
  81.     restore_mode: ALWAYS_OFF
  82.     icon: "mdi:water-pump"
  83.  
Tags: ESPhome
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement