Weather based irrigation

I turned on debug in configuration.yaml

logger:
  default: error
  logs:
    custom_components.wb_irrigation: debug

after HA restart I got this in log:

2020-04-12 20:57:12 INFO (MainThread) [custom_components.wb_irrigation.sensor] wbi async_added_to_hass {'friendly_name': 'wb_irrigation_rain', 'unit_of_measurement': 'mm'}
2020-04-12 20:57:13 INFO (MainThread) [custom_components.wb_irrigation.sensor] wbi async_added_to_hass {'friendly_name': 'wb_irrigation_rain_day', 'rain_total': 0.0, 'unit_of_measurement': 'mm'}
2020-04-12 20:57:13 INFO (MainThread) [custom_components.wb_irrigation.sensor] wbi async_added_to_hass {'fao56': 536.3, 'friendly_name': 'wb_irrigation_fao56', 'unit_of_measurement': 'ev'}
2020-04-12 20:57:13 INFO (MainThread) [custom_components.wb_irrigation.sensor] wbi async_added_to_hass {'friendly_name': 'wb_irrigation_p1_front', 'unit_of_measurement': 'ev'}
2020-04-12 20:57:13 INFO (MainThread) [custom_components.wb_irrigation.sensor] wbi async_added_to_hass {'friendly_name': 'wb_irrigation_p2_bok', 'unit_of_measurement': 'ev'}
2020-04-12 20:57:13 INFO (MainThread) [custom_components.wb_irrigation.sensor] wbi async_added_to_hass {'friendly_name': 'wb_irrigation_p3_taras1', 'unit_of_measurement': 'ev'}
2020-04-12 20:57:13 INFO (MainThread) [custom_components.wb_irrigation.sensor] wbi async_added_to_hass {'friendly_name': 'wb_irrigation_p4_taras2', 'unit_of_measurement': 'ev'}
2020-04-12 20:57:13 INFO (MainThread) [custom_components.wb_irrigation.sensor] wbi async_added_to_hass {'friendly_name': 'wb_irrigation_p5_wykusz', 'unit_of_measurement': 'ev'}
2020-04-12 20:57:13 INFO (MainThread) [custom_components.wb_irrigation.sensor] wbi async_added_to_hass {'friendly_name': 'wb_irrigation_p6_wyspa', 'unit_of_measurement': 'ev'}
2020-04-12 20:57:13 INFO (MainThread) [custom_components.wb_irrigation.sensor] wbi async_added_to_hass {'friendly_name': 'wb_irrigation_p7_tujki_L', 'unit_of_measurement': 'ev'}
2020-04-12 20:57:13 INFO (MainThread) [custom_components.wb_irrigation.sensor] wbi async_added_to_hass {'friendly_name': 'wb_irrigation_p8_tujki_P', 'unit_of_measurement': 'ev'}

nothing more :frowning:
fao sensor state is the following:

image

any idea ? :slight_smile:

wb_irrigation:
api_key: !secret openweathermap_key
rain_factor: 90
max_ev: 3000
min_ev: -1500.0
name: ā€œwb_irrigationā€
debug: false
longitude: !secret accurate_longitude
latitude: !secret accurate_latitude
elevation: !secret accurate_elevation
taps:
- name: p1
- name: p2

Change the debug in the component to true

1 Like

I did it
packages/irrigation.yaml

wb_irrigation:
  api_key: !secret openweathermap_key
  rain_factor: 90
  max_ev: 3000 
  min_ev: -1500.0
  name: "wb_irrigation"
  debug: true
  longitude: !secret accurate_longitude
  latitude: !secret accurate_latitude
  elevation: !secret accurate_elevation
  taps: 
    - name: p1_front
    - name: p2_bok
    - name: p3_taras1
    - name: p4_taras2
    - name: p5_wykusz
    - name: p6_wyspa
    - name: p7_tujki_l
    - name: p8_tujki_p

but no change in home-assistant.log

