I’ve recently installed solar panels in my place and I’m trying to create an automation for the garden watering.
My problem is that the solar power from my panels is about 2.7KW which only allows me to run a single high-power appliance at once. I can do that just fine BUT I want to interrupt the watering when something else is turned on while it’s running and resume when power is available.
For example, I want the watering done for 15min; the microwave is turned on 7min into the program. I want the watering to suspend until the microwave is off and then resume for the 8min left.
Any general pointers on how I can achieve this? The best I can some up with is using a helper and adding a +1 after every 60 seconds of uninterrupted running but I’d like to know if there’s any better way.
There’s many ways to do this, but we’d need to see your current automation on how you set the 15 minutes in the first place. Please post the automation here, and make sure you format it properly.
I do a variety of automations like this. Rather than using long running automations with delays - for example turning the watering on, delaying 15 minutes, then turning off. I create a series of automations to run a state machine. Anyways…
The first thing I’d do is to create a binary sensor template called inhibit_watering, this goes to True whenever the watering should be inhibited regardless of whether it’s currently active.
Next create an input number to hold the desired watering duration and another to hold the remaining watering duration.
Next, create an automation(s) to start the watering at the scheduled times. That automation does:
service call - set the remaining duration to the desired duration
condition - test the inhibit (if inhibit is true sequence stops)
turns the watering switch on
Next, create an automation that runs once a minute when the watering switch is on
decrements the remaining time by 1
if remaining time is < 1 turn the switch off
Next, create an automation that runs when inhibit becomes true and switch is on
turn switch off
Next, create an automation that runs then inhibit becomes false and switch is offf and remaining time > 0
turn switch on
As a bonus exercise, I usually create an input_text and write messages to it from the automations so it’s easy to see what is going on. Also, I usually create an input_boolean to enable / disable the control. For example when this is turned off, none of the automations run.
Add all of these to the recorder and create a dashboard to view.
I find it’s also helpful to test and develop these automations not on the running system. So if you can setup a separate HA instance (like in Docker), then you can test it there. Create the sensors the automation used backed by input numbers so their values can be adjusted and the make a switch template for the output.
Have all your config in a package to are deployment easy.