donavanbecker / homebridge-rainbird

The Homebridge RainBird plugin allows you to access your RainBird Controller from HomeKit with Homebridge.
ISC License
20 stars 0 forks source link

Feature Request: Enable a delay watering accessory #489

Closed tbaur closed 1 year ago

tbaur commented 1 year ago

Problem

No response

Solution

Enable a delay watering accessory

Alternatives

No response

Additional context

No response

tbaur commented 1 year ago

Within the controller you can define the number of days to delay watering and program run's will skip. Ex set delay 2 days and the scheduled program will not run for 2 days, restarting automatically on the 3rd day.

Within the plugin if there was an accessory to turn delay watering on, even if it had to be a switch that when on, would just delay indefinitely until turned off... then I can use other automation (and other accessories) to flip this bit.

mantorok1 commented 1 year ago

The Rainbird's API does have a known command where you can set a delay of up to 14 days. (Command 0x36). It doesn't appear that it can be set to "indefinite" though. One option could be that you set the "delay days" in the plugin's settings (say 5 days) and then a new switch will send that to the Rainbird when turned on. Or, if you just want the ability to prevent any watering occurring while this switch is on then maybe the plugin could send a "Stop Irrigation" command when it detects that a program is running. The only problem with this is that the program will run for a short while before it detects that it was started.

tbaur commented 1 year ago

Gotcha.

I don't see an option to set delay days to 5, but turn it off while keeping the value set. In the app you set delay days to 0 for off and 1-14 for on (right, no indefinitely). However, for most of the use cases that I’m thinking of, I'd want to delay 1 day. The automation would run each day, then delay a day or not. Basically my rainbird water sensor is a start, but I can use a lot of other inputs by way of HomeKit (weather station or any weather data, temp, humidity and light sensors -- ex. even though it hasn't rained yet to trigger the rainbird water sensor, weather data says it will rain in the afternoon, so delay 1 day).

Maybe there can be a plugin config option to say -- enable delay day switch accessory and config it with "this" value for how many days to delay if turned on, between 1 and 14 days. Sounds like that could work?

mantorok1 commented 1 year ago

I think we're on the same page. In the plugin's settings there would be 2 new controls:

I haven't used that feature with my own Rainbird so I'm not quite sure how it works. If you set the delay to say 3 days does the number of days shown on the Rainbird app's slider control reduce after each passing day? I'm guessing you'd like to see the switch in the ON position until the specified number of days has expired.

tbaur commented 1 year ago

Yep, sounds right.

If you set for 3 days, it delays scheduled program runs for 3 days and shows that in the "Next Irrigation" panel within the rainbird app. If you go back into the delay watering config after the first day of delay, it'll then show 2 days for the delay remaining.

So if the plugin was set to enable delay watering by 7 days when you turn it on, the switch would have to stay on until the count expires and when it expires (gets to 0), the switch should turn off. If you manually turned the switch off at any point within the 7 days, it should also set delay watering to 0 (which is off).

mantorok1 commented 1 year ago

Thanks @tbaur. I can't see any problems with implementing this

mantorok1 commented 1 year ago

Hi @tbaur, the latest beta (version 13) includes the new "Delay Irrigation" switch. In the settings you'll see a new "Show Delay Irrigation Switch" checkbox followed by an "Irrigation Delay (days)" textbox. Give it a try and let me know if it works ok.

tbaur commented 1 year ago

Installed, configured, set a delay and removed the delay with the switch, all working. Leaving the delay on for one day to see it turn off by itself later. This is nice :-)

tbaur commented 1 year ago

Everything works best I can tell. Thanks!!

tbaur commented 1 year ago

Looks like there may be an issue. I had turned the switch on yesterday, which is config'd for 2 days. I didn't check the rainbird app. But this morning irrigation ran ...I checked and the switch was still on. I turned it off, on again. Looking at the logs, no logs for the morning irrigation run and no logs for switch off/on. Tried to manually run a zone, sat at idle.

Then I found this in the logs

[6/12/2023, 1:10:43 PM] [RainBird] RainBird controller request failed. [Error: read ECONNRESET] [6/12/2023, 1:10:43 PM] [RainBird] Will retry in 60 seconds [6/12/2023, 1:15:15 PM] [RainBird] RainBird controller request failed. [Error: read ECONNRESET] [6/12/2023, 1:15:15 PM] [RainBird] Failed to Discover Devices, "Cannot read properties of undefined (reading 'hour')"

and no rainbird plugin logs after that. Restarted homebridge, all seems to be working again. Not sure if related, but first I’ve seen this @mantorok1 -- it may have been in this state when I turned the delay switch on yesterday and so it didn't actually set the delay in rainbird.

mantorok1 commented 1 year ago

The "read ECONNRESET" error means that the connection was unexpectedly closed by the other end (i.e. on the RainBird controller). I know the connection to the RainBird can be temperamental and we recommend you don't use the RainBird app while the plugin is running for this reason. Perhaps monitor it for now and maybe turn on the "show Requests/responses" option so you can capture which requests are being made if the error returns.

tbaur commented 1 year ago

Yes, I’ve seen that before, but it always reconnects and continues on fine. I think we see this between 1:10, retry and 1:15

This is the first time it was full stop and stuck until homebridge restart. The last log entry has never been seen before on my end re failed to discover devices. No retry after that.

mantorok1 commented 1 year ago

The "Failed to Discover Devices" error should only show when the plugin is first launching. It sounds like it wasn't able to determine the current time of the controller which prevented the plugin from loading some or all of the accessories. I don't think all requests to the controller attempt a retry. We probably should look at that to make it more resilient.

tbaur commented 1 year ago

Sounds like something there -- homebridge was not restarted when that showed up. Probably unrelated to this feature, obviously :)

It's likely I hit the delay switch after this happened. HomeKit said ok, but it wasn't actually set with rainbird.

mantorok1 commented 1 year ago

Hi @tbaur, a new beta version (14) is now available which adds retries for additional request types. This should make it more resilient when connectivity issues occur. I've also added more info in the logs when connectivity issues do occur so we can capture which request was being made at the time.

tbaur commented 1 year ago

Nice! This is great. Thanks! I am updated

-tbaur

On Jun 17, 2023, at 7:59 PM, mantorok1 @.***> wrote:

Hi @tbaur, a new beta version (14) is now available which adds retries for additional request types. This should make it more resilient when connectivity issues occur. I've also added more info in the logs when connectivity issues do occur so we can capture which request was being made at the time. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

tbaur commented 1 year ago

we're good, can release

donavanbecker commented 1 year ago

v1.10.0 has been released.