New user, looking to build first rule using timers

New to HA in general, only “experience” has been Google Home. I ran into the limits of that in term of automation so here I am.

The automation that finally made me switch was the need to kick on my water recirculating pump under various conditions. I want to run it for either 5, 15, or 60 minutes. I had that setup via Google Home and it worked, until someone comes along midway through the 60 minute routine and kicks off a 5 minute timer right in the middle of a shower. There was no way to know that a routine using the recirc pump was already running.

So, in HE, I was thinking of creating a global variable to hold the max time the pump should stay on. If a new command comes in trying to adjust that time downward, it’s ignored. Only a straight up off() command should be able to kill it. But adjusting the timer to be further out would be allowed (ie I started a 5 minute timer, but decided I really want 60 minutes).

Is this a decent approach? Are there better ways? I still want to be able to issue Google voice commands so I need to figure out how to have various routines to toggle the timer. Lastly, variable name standards/suggestions?

Thanks

How are you turning on the pump? Are you telling Google Home "turn on pump for xx minutes"?

I'm always a bit leery of using timers instead of conditions or things actually happening, unless there is some way to do basic math to work around the timers.

In your case, one way to do it is have virtual switches for your time settings - 5/15/60. If any of those switches (OR statement) are on, run pump. Only turn off pump if all switches are off (AND statement).

1 Like

Yeah, the commands are basically that.

I had originally thought of using a virtual switch then quickly realized I’d need one per timespan. So figured one global var could check would be more simple. Having never built a rule though, I’m open to whatever.

My thought with the var would be when the command “5 mins” comes in, check the var if not set, set it for 5 mins in the future and execute the rest of the actions. Basically just a 5 min delay. Alternatively I suppose I could just keep check the value of the var and when now() > var, kill the pump. That would solve the issue of a longer timer being set in the middle of the short one.

If I went the virtual switch route, I’d turn in the “5 min switch” and then execute actions. Beforehand, check if the other virtual switches are on and if so, stop execution. And then various conditionals for the others. Is that what you’re suggesting?

As you note, there are likely various ways of doing this. Some will be simpler than others…

Could you share you use cases? You explained what you want to do at a high level, but more details would likely help us provide some rule examples that could meet your needs.

The only knowledge of recirculating pumps I have are for moving hot water in pipes to keep the water hot. Is this what you are looking to do, or are there other uses for those?

This was one of my first use cases that got me into HA back into 2014 and the purchase of SmartThings.

Every shower of mine has a separate shower light so I automate the pump based on turning on that switch and all family members know this. This turns on a "Hot Water" virtual switch and this switch is also available via Alexa and Home Kit so you can control by voice too. This way if any family member takes a shower at the same time the switch is already on so it doesn't turn on again.

I then have a set timer to turn off the pump at a specific duration unless all the shower lights are turned off prior to that duration in which it turns off after the last shower light is off. The timer is there in case we run the dishwasher or washer. I have mine set to 60 minutes max and will admit I am using a custom app because of complex scenarios I have to determine if the pump is on given it is not as simple as turning on a smart switch to control the pump - have a Rinnai tankless where the circ pump is controlled with a wall mount display.

You may want to reconsider the 5 vs 15 vs 60 considerations and focus on a set time because all the variances complicates things and does it really matter to run longer? The main thing is turning off at a set period and not run all the time.

does it really matter to run longer?

Other than wasting propane, no.

I think I'm going to end up going the motion sensor route (my bathroom switches don't have ground, so swapping those out for smart switches is out). I could potentially use a smart bulb in the bathrooms, but that only handles the shower which, at least in the master, is separate from the sinks. If I do that, I'll likely just do the 60 min shutoff as a backup.

As for the custom app, I'd almost prefer doing that than figure out how to implement it in rule manager; I even fired up VS Code to try an lay one down, but don't really know where to start. I wouldn't mind taking a look at yours, if possible. Your setup and use case does sound very similar to mine.

Only the 5 and 60 minute timers have voice commands currently. The 15 minute is built into a GH routine and no other way to invoke it other than that routine. As I mentioned to @ritchierich, the goal is to reduce propane consumption in the (likely) event a household member forgets to manually kill the pump when they're done using it. That said:

The 5 minute timer is really just to wash your hands, face, or the dishes real quick. It takes a couple minutes for the master bath to heat up, but 5 mins is generally long enough.

The 15 minute timer is new and is a result of feeding a newborn at all hours of the night. Once the diaper changes are done and settled, we want to wash our hands. It also kicks on a space heater by the changing station for the 15 minutes. This is a scenario where relying on motion wouldn't make much sense because I don't want to have to walk into the bathroom just to kick on the heater for a bit. Again, I don't want to forget to turn it off in the middle of the night on all of an hour of sleep.