2020-04-12 22:08:19 INFO (MainThread) [custom_components.wb_irrigation.sensor] wbi async_added_to_hass {'friendly_name': 'wb_irrigation_rain', 'unit_of_measurement': 'mm'}
2020-04-12 22:08:19 INFO (MainThread) [custom_components.wb_irrigation.sensor] wbi async_added_to_hass {'friendly_name': 'wb_irrigation_rain_day', 'rain_total': 0.0, 'unit_of_measurement': 'mm'}
2020-04-12 22:08:19 INFO (MainThread) [custom_components.wb_irrigation.sensor] wbi async_added_to_hass {'fao56': 536.3, 'friendly_name': 'wb_irrigation_fao56', 'unit_of_measurement': 'ev'}
2020-04-12 22:08:19 INFO (MainThread) [custom_components.wb_irrigation.sensor] wbi async_added_to_hass {'friendly_name': 'wb_irrigation_p1_front', 'unit_of_measurement': 'ev'}
2020-04-12 22:08:19 INFO (MainThread) [custom_components.wb_irrigation.sensor] wbi async_added_to_hass {'friendly_name': 'wb_irrigation_p2_bok', 'unit_of_measurement': 'ev'}
2020-04-12 22:08:19 INFO (MainThread) [custom_components.wb_irrigation.sensor] wbi async_added_to_hass {'friendly_name': 'wb_irrigation_p3_taras1', 'unit_of_measurement': 'ev'}
2020-04-12 22:08:19 INFO (MainThread) [custom_components.wb_irrigation.sensor] wbi async_added_to_hass {'friendly_name': 'wb_irrigation_p4_taras2', 'unit_of_measurement': 'ev'}
2020-04-12 22:08:19 INFO (MainThread) [custom_components.wb_irrigation.sensor] wbi async_added_to_hass {'friendly_name': 'wb_irrigation_p5_wykusz', 'unit_of_measurement': 'ev'}
2020-04-12 22:08:19 INFO (MainThread) [custom_components.wb_irrigation.sensor] wbi async_added_to_hass {'friendly_name': 'wb_irrigation_p6_wyspa', 'unit_of_measurement': 'ev'}
2020-04-12 22:08:19 INFO (MainThread) [custom_components.wb_irrigation.sensor] wbi async_added_to_hass {'friendly_name': 'wb_irrigation_p7_tujki_L', 'unit_of_measurement': 'ev'}
2020-04-12 22:08:19 INFO (MainThread) [custom_components.wb_irrigation.sensor] wbi async_added_to_hass {'friendly_name': 'wb_irrigation_p8_tujki_P', 'unit_of_measurement': 'ev'}

just in case my configuration.yaml

homeassistant:
  auth_mfa_modules:
    - type: totp
  whitelist_external_dirs:
    - /config
    - /config/sh
  packages: !include_dir_named packages
  customize: !include customize.yaml

logger:
  default: error
  logs:
    custom_components.wb_irrigation: debug

I tried to turn on debug on default hassio level ā€¦ got trylion of lines :slight_smile: but when searched for string fao got plenty of those:

020-04-12 22:23:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event platform_discovered[L]: service=load_platform.sensor, platform=wb_irrigation, discovered=api_key=XXXXX, rain_factor=90.0, max_ev=3000.0, min_ev=-1500.0, name=wb_irrigation_fao56, debug=True, longitude=XXXXX, latitude=XXXXX, elevation=180, taps=[OrderedDict([('name', 'p1_front')]), OrderedDict([('name', 'p2_bok')]), OrderedDict([('name', 'p3_taras1')]), OrderedDict([('name', 'p4_taras2')]), OrderedDict([('name', 'p5_wykusz')]), OrderedDict([('name', 'p6_wyspa')]), OrderedDict([('name', 'p7_tujki_l')]), OrderedDict([('name', 'p8_tujki_p')])], unit_of_measurement=ev, type=fao56>
...
2020-04-12 22:23:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event platform_discovered[L]: service=load_platform.sensor, platform=wb_irrigation, discovered=api_key=XXXXX, rain_factor=90.0, max_ev=3000.0, min_ev=-1500.0, name=wb_irrigation_p7_tujki_l, debug=True, longitude=XXXXX, latitude=XXXXX, elevation=180, taps=[OrderedDict([('name', 'p1_front')]), OrderedDict([('name', 'p2_bok')]), OrderedDict([('name', 'p3_taras1')]), OrderedDict([('name', 'p4_taras2')]), OrderedDict([('name', 'p5_wykusz')]), OrderedDict([('name', 'p6_wyspa')]), OrderedDict([('name', 'p7_tujki_l')]), OrderedDict([('name', 'p8_tujki_p')])], unit_of_measurement=ev, type=bucket, fao56=sensor.wb_irrigation_fao56, rain=sensor.wb_irrigation_rain_day>
...
2020-04-12 22:23:50 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.wb_irrigation_fao56, old_state=None, new_state=<state sensor.wb_irrigation_fao56=0.0; fao56=536.3, unit_of_measurement=ev, friendly_name=wb_irrigation_fao56 @ 2020-04-12T22:23:50.369421+02:00>>

