Garden Irrigation

Hi. Just FYI - latest model of Sonoff might have some “improvements” that require additional steps when flashing. I’ve just received Sonoff Dual. It has one more microchip onboard. That’s why regular procedure does not work. Possible solution explained in this video https://youtu.be/8naMP_OpBuY?t=3m25s. Keep it in mind when taking final decision.

Hello,
can you tell me which provider use for weather or what to change to make work with weatherundergroud.

Thanks.

Using the hard work of @petr I have managed a zone irrigation system. I made a few small changes:

  • Include a boolean to disable/enable the rain sensor
  • Save the next run in a different format
  • Small changes

The configuration can be found here

4 Likes

It is working with WU. You need to setup the backend, activate sensors you’re interested in, in my case it was today’s precipitation chance %, and today’s precipitation mm, which I use for establishing if it has rained and if it is going to rain.

It’s good to have a look for a local weather station, just to improve the accuracy of local predictions and observations.

Just a word of warning, there are times when a proper soil moisture sensor beats any external data. You could find that the day before it rained so hard that the soil is still waterlogged, yet “today’s” predictions and observations, might let the sprinkler water your garden.

You could improve that further by capturing and storing a variable from the day before, i.e. capture it today and use it tomorrow… someone correct me, but I’m not sure if WU provides historical data through the API used. If so, then just look a day back, set a slider for sensitivity of the wetness, so you can dynamically change it later (similar to current observations).

This amazing!
Thanks guys!!! This is what brought me to home assistant in the first place.

It took me a long time to get this to show up in HA; many ‘check configs’ we pressed, but I finally got it to work… I think it does…

I was hoping you could walk me through some of the basic requirements to get this up and running.
What I did was copy anything related to “Greenhouse” “zone_1” "serre ":

config.yaml

#wunderground

sensors.yaml

“# temperature serre”
“# humidity serre”
#Greenhouse
#Greenhouse zone 1”
platform: mqtt “Zone 1 Timer Sensor”
platform: mqtt “Soil Moisture Zone 1”

automations.yaml:

id: Activate_Greenhouse_Zone_1_Button
id: Activate_Greenhouse_Zone_1_Timer
id: Greenhouse_Zone_1_Timer_Reset
id: Greenhouse_Zone_1_Set_Rain_Sensor

groups.yaml

GreenhouseSensors:
GreenhouseDevices:
IrrigationZones:
IrrigationButtons:
IrrigationTimer1:
SettingsZone1:
SerreView:
rain_sensor:

scripts.yaml

activate_irrigation_greenhouse_zone_1:
extend_greenhouse_zone_1_when_wet:

binary_sensors.yaml

name: “greenhouse button 1”
name: “greenhouse button 2”
name: “greenhouse button 3”
name: “greenhouse button 4”
name: “include rain sensor 1”
name: “Greenhouse_Control_1_Status”
name: “Greenhouse_Control_2_Status”
name: “Greenhouse_Control_3_Status”

input_boolean.yaml

reset_zone_1:
include_rain_sensor_1:

input_number.yaml

#Rain
#Zone_1

Did I miss anything?

The errors i’m getting are:
Template error: UndefinesError: ‘value_jason’ is undefined
Unable to find service sensor/turn_off
Unable to find service input_number/turn_off
Unable to find service binary_sensor/turn_off

If these errors are simply because I don’t have the sensors yet, I can live with that for now (they’re in the mail).
I have a weather underground account setup in the config with the api key, but I do not have the hygrometers yet. While I have a sonoff basic with tasmota and an dht-22, i’m not quite sure how to get the sonoff to report back to the script. (I don’t want to futz around with your code since it took me this long to get it up, but would prefer to change the name of my sonoff to match -at least until I can grasp this beast of an automation).

Thanks for helping if you can, any advice is much appreciated!

I see you mention template error, maybe you can validate the template with the develop tool?

Unfortunately this is beyond my scope of understanding. How would I validate the template with the develop tool?
I just copy pasted what you have on your github.

Thanks

Is there more information in the home-assistant log? perhapse a trace.

Hi, were you able to get the water flow meter working, with the sonoff’s if yes do you mind sharing the code.
I’m battling, from what I understand the sonoffs has a counter option if flashed with tasmota. How on earth do I get accurate readings to display in litres on HA.

Any form of help will be much appreciated.

I don’t know if I did this right, but I copied the template into the “template” space, under the templates tab, in “developer tools”, and it returned this:
alias: “Activate Greenhouse Zone 1 Timer”

