My Garden Irrigation

Ok, let me try and answer some of your points, but first thanks for the praise :slight_smile:

Yes, I am not sure if I could have done this better to help other users but to be honest I never once thought I would ever have anything worthy of sharing when I started.

Good point, no you didn’t miss anything :wink: Again even when I first shared it I wasn’t sure if anyone would actually use this so I admit the documentation is sparse. At best. I will look into improving it.

For rainfall I add up the amount of rainfall in mm for the last three days based on the formula in the code comments and add in rainfall so far today. That is then used to give a multiplier for how to adjust the time. If there is zero rain it will be 1 if there is some rain it will be a number between 0 and 1.

For temperature I take the average high temp for the last five days and the way this affects the run time is described in the comments.

NOTE: As I have said many times, I have never actually used the weather adjustments in my schedules but I occasionally look at the adjusted times and they seem reasonable. All the parameters can easily be changed if you think it would be appropriate.

The adjusted durations shown are the actual time in minutes the system will run and they are updated as per the comments:

  #=== Adjust weather durations if:
  #===   - the baseline duration is changed
  #===   - the temperature threshold or rainfall baseline are changed
  #===   - use weather adjustment is turn on

and also every 30 minutes (which I think may be overkill).

:scream:You’re right I do! That must have been me being overzealous in my attempts to stop anything happening that might cause the system to go ‘mad’ at the end of last summer. I too have now removed this! Thanks.

Those big buttons are now little ones in my config :slight_smile:image

The big ones were too easy to press by accident on my phone. It has already been pointed out that they don’t respond to their state. Now that they are Booleans at least they will change colour when on.

I will copy my new Lovelace config to GitHub. It also has this…

image

Hmm… good question… I think you are going to need two complete copies I’m afraid…
Actually, maybe not? I think you might be able to just call the valves controlled by the second Sonoff switch.zone6_valve, switch.zone7_valve and so on. And then the new location has cycle3 and cycle4I think. Off the top of my head that might work…

And I’d be VERY interested if it does!

I hope that all helps…

Probably best thing is to define some rules directly in Tasmota, for example onBoot or on WifiDisconnect to turn off all the relays to be sure that in these particular case the watering will be stopped.

My first thing about a watering project, was to define all the relays on/off stuff defined directly on Tasmota and from the Home Automation System (in this case HA, previously I was using Domoticz) pass only some info like relay number and duration, to be sure to have always (?) the relay to be off after defined time or have a failover task.

Yes, I started this project when Tasmota was a bit more basic and had no rules (and I had much less knowledge!).

I hope I have everything covered now that PULSETIME has been included in the setup.

Talking of trying to prevent ‘accidents’…
:sunglasses:

I think this should be added to script.irrigation_irrigate_a_zone

      #=== Don't continue if switch is unavailable
      - condition: template
        value_template: >
          {{ states('switch.zone' + zone + '_valve') != 'unavailable' }}
2 Likes

One more…

If there is a cycle running and I turn off the Master control button, the actual zone being watered turn off, but the cycle continue going on.
If I turn on again the Master control, I will see the time remaining freeze at the time it was stopped and Running.
Waiting for the time of the zone to finish, the next zone will start and the Time remaining will start again counting down.

If I will not turn on again the Master control, after turning off, the cycle will continue anyway.

Sorry to bother you, but, as you said, if there is somethig wrong with the watering it cause damage…

But, luckily you’re doing a really good job.

Thanks

No problem at all, thanks for spotting it.

I think I’m going to regret including that Master Control Button :slight_smile:

Yes, I suspect there are other cases it doesn’t handle too well, I added it in a moment of paranoia without giving it much thought apart from it simply stopping anything from being started.

I’ll try to look at it and make it more robust.

EDIT: that one was easy…
Feel free to find more :wink:

In the automation ‘Irrigation Master Control Switch’ add this

      #=== Stop both cycles
      - service: input_boolean.turn_off
        data:
          entity_id: 
            - input_boolean.cycle1_manual_run
            - input_boolean.cycle2_manual_run

1 Like

Perfect, works like a charm!
Thanks

1 Like

Proposed some additional info in your readme.md on github.
Hope that’s ok and that i did it correctly (first time i do it :slight_smile:)

Also an idea: You could add 5 template switches at the start of your pack that would only turn on/off the switches. Then use the template switches for the whole code. This way each user could replace the switch once and not throughout your whole code.
Something like this?

  - platform: template
    switches:
      zone1_valve:
        value_template: "{{ is_state('switch.MY_VALVE_SWITCH1', 'on') }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.MY_VALVE_SWITCH1
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.MY_VALVE_SWITCH1

Or i could have thought of that too, before find/replacing the whole thing :expressionless:

Here’s how i did it:
added two extra files in the packages/garden folder:

garden_extra_template_switches_renaming.yaml:

switch:
  - platform: template
    switches:
      zone1_valve:
        value_template: "{{ is_state('switch.eWelink_Random_Name_1', 'on') }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.eWelink_Random_Name_1
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.eWelink_Random_Name_1
            
      zone2_valve:
        value_template: "{{ is_state('switch.eWelink_Random_Name_2', 'on') }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.eWelink_Random_Name_2
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.eWelink_Random_Name_2
            
      zone3_valve:
        value_template: "{{ is_state('switch.eWelink_Random_Name_3', 'on') }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.eWelink_Random_Name_3
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.eWelink_Random_Name_3
            
      zone4_valve:
        value_template: "{{ is_state('switch.eWelink_Random_Name_4', 'on') }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.eWelink_Random_Name_4
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.eWelink_Random_Name_4
            
      zone5_valve:
        value_template: "{{ is_state('input_boolean.dummy_switch_zone5_valve', 'on') }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: input_boolean.dummy_switch_zone5_valve
        turn_off:
          service: switch.turn_off
          data:
            entity_id: input_boolean.dummy_switch_zone5_valve
            

            
input_boolean:
  dummy_switch_zone5_valve:
    name: Dummy switch Zone5 Valve
    initial: off
    icon: mdi:switch

(i only use 4 zones so added a boolean to play with the last zone)

and garden_extra_weather_providers.yaml

smartweather:
  station_id: XXXX
  api_key: public_api_key



sensor:
  #==============================================
  #=== Dark Sky sensor for forecasting in the
  #=== Custom Dark Sky Animated Weather Card
  #==============================================
  - platform: darksky
    api_key: !secret darksky_api_key
    name: dark_sky_forecast
    units: auto
    scan_interval:
      minutes: 720
    forecast:
      - 0
      - 1
      - 2
      - 3
      - 4
      - 5
    monitored_conditions:
      # - icon
      # - summary
      - temperature_high           
      # - temperature_low 
      # - precip_intensity_max
      # - precip_probability


  #===================================================
  #=== Dark Sky sensor for current weather conditions
  #===================================================
  - platform: darksky
    api_key: !secret darksky_api_key
    name: dark_sky
    units: auto
    scan_interval:
      hours: 1
    monitored_conditions:
      # - icon
      # - summary
      # - minutely_summary 
      - hourly_summary
      - daily_summary
      - temperature
      - apparent_temperature
      # - precip_intensity
#      - precip_type            # If precip_intensity is zero, then this property will be unknown
#      - precip_accumulation    # If no snowfall is expected, this property will be undefined
      # - dew_point
      # - wind_speed
      # - wind_gust
      # - wind_bearing
      # - cloud_cover
      # - humidity
      # - pressure
      # - visibility
      # - ozone
      # - uv_index
      # - moon_phase
      # - nearest_storm_distance
      # - nearest_storm_bearing 
1 Like

I like your suggest!

I’m not sure if you have done it correctly. I am no expert in GitHub, this is my first time using it too but I think that you have created a fork which is a completely separate copy of the whole repository. I could be wrong but I can’t see how I include your changes in my files!

As for the switch template, yes I think that might have been a good idea but when I wrote this I was just learning HA and I didn’t even know such a thing existed!

I’m not sure I’ll change it now (if it ain’t broke, don’t fix it) but if you want to do it I can include it, once we know how to use GitHub properly!! :slight_smile:

Included my two extra yaml files in the comment above.
As for github, its a whole new world lol…
I also added a comment character at the start of your garden_master_control.yaml that you missed (fix that manually as it messes the whole thing up)

=================
# === Automations
#=================

And i rounded up the 3day cycle multiplier in garden_weather_calculations.yaml

{{ (states.input_number.rain_3days_total.state | float / states.input_number.rainfall_threshold.state | float) | round(2) }}

Hope im not busting your balls :smiley:

Whoops… will fix that straight away!

For github, after you have forked original work by @klogg, and done your customization, you need to create a “pull request” to files you like to “send” to @klogg. In this way klogg can accept or reject your customization and include in the master project

Ill look into it, Thanks!

And this makes perfect sense. I’ll add it too.

Im actually having a hard time getting the card with the switches (custom:config-template-card) to appear.

I am guessing you are creating the sensor.zone1to4_valve and sensor.zone5_valve somewhere else in your configuration and they are supposed to show the wifi signal of the sonoffs?

Also, inside the custom:hui-glance-card part of the card, you have defined the entity: sensor.zone1to4_valve 4 times.
Is that correct? i’m totally confused :stuck_out_tongue:

your code:

... # everything below this part does not appear in my UI
                - type: 'custom:config-template-card'
                  entities:
                    - switch.zone1_valve
                    - switch.zone2_valve
                    - switch.zone3_valve
                    - switch.zone4_valve
                    - switch.zone5_valve
                    - sensor.zone1to4_valve
                    - sensor.zone5_valve
                  variables:
                    - 'states[''sensor.zone1to4_valve''].state'
                    - 'states[''sensor.zone5_valve''].state'
                  card:
                    type: 'custom:hui-glance-card'
                    entities:
                      - entity: switch.zone1_valve
                        icon: 'mdi:engine'
                      - entity: switch.zone2_valve
                        icon: 'mdi:engine'
                      - entity: switch.zone3_valve
                        icon: 'mdi:engine'
                      - entity: switch.zone4_valve
                        icon: 'mdi:engine'
                      - entity: switch.zone5_valve
                        icon: 'mdi:engine'
#if i remove the part below the engines (above) appear ok
                      - entity: sensor.zone1to4_valve
                        name: ''
                        icon: >-
                          ${vars[0] >= 100 ? 'mdi:wifi' : vars[0] >= 80 ?
                          'mdi:wifi-strength-3' : vars[0] >= 60 ?
                          'mdi:wifi-strength-2' : vars[0] > 0 ?
                          'mdi:wifi-strength-1' : 'mdi:wifi-off' }
                      - entity: sensor.zone1to4_valve
                        name: ''
                        icon: >-
                          ${vars[0] >= 100 ? 'mdi:wifi' : vars[0] >= 80 ?
                          'mdi:wifi-strength-3' : vars[0] >= 60 ?
                          'mdi:wifi-strength-2' : vars[0] > 0 ?
                          'mdi:wifi-strength-1' : 'mdi:wifi-off' }
                      - entity: sensor.zone1to4_valve
                        name: ''
                        icon: >-
                          ${vars[0] >= 100 ? 'mdi:wifi' : vars[0] >= 80 ?
                          'mdi:wifi-strength-3' : vars[0] >= 60 ?
                          'mdi:wifi-strength-2' : vars[0] > 0 ?
                          'mdi:wifi-strength-1' : 'mdi:wifi-off' }
                      - entity: sensor.zone1to4_valve
                        name: ''
                        icon: >-
                          ${vars[0] >= 100 ? 'mdi:wifi' : vars[0] >= 80 ?
                          'mdi:wifi-strength-3' : vars[0] >= 60 ?
                          'mdi:wifi-strength-2' : vars[0] > 0 ?
                          'mdi:wifi-strength-1' : 'mdi:wifi-off' }
                      - entity: sensor.zone5_valve
                        name: ''
                        icon: >-
                          ${vars[1] >= 100 ? 'mdi:wifi' : vars[1] >= 80 ?
                          'mdi:wifi-strength-3' : vars[1] >= 60 ?
                          'mdi:wifi-strength-2' : vars[1] > 0 ?
                          'mdi:wifi-strength-1' : 'mdi:wifi-off' }
