petergridge/Irrigation-V5

Problem for compute next running programm time when rainy sensor is true

Closed this issue ยท 13 comments

Hi
Last version of irrigation V5 !

I'm making test for next summer ;-)
I have just one rainny sensor (for all my zone) wich is true when I don't want irrigation.
If Y have a planned next running to 20:00:00 (or 8h00 PM),

  • At 8h00 PM the programm is launched but all zones doesn't start (if rainsy sensor is true). OK at this stage
    The problem is after that, the "next cycle" displays the the time of last canceled cycle (cause of rainy sensor) instead of next compute running cycle time...
    Strange because we have in "next cycle" : a past time instead of future time ;-)

For me, the process should be when rainy sensor is true :

  • last cycle of the zone must be unchanged
  • next cycle of the zone must be the date of the next compute cycle , maybe tomorrow if frequency is on 1 day

I think it is a small bug ;-)

What is yours opinions ?

Hi @Loic691

I am testing a fix to this at the moment. For such a simple concept this has been a real pain to debug.

I expect to have a new release available soon.

The workaround to this is to use named days to schedule I.e. mon,tue... instead of a numeric frequency.

Il let you know when a beta version is available.

Cheers
Pete

Thanks for response
As soon as you have a beta, i can test if you want !
The workaround is not ok in each case.... (7 days for me).
In the following case for exemple, it doesn't working.
Next Cycle => past cancel time (cause rain sensor) instead of real next cycle

image

if you don't speak french

  • Prochain = Next
  • Dernier = Last
  • Il y a = ago

The bug linked to this issue seams a display bug... When I restart programm integration irrigation V5, the next time seams good.

It is a timing issue, the next run is not being triggered because the cycle did not run, unfortunately moving the trigger had other consequences so I am moving a lot of code around.

It will be great to have help with the testing.

Yes I think next run zone should be triggered at the beginning of the zone (before irrigation action) but with take into account rain sensor .

It's not a problem to have same next run time for each zone of a program ( as now)

Hi @Loic691,

I have had some success in testing my changes and will have a beta up next week. I am trying to track down some weird behaviour when the program is upgraded, it is hard to recreate so be aware of this when you upgrade. If you have a problem with a past start time after upgrading just change the start time of the program, to reset the next start time.

Cool, let me know when the beta is ready !

Hi I have released the beta, let me know how you go, I really need to learn how to automate my testing.

Hi
Here's the error just after restarting and update to the beta without any modification

`Logger: homeassistant
Source: custom_components/irrigationprogram/irrigationzone.py:377
Integration: Irrigation controller ([documentation](https://github.com/petergridge/irrigation-v5), [issues](https://github.com/petergridge/irrigation-v5/issues))
First occurred: 10:00:34 (2 occurrences)
Last logged: 10:00:34

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/config/custom_components/irrigationprogram/irrigationzone.py", line 336, in next_run
    frq = int(float(self.run_freq_value()))
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: could not convert string to float: 'Mon, Tue, Wed, Thu, Fri, Sat, Sun'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/irrigationprogram/switch.py", line 416, in hass_started
    await self.update_next_run()
  File "/config/custom_components/irrigationprogram/switch.py", line 250, in update_next_run
    await self.set_zone_next_run(zone, string_times[0], next_start_time)
  File "/config/custom_components/irrigationprogram/switch.py", line 257, in set_zone_next_run
    next_run = zone.next_run(first_start_time, start_time,self.irrigation_on_value())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/irrigationprogram/irrigationzone.py", line 377, in next_run
    next_run = datetime.fromtimestamp(next_run).replace(tzinfo=UTC).astimezone(tz=localtimezone)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'datetime.datetime' object cannot be interpreted as an integer`

Sorry, that last change... I forgot to comment out a line.

V5.4.8 released :)

Hi
The first error is solved on the 5.4.8.
now, another error when program end this morning ! No modification on my old programs.
The error is present on each irrigation program.
No time to test. I will start this week ;-)

2024-01-29 04:55:00.021 ERROR (MainThread) [homeassistant.core] Error executing service: <ServiceCall irrigationprogram.stop_programs (c:01HN9NPAH3ZCAP28HVTD94FSNC): ignore=Prog2>
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/core.py", line 2165, in _run_service_call_catch_exceptions
await coro_or_task
File "/usr/src/homeassistant/homeassistant/core.py", line 2186, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/irrigationprogram/__init__.py", line 104, in async_stop_programs
if hass.states.get(device).state == "on":
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'

Hi @petergridge
I'm testing your modification.
One question and doc update :

  • Is normal that the last cycle is not updated after the end of a manual launch of a zone ?

PS :
You can update the doc with theses responses I found myself ๐Ÿ‘ :

  • wait time for ECO mode is in minutes
  • repeat is the number of cycle. The zone duration water is not split by repeat times. The effective irrigation time of a zone is water * repeat. Example : If 5 minutes is define in wait and repeat = 2, the final duration will be 10 minutes

Hi, Yes it is by design that the last_ran is not updated from a manual run.

I have updated the readme.

Thanks for the feedback ๐Ÿ˜„

Thanks. All is ok for now