My Garden Irrigation

Nice one!
I can’t think of anywhere else that this should be a problem. It’s always very satisfying to find that the code that was written is easy to be altered to accommodate new things so I hope you are right!! :slight_smile:

Once you are sure that it is all working I will update the code on github (and credit you of course :wink: )

Thanks for looking into this, I am sure others will find it useful…

2 Likes

My pleasure to use your code and help if i can. You can make a pull request if you like. I have a separate branch with the extra zones and keep them all updated from yours.
Only other issue is that there are no mdi:numeric above 10 lol. So i redisplay 1 as icon for zone11, etc.
BTW, this is not a bench test project for me. I’m actually using it every day for my garden :grinning:.

Ha ha! yes that is true!

As for a pull request… I’m afraid I have no idea how to use Github ‘properly’.
I’m afraid I’m just going to have to edit that line in my copy once we’re sure it’s all ok :roll_eyes:

Great, well let’s give it a couple of days and I’ll make the change.
PS You’re lucky, it’s been raining here for days… (London)

No worries. I didn’t know either. I just learn a couple of days ago, in order to get your updates. I did too prefer the old fashion way, but i couldn’t cope with all the extras zones that i had put in.

1 Like

@klogg, I have created a NodeRed flow that trigger each of my real zone switches and update each sensor.irrigation_sensor_zoneX_switch on and off

and now I can see values in the History Totals, so, for me, I confirm that the automation Irrigation Synchronise Sensor Zone Switches is the cause of the History malfunction…

Schermata 2020-07-09 alle 18.31.19

Thanks

1 Like

That automation is very simple, it doesn’t really do much.

It triggers on every HA event

The condition for it to continue processing is that the entity_id which causes the trigger is one of:
input_text.irrigation_zone1_switch_entity_id
to
input_text.irrigation_zone8_switch_entity_id
or
it is in one of the entity_ids held in one of those input_texts (i.e. states('input_text.irrigation_zone1_switch_entity_id')).

The action block simply updates the appropriate sensor based on which one of the above triggered it.


Perhaps we can start to debug this by at least ensuring that that automation is running…

Can you add this somewhere in your config

notify:
  - platform: file
    name: log_irrigation
    filename: my-log-irrigation.log

Then in the automation, as the first service in the action block (after the condition block) add this:

      - service: notify.log_irrigation
        data_template:
          message: >
            {{ trigger.event.data.entity_id }}

So long as the automation is triggered and the condition passes, this should create a file in the root of your config folder called my-log-irrigation.log

And just as I finished typing this it occurred to me to ask the obvious question to check that you don’t have any errors in the HA log relating to this package?

1 Like

I will sure check for any errors in the logs and will sure try your suggestions, but I will do late next week since I’m not home until then.

I will update soon…

Thanks

1 Like

If it helps, this is from this morning run.
Total watering time is correct.
Details of the time that each zone run, are correct
Zero for history (today and yesterday) and wrong end time calculation (actually only calculates zones 1,2,3,10. Used to be correct until some changes that you made, can’t remember which one was)

I did check for errors, and i can see at the logbook the history of the switch (actually are groups since i have master valves too) and defiantly i can verify that my garden is watered as planed :smiling_face_with_three_hearts:

PS. @klogg i do have an issue displaying only the history and details of last run only for the “Numbers of Zones” as you can see. If i go to fewer than 8 then it truncates the first 8 correctly but still leaves the extras that i have. But we can look at it whenever you have the time.

This is almost certainly a similar thing to your previous ‘more than 8 zones’ question.
For the History, look in item_status_history_line.yaml, this is the section that decides if the row is displayed:

  card:
    - display: >
        [[[
          var zone = '{{ zone }}';
          zone = Number(zone.substring(4, 5));
          var number_of_zones = Number(states['input_number.irrigation_number_of_zones'].state);
          var show_history = states['input_boolean.irrigation_ui_show_status_history'].state;
          if (zone > number_of_zones ||
              show_history == 'off' )
            return 'none';
          else return null;
        ]]]

As you can see, like before it only checks one character. I am sure if you change it to strip out the word ‘zone’ like you did before it will probably work.

Remember it is Javascript. I will try to find time to look up how to do this (I am no expert in Javascript) but it won’t be soon. As always feel free to try it yourself :wink:

Last Run is similar in item_status_last_run_line.yaml

Feel free to experiment, it is only the UI so you can’t do any lasting damage!!

Thanks a lot for the hint.
Change

zone = Number(zone.substring(4, 5));

to

zone = Number(zone.replace(‘zone’, ‘’));

and everything are ok now.

If you can give me some directions for the history issue that everyone seems to have, i might find something :smiley:

1 Like

That simple eh?!

Thank you! As with the other change you made if I don’t hear you screaming that it has all gone wrong in the next few days I’ll change the code on GitHub

I wish I could!! I have looked at where I think there might have been a problem a hundred times and can’t find anything (maybe I’ve looked for too long to see it now!?).

What is worse is that it works for me and from the lack of feedback I am guessing it works for some others too.

I will find time to describe what is happening and where it all happens so that you can take a look. But again, it might be a few days until I do.

No worries. Whenever you have time.
Any ideas why it only calculates the time for zones 1,2,3,10 at (will end about …) ?

Not yet but I’ll look into it!

1 Like

Actually, yes…
This could be a bigger change though.

Look in garden_globals_cycle1.yaml

The cycle duration is calculated in a template sensor - irrigation_cycle1_duration_in_seconds

Possibly you can change that to work for you.

and don’t forget to do the same for Cycle 2 and 3 :wink:

The Lovelace bit, if it helps is the label in `item_cycle_start_time.yaml’


Maybe once everything is sorted out for ‘more than 8 zones’ we could put together a few words on what you changed to make it work. I’m guessing apart from this (and the code changes already identified which I’ll add) you added a few input_* but was there anything else?

Hi @klogg

here is the log doing a manual cycle with Zone 3 (1min) and Zone 4 (1min).

Home Assistant notifications (Log started: 2020-07-12T19:21:43.142973+00:00)
--------------------------------------------------------------------------------
switch.sonoff_ch4pro_relay3
switch.sonoff_ch4pro_relay3
switch.sonoff_ch4pro_relay4
switch.sonoff_ch4pro_relay4

Those two switches are the real ones I have defined in the respective zones.

Is it what you were expecting?

Thanks

Ah ha!
Yes it is.
Sort of…

I’ve only snatched a few minutes to look at this but I think the problem is that your switches don’t have the word ‘zone’ in them!

I look for a name with ‘zoneX’ you have ‘relayX’.

There are several ways around this…

I need to have a pattern to look for in switch names that I am sure will appear in everyone’s switch name.

So I can think of three options:

  1. I ‘insist’ everyone (re)names their switches to include the string ‘zoneX’
  2. I add extra checks to look for other possible strings, such as ‘relayX’
  3. I just look for a digit (i.e 1, 2 ,3 … etc.)

There are pros and cons to all these solutions.

  1. This would affect some people who would need to rename their switches (and I would need to update the documentation)
  2. This would make clunky code and I would never be sure I had included every option
  3. This would run the risk of someone using numbers inappropriately and also I am hoping to add changes soon that allow an unlimited (theoretically) number of zones so I’d have to search for double digit numbers and everyone would have to rename theirs to ‘01’, ‘02’, etc.

My preference is for option 1 but I am open to any other suggestions…

In NodeRed, I “simply” check each real names of my switches and then update the relative sensor.

The code should already know the number of zones defined and the switches real names (in input_text.irrigation_zoneX_switch_entity_id), so maybe another way is to do it per single zone, without caring of the zoneX, relayX or others in the switch name, even if wouldn’t be the best optimized way, but at least you don’t have to ‘insist’ on switches naming.

Yeah, I’d thought of that… An automation for every zone instead of one automation that checks all zones. Not the most optimized way but maybe it would be best that way…

I’ll think about it.

Whatever I do, I can’t work on this for a couple of days.


If you want to change your code in the meantime so that you get history data then in the automation you can change the action by replaceing all the

{% if 'zoneX' in trigger.event.data.entity_id %}

to

{% if 'relayX' in trigger.event.data.entity_id %}

1 Like

Probably, a fast way could be to adapt the naming of the switches to ‘zoneX’ or to modify that automation reflecting the switch naming.
If explained well, as you already did with the Readme and Prerequisites, should not be an issue…