Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- time:
- - platform: homeassistant
- id: homeassistant_time
- - platform: sntp
- on_time:
- - seconds: /20
- minutes: "*"
- then:
- - switch.turn_on: soil
- - delay: 10s
- - switch.turn_off: soil
- # Soil sensor setup
- sensor:
- - platform: adc
- id: soil_sensor
- name: "Soil Sensor"
- pin: GPIO35
- update_interval: 1s
- attenuation: 12db # or auto
- unit_of_measurement: "%"
- icon: "mdi:water-percent"
- device_class: moisture
- accuracy_decimals: 2
- filters:
- - clamp:
- min_value: 1.5
- max_value: 3.12
- #ignore_out_of_range: true
- #- lambda: |-
- # if (x == 0.142) return 0;
- # else return (x);
- - calibrate_linear:
- - 1.50 -> 100
- #- 2.3 -> 50
- - 3.12 -> 0
- on_value:
- then:
- - if:
- condition: # Check that the threshold value from HA UI is imported
- sensor.in_range:
- id: moisture_set
- below: 100.0
- then:
- - if:
- condition:
- lambda: 'return id(soil_sensor).state < id(moisture_set).state;'
- then:
- - switch.turn_on: pump1
- - logger.log: "*** DELAY STARTED ***"
- - delay: 2s
- - logger.log: "*** DELAY ENDED ***"
- - switch.turn_off: pump1
- - sensor.template.publish: # Sending Timestamp of pumping to HA UI
- id: pump1_last_update
- state: !lambda 'return id(homeassistant_time).now().timestamp;'
- - switch.turn_off: pump1
- - platform: homeassistant
- name: "Moisture Set Point"
- entity_id: input_number.desired_moisture1
- id: moisture_set
- accuracy_decimals: 2
- - platform: template
- name: "Pump1 last watered"
- device_class: timestamp
- id: pump1_last_update
- switch:
- - platform: gpio
- pin:
- number: GPIO32
- inverted: False
- id: soil
- name: "Soil Sensor Switch"
- - platform: gpio
- pin: GPIO33
- id: pump1
- name: "First water pump"
- restore_mode: ALWAYS_OFF
- icon: "mdi:water-pump"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement