Open jdchristensen opened 1 year ago
Hi, auto rain delay is basically manual adjustment with automatically rain delay detection. Not setting scale is intentional, so the firmware will not receive watering percentage changes. The firmware will reset watering percentage to 100% whenever you make changes to the weather adjustment method. So when you first switched to auto rain delay method, the watering percentage will reset to 100% therefore should not remain 0%.
But when the California restriction kicks in, it sets the percentage to 0%. And then nothing ever sets it back to 100%. This just happened to me, so that's why I dug into the code and figured out why.
An alternate solution would be to change how the California restriction is implemented. Instead of having it set the watering level to 0%, it could return rd=7
or rd=24
, using the rain delay mechanism to inhibit watering. (I suggested a 7 hour delay, since the controller polls for a weather update every 6 hours, so the rain delay would keep getting extended until the California restriction no longer applies.)
A third solution, that doesn't hardcode the adjustment method, is
else if (data.scale === undefined) {
data.scale = 100;
}
Oh, I see, I forgot that California restriction is an independent option that can be selected with auto rain delay method. Yes, I now understand the problem. Well, logically auto rain delay still should not set watering percentage because it is not an adjustment method that calculates watering percentage. Someone can be using it with, say, 50% adjustment and would not want it to reset to 100% every time a weather query is sent. So having data.scale set to undefined is to signal to the firmware to not change watering percentage. Let me think about how to handle California restriction with auto rain delay. The second solution you proposed, which is to have California restriction set rd seems the most plausible.
Actually now I remember at one point my plan was to formulate auto rain delay as an option to other weather adjustment methods, just like California restriction. So it is not an independent adjustment method but rather it's an option that user can select with any other adjustment method.
With the current set-up, if you select the California restriction with the Auto Rain Delay method, the UI doesn't let you set the water percentage any more, and resets it to 100% when you do the set-up. So my proposed code change, which only applies in this situation, shouldn't be overwriting a manually set percentage.
Still, maybe it makes sense to use rd
, or to change things like in your last message. My intention in choosing both was the following: If it rains, I don't want my sprinkler to run for a couple of days afterwards, so I selected the California restriction. Also, if it is currently raining or forecast to rain tomorrow, I also don't want my sprinkler to run. I thought this was what the Auto Rain Delay does, based on "The Auto Rain Delay method uses online weather forecast data to automatically determine a rain delay time period." (The word "forecast" suggests it looks to the future.) This is from this support article.
But maybe I'm misinterpreting things, and it doesn't make sense to choose them both?
Of course, one can use the "Manual" method and select the California restriction, and then there is a problem that is harder to fix with the current set-up, since we don't know what percentage the user had things set to before the California restriction kicked in. So maybe we should use rd
for the California restriction.
If the California restriction is triggered, it sets the watering level to 0%. But the Auto Rain Delay method never changes the watering level, so the level stays at 0% from then onwards. You can see this at this line:
https://github.com/OpenSprinkler/OpenSprinkler-Weather/blob/b486f6d26ae594e62274ca0067dd0d0eca6df7cf/routes/adjustmentMethods/RainDelayAdjustmentMethod.ts#L19
where the scale is set to undefined.
One solution is to change this line to set it to 100. The disadvantage is that this would overwrite a custom watering level set by the user. So another another is to set it to 100 only if the California restriction is enabled (since in that case the user can't manually set the percentage anyways). I think one could do that by adding an
else if
clause right after this line:https://github.com/OpenSprinkler/OpenSprinkler-Weather/blob/b486f6d26ae594e62274ca0067dd0d0eca6df7cf/routes/weather.ts#L285
The
else if
clause might look like:I can't easily test this, but I can create a PR if that would help. (I think this might also explain some of the forum posts about the controller getting stuck on 0%.)