# Things are okay from here on ->
                - type: entities
                  title: Temperature and Rainfall
...

Actually, I’ve changed my mind on this. It does make some sense but weather forecasting is a little more general and used in other places so I have decided to leave it alone in the code but have it referenced in the readme. Another reason is that there is no requirement to use these same sensors (in fact SmartWeather will not be suitable for anyone without a station near them) all you need is some source of temperature and rainfall.

Ha! That custom card is really something else! I have seen it affectionately called an abomination but it is close to genius. I think your problem is the double quotes here:

                  variables:
                    - 'states[''sensor.zone1to4_valve''].state'
                    - 'states[''sensor.zone5_valve''].state'

it should be

              variables:
                - states['sensor.zone1to4_valve'].state
                - states['sensor.zone5_valve'].state

Yes I have, purely for this card. The sensor.zone1to4 is the Sonoff 4ch. It made sense to only have one sensor as it is only one device.

Yes, again. Simply for aesthetic reasons because I wanted to have the WiFi icon on the card line up with the correct valve and whilst all the switches (valves) 1 to 4 are the same I didn’t want zone5 to line up under zone 2. Does that make sense?

I’m not surprised, like I said that card is an abomination. But incredibly powerful!!

I see water stains in the bottom of that box. I see 240V lines. I see a plastic box, and not metal and bonded to ground.

This is definitely not to code and to be honest is really scary shit. Please tell me you at least have a sticker on the outside saying 240VAC inside and a lock to keep people out.

Thanks, your clarifications make sense, I’ll get back on it!

Agreed :slight_smile:

That was it, now i have my signal measurement too.
I had to convert it from rssi so here’s the code, in case someone needs it:

sensor: 
  - platform: template
    sensors:
      irrigation_wifi_signal_str_percentage:
        friendly_name: "Irrigation Wifi Str conversion"
        unit_of_measurement: '%'
        value_template: "{{ 2* (state_attr('switch.10005b67f1_1', 'rssi')+100) }}"

(it needs an if statement, something like
if result > 100 : keep it at 100, if not: just give the percentage
but i dont know how to write that , so ill just have to live with 102% wifi signal :stuck_out_tongue:)

Then in the lovelace i did:

                - type: 'custom:config-template-card'
                  entities:
                    - switch.zone1_valve
                    - switch.zone2_valve
                    - switch.zone3_valve
                    - switch.zone4_valve
                    - sensor.irrigation_wifi_signal_str_percentage
                  variables:
                    - states['sensor.irrigation_wifi_signal_str_percentage'].state
                  card:
                    type: 'custom:hui-glance-card'
                    entities:
                      - entity: switch.zone1_valve
                        icon: 'mdi:engine'
                      - entity: switch.zone2_valve
                        icon: 'mdi:engine'
                      - entity: switch.zone3_valve
                        icon: 'mdi:engine'
                      - entity: switch.zone4_valve
                        icon: 'mdi:engine'
                      - entity: sensor.irrigation_wifi_signal_str_percentage
                        name: wifi signal
                        icon: >-
                          ${vars[0] >= 100 ? 'mdi:wifi' : vars[0] >= 80 ?
                          'mdi:wifi-strength-3' : vars[0] >= 60 ?
                          'mdi:wifi-strength-2' : vars[0] > 0 ?
                          'mdi:wifi-strength-1' : 'mdi:wifi-off' }
1 Like

The feed to this box is from a single standard fused 3 pin UK plug that goes through the wall from an interior wall socket.

The box does not have a sticker, which is a good idea and yes it is locked closed.

As for it being plastic, I did not know that was a bad thing, all the components are mounted on a metal plate.