- id: Activate_Greenhouse_Zone_1_Button

alias: “Activate Greenhouse Zone 1 Button”
trigger:
- platform: state
entity_id: binary_sensor.greenhouse_button_1
from: ‘off’
to: ‘on’
action:
- service: switch.turn_on
entity_id: switch.greenhouse_zone_1
- delay: ‘00:00:15’
- service: switch.turn_off
entity_id: switch.greenhouse_zone_1

  • id: Activate_Greenhouse_Zone_1_Timer
    alias: “Activate Greenhouse Zone 1 Timer”
    trigger:

    • platform: time
      minutes: ‘/1’
      seconds: 00
      condition:

    • condition: template
      value_template: ‘False’
      action:

    • service: script.turn_on
      data_template:
      entity_id: >-

               script.activate_irrigation_greenhouse_zone_1
            { else %}
               script.extend_greenhouse_zone_1_when_wet
      
  • id: Greenhouse_Zone_1_Timer_Reset
    alias: “Greenhouse Zone 1 Timer Reset”
    trigger:

    • platform: state
      entity_id: input_boolean.reset_zone_1
      from: ‘off’
      to: ‘on’
      action:

    • service: mqtt.publish
      data:
      topic: “greenhouse/zone1/TIMER”
      retain: 1
      payload_template: >-

        2018-02-08 06:00:00
      
    • service: mqtt.publish
      data:
      topic: “greenhouse/zone1/IncludeRainSensor”
      retain: 1
      payload_template: “OFF”

    • service: mqtt.publish
      data:
      topic: “greenhouse/zone1/MinMoisture”
      retain: 1
      payload_template: “20.0”

    • delay:
      seconds: 1

    • service: input_boolean.turn_off
      data:
      entity_id: input_boolean.reset_zone_1

  • id: Greenhouse_Zone_1_Set_Rain_Sensor
    alias: “Greenhouse Zone 1 Rain_Sensor”
    trigger:

    • platform: state
      entity_id: input_boolean.include_rain_sensor_1
      from: ‘off’
      to: ‘on’
      action:
    • service: mqtt.publish
      data:
      topic: “greenhouse/zone1/IncludeRainSensor”
      retain: 1
      payload_template: “OFF”
    • delay:
      seconds: 1
    • service: input_boolean.turn_off
      data:
      entity_id: input_boolean.include_rain_sensor_1

So that’s cool, now I know I can paste code there and have it validate the code. Awesome.

Does this look right?

Thanks for your patience!

What I’m seeing it looks ok. Have you done a check on the configuration?

Perhaps can you share all of your configuration?

what a great piece of software. i want to build an irrigation system as well.
i have a lolin node mcu. flashed with espurna (but can be flashed with tasmota if needed). connects to moquitto running on the pi3.
do i assume correctly if i think that i can connect a 4 channel relais to 4 digital in/outputs and then run the scripts and automation posted above.
what i haven’t seen in this thread is a wiring diagram or similar. is there any?

i also would be interested to know how much water is used for irrigation. my idea: every household need a water meter installed by the water company. so just open one circuit after the other for 5min or so, note the meter before and after and you know the flow rate. multiply by the time the valve is open and you have a good estimate about the water used.
of course that’s no way of checking it watering really happened, but i see no usecase for that. my water supply is 100% bullet proof.

1 Like

Hi Iz3man, if you ever figure out how to add a flow meter and which products to us, please keep us posted. I’ve been battling to get accurate water meter readings using sonoff tasmota FW and flow meter, let alone getting them into HA with the correct readings.

well, i WON’T add a flow meter, hence the different approach i mentioned. i’d just measure “valve open time” and multiply this with values measured before. quite simple.

i guess i copied everything correctly, and added the relays of my nodemcu running tasmota correctly. at least on the paper and during a dry run is all looks ok, and i can make the valves turn on/off on a timer base and manually.

one thing that doesn’t work is showing the correct TIME of the next event.
when i set it in the SETTINGS, the displays time is shown 2 hours ahead, but it is triggered at the correct time, so it’s just a display thing. i know this it UTC related, but i don’t know how to solve it.

image

image

i set it to 6am and it shows 8am as start time.

image

anyone following that thread? maybe petr or phdelodder?

can you please share the code so I can look at it and try to solve the error?

that would be very welcome. my config is on github:
https://github.com/iz3man/Home-AssistantConfig

@phdelodder What kind of soil moisture sensor are you using in your garden?

Mi flora?