The 60 minute timer is for shower/bathing/dishwasher.

There is something up with my plumbing to the master bath area that really messes with the water temp. I'm looking into that separately. However, as long as the recirculation pump is running, the water temp is fine. That said, if I'm in the middle of a shower, and someone in the kitchen wants to wash their hands, not realizing the pump is already on, and kicks off the 5 min timer, it'll kill the pump mid shower. So, here's the logical flow in my head:

  • given command "quick wash":
    ---check if someVariableOrSwitch is on already. If it is, ignore the quick wash command since the water pump is already on and the pipes likely already hot.
    ---if someVariableOrSwitch is off, set someVariableOrSwitch to indicate pump is running and for how long, and turn on the pump.
    ---At the end of the delay (5 mins), check the value of someVariableOrSwitch again to see if anything else requested a longer running pump. If not, kill pump and reset someVariableOrSwitch. Else, do nothing.

  • given command "water heater on":
    ---check if someVariableOrSwitch is on already.
    ---If it is not, set someVariableOrSwitch to indicate pump is running and for how long, turn pump on.
    ---Else if someVariableOrSwitch is on, see how long pump is scheduled to run. If it's shorter than 60 minutes, reset someVariableOrSwitch to new time.
    ---Check the value of someVariableOrSwitch for 60 minutes; once now() > than that value (or some other way to determine 60 minutes has passed), kill the pump, reset someVariableOrSwitch.

  • given command "water heater off":
    ---Reset someVariableOrSwitch to off (or now()), kill pump.

The 15 minute timer would likely act like the 60 minute timer.

Hence my thought of using a hub variable to hold the "scheduledPumpOffDateTime" and just contitunously check that and reset as needed.

I'm totally up for writing my own app, I just don't know where to start. Is there a library of them I can look at? I started going through the docs for the motion sensor/lighting and can follow along fine. But like most tutorials, it's hard to take it and immediately apply it to my situation.

1 Like

Tell me a little more. Do you have a dedicated hot water loop or do you have the recirculation pump valve under the farthest sink?

Honestly you don't need to run the pump for longer than it takes to get hot water to the farthest point. I have considered refactoring my setup because once in the shower hot water is available and the pump really doesn't need to run - if you have the under sink valve it shuts off automatically anyway. I have 2 under sink valves with my house configuration and again don't need to run pump longer than it is needed. I have also considered insulating my hot water lines too.

Do you have a crawl space?

I ask these questions because you could put a temp sensor at the farthest point of your recirculation line and once that reaches X temp shut off the pump. If you have a crawl space this would be easier obviously and you could use an ESP8266 board with an external temp probe to provide that temp to your hub for your rule/app to react to.

I hear you and actually wrote v1 of this app while on SmartThings before any sort of rule engine existed. I have improved it as I migrated to Hubitat 6 years ago and as I moved to a Rinnai tankless. Here is what it does:

  • Virtual switch that starts the pump and state is based on when the pump is running
  • Preference to set switches to turn on pump when they turn on, shower lights in my case
  • Preference to set switches to turn off pump when they turn off, again shower lights in my case
  • Preference to set the default number of minutes the pump stays on. This is useful if my teenage kids take a long shower or for dishwasher/laundry or if my family turns on the virtual switch to get hot water flowing and never showers.
  • Then complexity for my particular setup:
    • I don't have a way to really know when the pump is on since it is controlled by a button on a wall mounted display in my master bathroom
    • Monitors a zigbee outlet my tankless hot water heater is plugged into for wattage. Based on a threshold the pump is usually on, except in winter when power consumption increases since it will run to prevent freezing.
    • Monitors temperature sensors in my crawl space and based on 2 different readings over X temp the pump is usually on
    • Using an ESP8266 I try to detect when the button is pressed on the wall display but this unfortunately isn't 100%
    • I have a wire soldered to this display button that is connected to a dry contact relay that "pushes" the button to turn on and off the pump.

So again based on my questions above this complexity is hopefully not needed for you. My old electric water heater had a zwave receptacle that would turn on a dumb circ pump and was much easier to manage.

electric water heater had a zwave receptacle that would turn on a dumb circ pump

That's basically my setup.

Tell me a little more. Do you have a dedicated hot water loop or do you have the recirculation pump valve under the farthest sink?

Dedicated line, no pump under the sinks. As stated above, just a smart outlet in the garage that I can toggle, so I can know when the pump is running.

Honestly you don't need to run the pump for longer than it takes to get hot water to the farthest point