of course real data hidden behind XXXXX :slight_smile:

I havenā€™t found anything for string ā€œopenweatherā€¦ā€ or error which I could connect in any manner to fao sensor.
Further, openweathermap_key string in this debug log I found only in lines provided above.

Maybe this is a hint somehow ?

another thing Iā€™ve found in log:

2020-04-12 22:23:55 WARNING (MainThread) [homeassistant.helpers.service] Unable to find services.yaml for the wb_irrigation integration
2020-04-12 22:23:55 WARNING (MainThread) [homeassistant.helpers.service] Unable to find services.yaml for the variable integration

but those are just warnings not errors ā€¦

other logs but seems nothing special ā€¦

2020-04-12 22:23:58 DEBUG (SyncWorker_5) [homeassistant.util.json] JSON file not found: /config/custom_components/wb_irrigation/.translations/en.json
2020-04-12 22:23:58 DEBUG (SyncWorker_5) [homeassistant.util.json] JSON file not found: /config/custom_components/wb_irrigation/.translations/sensor.en.json

sic! ā€¦ I must be doing something wrong here :frowning: for sure this is some super silly mistake :frowning: but where ā€¦

The update happens every hour and you didnā€™t wait an hour.

change this code (in sensor.py under custom_component):

if (self._type != TYPE_EV_RAIN_BUCKET):
          async_track_utc_time_change(
              hass, self._async_update_every_hour,
                minute = 0, second = 0)

to this (remove minute = 0)

if (self._type != TYPE_EV_RAIN_BUCKET):
          async_track_utc_time_change(
              hass, self._async_update_every_hour,
                 second = 0)

Then you will have an update and wbi log every 60 sec

you see ā€¦ silly me :slight_smile:

Now seems ev is being calculated :slight_smile:

and in the home-assistant.log I see debug info wbi_raw_data ā€¦ and it is also updated every time :slight_smile:

So far so good :slight_smile:

one question ā€¦ ev is now -36 but irrigation still have not started:

2020-04-13 11:31:00.010323 INFO wb_irrigation:  irrigation event for p2_bok
2020-04-13 11:31:00.012103 INFO wb_irrigation:  irrigation  queue is small  -36.3 

ev -36 is not low enough or ?

Somethingā€™s wrong here as well. I had to reinstall HA completety, and now want to reactivate irrgigation. All sensors are there, taps are there, EV is reduced every day, itā€™s at -1000 but it doesnā€™t start irrigation on any tap.

image

wb_irrigation:
  api_key: !secret openweathermap_key
  rain_factor: 30
  max_ev: 500 
  min_ev: -1500.0
  name: "wb_irrigation"
  debug: true
  latitude: 48.xxx
  longitude: 16.xxx
  elevation: 340

What I observed as well: When I start a manual cylce it doesnā€™t stop after the time given by the slider. It looks as if I forgot to install a part or misconfigured it??!

@iz3man your component works. AppDeamon does not !

Stupid me. I had it installed under ā€œSupervisorā€ Add-Ons, but didnā€™t activate it. Will try now. Thanks!
Ok, it seems that was the culprit. I guess itā€™s working now.
And I also receive a lot of device tracker message again on my Iphone. I had that already, but canā€™t remember which part of your git was responsible for that :wink:

I guess itā€™s that part? I can remove it completely, correct?

track_notification:
   module: heat_app
   class: TrackerNotification

track_alarm:
   module: heat_app
   class: AlarmNotification

high_priorty_track_alarm:
   module: heat_app
   class: AlarmNotificationHighPriorty

The ā€œwater monitorā€ stuff is also not needed. Ok to delete as well?

I love the idea. As I am about to setup my garden irrigation I was looking for a way to adjust for weather and it looks like you did all the hard work. Thank you.

I have a problem tough. I set everything up and started testing. When the scheduled time comes I get this in the log:

2020-04-15 00:22:30.047683 INFO wb_irrigation:  irrigation event for r1
2020-04-15 00:22:30.121353 INFO wb_irrigation: 00:22:30 irrigation time tap r1 timer 9 min
2020-04-15 00:22:32.497871 INFO wb_irrigation: turn on by user r1 15 min 
2020-04-15 00:22:32.552345 INFO wb_irrigation: 00:22:32 irrigation time tap r1 manual 15 min

Looks like the app is turning the relay on, but then it detects it was set to on and thinks i turned it on manually. I am using esphome instead of tasmota, but I donā€™t see how it would affect it here. Any ideas what is going wrong or how to find out?

I have the same issues ā€¦ Iā€™m using rainbird integration which expose each section as a switch. So seems WBI can not handle correctly switches other than tasmota? @hhaim Can it be some hint maybe ?

My logs:

2020-04-18 04:30:00.025501 INFO wb_irrigation:  irrigation event for p4_taras2
2020-04-18 04:30:00.052758 INFO wb_irrigation: 04:30:00 irrigation time tap p4_taras2 timer 0 min
2020-04-18 04:30:02.003866 INFO wb_irrigation: turn on by user p4_taras2 5 min 
2020-04-18 04:30:02.089085 INFO wb_irrigation: 04:30:02 irrigation time tap p4_taras2 manual 5 min
2020-04-18 04:30:13.270231 WARNING AppDaemon: Logged an error to /config/appdaemon/appdaemon_error.log
2020-04-18 04:30:13.271531 WARNING AppDaemon: callback do_button_change() in wb_irrigation has now completed
2020-04-18 04:30:35.008831 INFO wb_irrigation:  irrigation stop for p4_taras2 on
2020-04-18 04:35:03.007416 INFO wb_irrigation:  irrigation stop but already off p4_taras2 
2020-04-18 04:35:03.008151 INFO wb_irrigation:  irrigation stop for p4_taras2 off
2020-04-18 04:40:00.018702 INFO wb_irrigation:  irrigation event for p5_wykusz
2020-04-18 04:40:00.049350 INFO wb_irrigation: 04:40:00 irrigation time tap p5_wykusz timer 0 min
2020-04-18 04:40:01.732089 INFO wb_irrigation: turn on by user p5_wykusz 5 min 
2020-04-18 04:40:01.763870 INFO wb_irrigation: 04:40:01 irrigation time tap p5_wykusz manual 5 min
2020-04-18 04:40:35.008438 INFO wb_irrigation:  irrigation stop for p5_wykusz on
2020-04-18 04:45:02.007109 INFO wb_irrigation:  irrigation stop but already off p5_wykusz 
2020-04-18 04:45:02.008062 INFO wb_irrigation:  irrigation stop for p5_wykusz off
2020-04-18 04:45:12.013401 WARNING AppDaemon: Logged an error to /config/appdaemon/appdaemon_error.log
2020-04-18 04:45:12.015083 WARNING AppDaemon: callback time_cb_event_stop() in wb_irrigation has now completed

but more important is that I noticed errors today:

2020-04-18 04:30:13.269998 WARNING wb_irrigation: ------------------------------------------------------------
2020-04-18 04:45:12.011139 WARNING wb_irrigation: ------------------------------------------------------------
2020-04-18 04:45:12.011435 WARNING wb_irrigation: Unexpected error in worker for App wb_irrigation:
2020-04-18 04:45:12.011711 WARNING wb_irrigation: Worker Ags: {'id': '5504f3e976c14825be0677caa1262417', 'name': 'wb_irrigation', 'objectid': '0b144cd3626548c8acf87e78908b1e9b', 'type': 'scheduler', 'function': <bound method CWBIrrigation.time_cb_event_stop of <heat_app.CWBIrrigation object at 0x7f44edd98220>>, 'pin_app': True, 'pin_thread': 0, 'kwargs': {'tap': {'name': 'p5_wykusz', 'days': [1, 2, 3, 4, 5, 6, 7], 'stime': '04:40:00', 'm_week_duration_min': 'input_number.wbi_week_p5_duration', 'switch': 'switch.rainbird_zone_5', 'manual_duration': 'input_number.wbi_p5_duration', 'queue_sensor': 'sensor.wb_irrigation_p5_wykusz', 'water_sensor': 'variable.wbi_water_p5', 'time_sensor': 'variable.wbi_last_duration_p5', 'handle': '5504f3e976c14825be0677caa1262417', 'start': 0.0}, 'clear_queue': False, '__thread_id': 'thread-0'}}
2020-04-18 04:45:12.012079 WARNING wb_irrigation: ------------------------------------------------------------
2020-04-18 04:45:12.012727 WARNING wb_irrigation: Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/appdaemon/threading.py", line 766, in worker
    funcref(self.AD.sched.sanitize_timer_kwargs(app, args["kwargs"]))
  File "/config/appdaemon/apps/heat_app.py", line 1138, in time_cb_event_stop
    self.turn_off(tap["switch"])
  File "/usr/lib/python3.8/site-packages/appdaemon/plugins/hass/hassapi.py", line 29, in func_wrapper
    return func(*args, **kwargs)
  File "/usr/lib/python3.8/site-packages/appdaemon/utils.py", line 191, in inner_sync_wrapper
    f = run_coroutine_threadsafe(self, coro(self, *args, **kwargs))
  File "/usr/lib/python3.8/site-packages/appdaemon/utils.py", line 285, in run_coroutine_threadsafe
    result = future.result(self.AD.internal_function_timeout)
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 441, in result
    raise TimeoutError()
concurrent.futures._base.TimeoutError

2020-04-18 04:45:12.013105 WARNING wb_irrigation: ------------------------------------------------------------

also switch related ā€¦

Interesting observation how irrigation works now:
I noticed that when I manually turn on any rainbird switch, pipes gets water for a second (taps goes up) but a second later they goes down for a half a second and goes up again ā€¦ looks like there would be a short break or quick on/off ā€¦ really strange and most probably competently not related with WBI but rainbird integration ā€¦ anyway might be important for analysis how WBI works with external switches.

I did one more test ā€¦
via service I set -1000ev for each line.
scheduled 10 min difference between the irrigation lines ā€¦
Moved slider to 8 min each
and WBI did the following:

2020-04-18 18:07:58.299590 INFO wb_irrigation: start irrigation app
2020-04-18 18:07:59.810993 INFO wb_irrigation: irrigation init p1_front sun,mon,tue,wed,thu,fri,sat 18:05:00 
2020-04-18 18:08:00.545434 INFO wb_irrigation: irrigation init p2_bok sun,mon,tue,wed,thu,fri,sat 18:10:00 
2020-04-18 18:08:01.297475 INFO wb_irrigation: irrigation init p3_taras1 sun,mon,tue,wed,thu,fri,sat 18:20:00 
2020-04-18 18:08:02.048991 INFO wb_irrigation: irrigation init p4_taras2 sun,mon,tue,wed,thu,fri,sat 18:30:00 
2020-04-18 18:08:02.796934 INFO wb_irrigation: irrigation init p5_wykusz sun,mon,tue,wed,thu,fri,sat 18:40:00 
2020-04-18 18:08:03.550842 INFO wb_irrigation: irrigation init p6_wyspa sun 11:04:00 
2020-04-18 18:08:04.301399 INFO wb_irrigation: irrigation init p7_tujki_l sun,mon,tue,wed,thu,fri,sat 18:50:00 
2020-04-18 18:08:05.057654 INFO wb_irrigation: irrigation init p8_tujki_p sun,mon,tue,wed,thu,fri,sat 19:00:00 
2020-04-18 18:08:05.062509 WARNING AppDaemon: Excessive time spent in utility loop: 6826.0ms, 6825.0ms in check_app_updates(), 1.0ms in other
2020-04-18 18:10:00.014433 INFO wb_irrigation:  irrigation event for p2_bok
2020-04-18 18:10:00.056806 INFO wb_irrigation: 18:10:00 irrigation time tap p2_bok timer 0 min
2020-04-18 18:10:06.215753 INFO wb_irrigation: turn on by user p2_bok 8 min 
2020-04-18 18:10:06.242670 INFO wb_irrigation: 18:10:06 irrigation time tap p2_bok manual 8 min
2020-04-18 18:10:32.006649 INFO wb_irrigation:  irrigation stop for p2_bok on

started at the time point I set
informed that tam was on by user not automatically
and even if stared with 8min , WBI turned off irrigation after 1 min :frowning:

further ev have been put to 0ev.

before WBI started:

image

after 1 min:

image

@hhaim what am I doing wrong ?

This was the issue reported. Take latest code with the fix

Updated ā€¦ now it tuns off even faster

2020-04-18 20:50:00.014556 INFO wb_irrigation:  irrigation event for p1_front
2020-04-18 20:50:00.876083 INFO wb_irrigation: 20:50:00 irrigation time tap p1_front timer 0 min
2020-04-18 20:50:29.006579 INFO wb_irrigation:  irrigation stop for p1_front on

before irrigation I set ev to -1000 via service wb_irrigation.set_value to force irrigation
after 30s WBI set it back to 0ev.

Now it works. Your weekly time is set to 1m, try to make it higher (more like 30 min). The irrigation time would be about this time (weekly time for - 1000ev)

ahhh now I see ā€¦ I understood that min/max defined for individual tap or for a week in irrigation.yaml are just boundaries for WBI but real irrigation time will be fully calculated by WBI despite I move sliders in UI or not ā€¦ so I have not set anything in the UI :frowning: silly me :frowning:

now seems to be better and irrigation started for 4 min :slight_smile:

but one more thing looks strange for me ā€¦

image

image

image

definitely non of those are true
what this time Iā€™m missing ? :slight_smile:


Try to tune it. All the time are accumulation.
Please add to the wiki things could be more clear

hmm but is there anything to tune in accumulator ?

my config looks like this:

  - platform: accumulator
    name: wbi_p1_hours
    entity_id: switch.rainbird_zone_1
    state_on: 'on'
    state_off: 'off'

and it looks like accumulator counting wrongly as this is not possible that I had 117h of irrigation over last few days :slight_smile: At the beginning I had a feeling that accumulator was counting time from the beginning when I configured WBI :slight_smile: without any special connection to switch state on or off

image

similar situation with variable last duration.
My config:

      wbi_last_duration_p1:
        value: 0
        restore: true
        attributes:
           friendly_name: 'last duration p1_front'
           unit_of_measurement: "min"
time_sensor: variable.wbi_last_duration_p1 

image

99min :slight_smile: not possible as well

How to reset it ? Maybe if I start from 0 with currently/finally :slight_smile: properly configured WBI it will start counting as it should :slight_smile:

Rename the sensor and reboot. Donā€™t forget to change the same name in AppDaemon.

When it rained, when does the queue go up?
Yesterday it rained and the irrigation started at 21:30. After the irrigation the queue was set to 0. At 1:58 the queue went up again, based on the rain. Is it possible to doen this before the irrigation started? Because the irrigation wasnā€™t neccesarry.

@sen it is not a real time device, the update are slow not to kill the weather service. Give it a time. It works perfectly for me for a year now. I didnā€™t touch the system.
For your question: the queue is updated @ midnight, so if there is rain on the same day, it will be remembered for the second day, not for the same day. Donā€™t worry