Which means, 'wait 0 minutes, then turn on valve1 for 20 minutes, then valve2 for 30 minutes, valve3 for 30 minutes, valve6 for 15 minutes, and valve8 for 10 minutes". Only one valve can be on at a time and when one cycle is programmed, additional sequences can not be sent unless you cancel a current sequence.
So I’ve created a Home Assistant component for the Etherrain and am creating a ‘switch’ module currently. I think what I’m going to do is have an ‘on’ event for a valve that turns the valve on for 60 minutes (the maximum) and then let HomeAssistant abort the sequence for the ‘off’ event. The hidden assumption here is that users will know that their etherrain will only run for a maximum of 60 minutes and they’ll have to send another ‘on’ event if they want to water something for greater than 60 minutes…
The part I’m struggling with is how to deal with the restriction that when one valve is running, no other valves can be turned on. Is this just another thing the user should know? Is there some way to lock out the other valves in the UI if one is running?
The final ‘feature’ is that the unit has a ‘rain sensor’ which can be read; unfortunately, if the sensor detects rain, the valves will not turn on. Because of that, I don’t use it. Besides, I don’t care if it’s currently raining. I only care if the chance of precipitation is >X% and will make my watering decision based on that. So I’ll use Darksky for that.
So is there another way for me to go about this (other than a raspberry pi and a relay board which I’m pretty tempted to do at this point).
Just throwing something out here, so it may be half baked.
One input_select to pick your valve, and an associated input_slider to set the time (that way you can restrict it to 60 min). Maybe a switch to turn it on, after you have set your values. But this is sounding rather un-automated to me. Do you plan to set a schedule of some type for each valve?
I do hope to build a schedule. Something like “Monday/Wednesday/Friday at 6AM, turn on Valve 1 for 20 minutes unless chance of precipitation >50%”.
I currently do it with Cron and screen scrape the local weather site and it’s working superbly… but since I’ve migrated my other stuff to HA, I figured I’d write the small amount of code to talk to this device. I also have an RS485 thermostat that I hope to write an HA component for as well.
This only one valve can be on at a time thing, what happens if you try to turn another valve on if one is already on?
I’m asking, because you might get away without too much thinking. Let me explain:
Maybe you can create a switch per valve, so you end up with 8 switches. If you turn one on, then it will be running for 60 minutes, or whatever you define as default. Now if you try to turn another on, maybe nothing happens. It doesn’t turn on, but so what. As long as you can read the state of the valve somehow, HA will read it after some time and tell you it is on or off. Maybe you could tweak the turn_off command in such a way, that it cancels the running sequence if the valve is on right now.
I think that would probably work just fine. If you try to turn on another valve while the system is busy, it will just respond with an error but there will be no affect on the currently running valve.
I have already coded the turn_off command to cancel the sequence. My concern is what to do about edge cases; ie: a user has programmed a valve to turn on at 6:00, then at 6:10 turns off the valve and at 6:10, turns on another valve. Will HA attempt to run both commands at approximately the same time or worse yet, what if the next ‘on’ runs before the previous ‘off’ runs.
I could also implicitely send an ‘off’ command in the ‘turn_on’ function so as to override any active valve… Then it doesn’t matter what order events happen.
As the author of the module, I will remember to leave a minute between off and on events and I can put a note in the component documentation in case someone else does actually try to use it… I was just checking if there was a way to enforce the policy within the code.
hmm I think this start to get in the region of threating, ans asyncio. I have absolutely no knowledge about. But I would just go for the simplest solution that works. Then you can make a PR and leave a note in the documentation. If you see that it is an issue, maybe someone else comes up with a good solution, or you will have a solution by that time. The two weaks release cycle allows for fixing very quickly. And to be honest in the beginning you will be the first and only one to have such a valve. I have the same for the acer_projector switch, I guess I’,m the only person in the World to use it, but so what.