petergridge / irrigation_V5

Version 5 of irrigation program - significant breaking change from v4
GNU General Public License v3.0
0 stars 0 forks source link

Water Adjust feature not working #2

Closed rjbungay closed 2 years ago

rjbungay commented 2 years ago

Hi Peter I've been continuing my testing of Irrigation_V5 and believe the water adjust feature is not working correctly. As I stated in my previous ticket, I believe this was the same in V4 of the program. I have set up a test routine with Dummy_1 for the watering switch and an input slider for adjustment factor rather than using "rainfactor". The adjustment seems to be applied correctly in the "Custom Card" and as yo can see in the screenshot taken just after I started the run, the 4min runtime is correctly scaled to 2min by the 0.5 factor. This counts down to "0:00:00" and the card shows "Dummy 1" turning off. However, the actual watering switch input_boolean.dummy_switch_1 stays on and runs for the full unadjusted 4mins. I hope this is sufficient information, if not let me know what else you need? Regards Richard Irrigation_1 Irrigation_2 d

petergridge commented 2 years ago

Hi Richard,

I found the issue, just one line of code. Good luck with the testing, I'm looking forward to the next bug you find.

Let me know how you go and I will close off this issue.

Cheers Pete

rjbungay commented 2 years ago

Hi Peter Unfortunately, that seems to have made things worse. The “Dummy 1” switch in the custom card turns on and the countdown timer shows adjusted the 0:02:00 timer (in my test case) for a second or two and then sets to 0:00:00 and turns off. The helper switch controlling the actual valve “dummy switch 1” is turned on at the same time, but now never turns off. I’ve tried to work out where this functionality is in your code to try and work out what is going wrong but failed to find it. If you let me know which line and file to look at I might be able to do some debugging? Regards Richard

petergridge commented 2 years ago

Sorry, A stupid mistake.

The bug was in irrigation.py line 285 in the new file:

                water = z_water * float(self.water_adjust_value()) * 60
                for w in range(0,int(water), 1):

I did not have the int() on the water and had int() instead of float on the adjust value.

The structure of the code is: switch.py sets up the environment, creating the program switch, creating a class for each zone (irrigationzone.py) and creates a class instance for the pumps defined for each program and the helpers for each zone.

Irrigation.py ; does the heavy lifting for the zone: has attributes to give the remaining run time etc. pump.py: monitors the need to turn on the pump while a program is running if one is defined helper.py is the cleverness for creating the helpers programmatically, I can't claim any credit for that work though.

rjbungay commented 2 years ago

Hi Peter Ok, that now seems to be working as expected in my test panel and adjust the watering time from the defined adjust helper including when ECO mode is enabled. However, my real instance is not being adjusted by your rainfactor addon. Currently is been raining here (what else do you expect in August in the UK) and the rainfactor is 0 but it is still running it’s full watering cycle. Maybe there is some problem with the way rainfactor is being passed into the program and the type is wrong or something? Thanks for all your help. Richard

petergridge commented 2 years ago

That is progress!

Do you get any errors in the log? There should be no difference between a sensor value and a input_number.

Ahh. the problem is not the sensor it is that the value is 0. you will see odd behaviour if you try it on the test bed.

Sorry, poor testing on my side, this is getting to be a beast. So glad to have your help.

petergridge commented 2 years ago

V5.0.8 fixes the issue.

petergridge commented 2 years ago

It is good you are getting rain after the hot summer, I am heading to Austria and surrounds in a few weeks from Australia so have been watching the weather.

Quick question on the rainfactor; do you use the default settings to calculate the factor or have you applied your own?

rjbungay commented 2 years ago

Thanks Peter, I’ll get that. Thanks once again for your quick support, much appreciated.

I’m currently using the default settings but was intending to look at them once I had it up and running and tune them for my location. I haven’t actually liked where to alter them yet though, where are they located?

petergridge commented 2 years ago

The defaults are applied in the code, you can change them by adding new values via the yaml

sensor:
  - platform: openweathermaphistory
    name: 'rainfactor'
    api_key: 'open weather map api key'
    num_days: 5
    day0min: 1
    day0max: 5
    day1min: 6
    day1max: 10  
    day2min: 11
    day2max: 15  
    day3min: 16
    day3max: 20  
    day4min: 21
    day4max: 25  
rjbungay commented 2 years ago

Hi Peter I render seeing those values in the description but wasn’t sure quite what they mean or how they affect the rain factor. could you give a brief explanation? I’ll test out the new fix. cheers Richard

petergridge commented 2 years ago

I read my notes that are not that clear are they:

so really a progression where the scale of the ratio expends over the 5 days until one results with a factor < 1 or runs out of days.

I have contemplated using the temperature to expand that to provide 1+ factor if the weather is extra hot and dry, but just can't get the motivation (brain power) to write the algorithm

rjbungay commented 2 years ago

Hi Peter OK, I think I understand the factoring. i have now tested v5.0.8 and the “0” case works without ECO mode. There is still a problem in ECO mode though! Test case I’m running Water =2 min, Wait =1 min, Repeat = 2x When you run this with a factor of “0” the timer pops up 0:01:00 which I guess if the wait time. But the switch is turned on straight away and never goes Off. Cheers Richard

petergridge commented 2 years ago

Thanks, I found another issue when reviewing/testing this one. The other issue was rounding of the reduced time. I was rounding down, using an int() where I should be rounding up using a ceil(). So factoring a 1 minute watering time done has no affect until the factor is 0. The factor is applied to the minutes of the run time not the seconds.

petergridge commented 2 years ago

I have release V5.0.9 with the fixes.

Have you noticed any changed behaviour with any of your helpers. input_boolean, input_number etc? I have not had any issues but am uncertain if the auto creation functionality has had any impact. I am nervous releasing this broadly without some feedback on that area.

rjbungay commented 2 years ago

Hi Peter The latest release seems to have fixed all the issues I was seeing. I have restarted HA many times while working through these problems, on one occasion I did see “entries not available” pop up in the helpers section of my dashboard for the start times but there were other valid helpers there as well. A refresh of the dashboard got rid of them. This is the only strange behaviour I have noticed with the new auto generated helpers. thanks once again for all your hard work.

petergridge commented 2 years ago

Great, thanks for your help, its not hard work but my warped sense of relaxation, I will publish this on the forum after I get back from holidays in 6 weeks or so.

My next big release is planned to be a move from YAML to config flow so everything will be configured in the UI. That one is giving me some challenges. If you don't mid I will put a call out for help testing the next version.

rjbungay commented 2 years ago

Hi Peter Yes, more than happy to test the next beta version for you while you are working on it. Cheers Richard