You'd think so, wouldn't you. And therein lies my plumbing issue I'm trying to troubleshoot separately. If I run just the master shower with the recirc pump, I get steamy hot water. While that's running, I kick on the guest shower (which is closer to the heater), and now the guest shower gets steamy and my master shower drops down to 86 deg F. Now, I'd think that if the heater couldn't keep up (it can/should according to everyone including Noritz tech support), I'd get the same "warm" water coming out of both faucets at some point. But nope, the guest shower never cools, and the master never comes back up.

Furthermore, if I don't run the recirc pump, my master doesn't get as hot as it can. Even if I run the pump to let it come up to temp, then kill it, my shower will cool slightly.

I don't have any crossovers in the line that I could detect. It's f'n weird.

I just tested the pump and master shower. With the shower being the only tap open, and open full, and the pump running, I get 111 deg.

I shut off the pump and kept the shower running and within minutes it’s down to 97 deg.

So again, something seems to be up with my plumbing. My water heater is set to output 135.

Did you install the pump or was it already in the house prior? Based on what you are saying it sounds like you don’t have a dedicated loop line and have a crossover valve under a sink, typically in farthest location. Look like this and will be mounted under a sink and screwed into back of the cabinet:

I say this because this crossover valve uses the cold water line to create the loop to get hot water through your plumbing. This said your water temperature will be higher as the pump runs because the cold water isn’t as cold given warm/hot water is flowing back via that line. I’d say your hot water piping might not be large enough for the demand, maybe 1/2 vs 3/4 or 1”.

Nope, no crossovers. The pump was installed before I bought. The only place a crossover could be that I can’t visually inspect is the master bathtub. But I killed water supply to the pump and heater and opened hot taps looking for flow on all my faucets and nada.

If I understand your requirements correctly, you want to ensure that the recirculating pump runs anytime someone uses the hot water in the kitchen (faucet or dishwasher) or in the bathrooms (Guest or Master).

Writing a rule in Rule Machine, Webcore or Groovy would allow this to be automated.

I typically use Rule Machine to write rules, and in this scenario, I would start with the following setup and rule.

Setup virtual switches for every situations/locations (use names you like - I will set some here for ease of use):

  • Create a virtual switch called Dishwasher. Setup this virtual switch to turn off automatically in 60 minutes (see “More Information” below for one way to get the switch to automatically turn off after the set amount of time)
  • Create virtual switches called KitchenHandFaucet, one called BathroomFaucet and one called MasterFaucet. Setup these switches to turn off automatically in 5 minutes
  • Create a virtual switch called KitchenDishes and set it to automatically turn off in 15 minutes
  • Create a virtual switche called MasterShower and set it to automatically turn off in 60 minutes (or however long you think the longest shower would be).

Create a Rule Machine Rule:

Trigger:
Dishwasher, KitchenHandFaucet, BathroomFaucet, MasterFaucet, KitchenDishes, MasterShower —> Any turns on

Rule:
Turn on recirculating pump
Wait for condition: Dishwasher, KitchenHandFaucet, BathroomFaucet, MasterFaucet, KitchenDishes, MasterShower —> All off
Turn off recirculating pump

Link all the Virtual Switches to Google Home:
Install or use the “Google Home” built-in app to add all the virtual switches to Google Home

Setup rules in Google Home that will allow you to turn them on or off as you wish, or just continue using voice commands like you did before, but with the new names. When any one of them is on, the recirculating pump will run until they are all off.

Possible Enhancements:

  • Purchase some motion sensors (PIR or mmWave) and place them in a spots that allows them to see motion in areas where hot water may be used (faucets or shower). Add the sensors in the rule as additional triggers and in the “Wait” condition. This will automatically turn on the pump when presence (for mmWave sensors) or motion (for PIR sensors) is detected in those areas.
  • Purchase an energy meter pug or sensor for the dishwasher, and add a trigger for the rule that when it is above a set value (ex.: 20W), the rule should run. Add an “AND” condition to the “Wait” condition that the energy meter must be under a certain wattage for it to trigger.

More Information:
To allow for the switches to easily automatically turn off at the set times, you can add the following code to your hub’s “Drivers Code” tab by clicking on “+ New Driver” and then “Import” and pasting the following link to it:
https://raw.githubusercontent.com/SebastienViel/HubitatVirtualSwitchWithContact/main/VirtualSwitchWithAuto-Off

Then select this virtual switch driver when you create your virtual switches.

If you want to give this a try but any of the steps sound too complex, or you’re not sure how to perform them, just let us know where you get stuck and I or someone else wil be able to help out. :slight_smile:

1 Like

Thanks. I like the power meter plug for the dishwasher because we'll often delay running it until after midnight.

1 Like

FWIW, it seems to have been a missing check valve on the recirc line. The pump is probably underpowered for my application and the pump was either unable, or barely able, to push against the supply water pressure. Installed a check valve and now both showers run hot, even with the pump off.

So great in that respect. And I had an excuse to get into HA.

3 Likes