A while ago my wife and I decided to sell our primary home and buy a new home. We wanted a bigger space to build our family in. Since buying the new home, we’ve completed a few home improvement projects to really make the space ours but one thing that has always bothered me is the hot water heater. Our new home came with a tankless hot waterheater setup. Its been mostly transparent and unnoticed except for one minor annoyance: the recirculation must be triggered about five minutes before a shower. Okay, technically it doesn’t have to be triggered, but you’re going to wait a while for some hot water. We have three wireless radio buttons to trigger the recirculation remotely. I’ve tried to set those up in convenient locations but I’m not always near a button 5 mins before I want to take a shower.

The problem

How can I trigger recirculation from anywhere in my house? I want to be lazy sometimes and not have to get up and take the few steps to the nearest button then figure out what to do for five minutes. I want to be able to integrate this with other services in the future so I can trigger when I’m away (like in the car on the way home). And last but not least, I want it to be simple and seamless so its easily used by my wife and future kids.

The hardware and solution

I knew I was going to utilize the extra RasPi B+ I had sitting around after upgrading my dns sinkhole to a model 3 (Thank you pi-hole). At first, I was thinking of wiring the pi up to one of the buttons but then I realized I’d have to do some fine soldering and could potentially mess up one of the buttons. Since I’m not yet comfortable with my soldering skills that solution got set aside. Next, I thought of buying and using my own 433MHz radio module to mimmic the signal sent by the recirculation buttons. They are relatively cheap and lots of projects use them. However, while researching more I found one nice thing about my waterheater that made me change directions. The wireless receiver attached to the waterheater also has a corded, momentary, push button to trigger the recirculation. This immediately made me think transistor or relay. In fact, I found a pack of 5 relays on amazon for about $1 more than the wireless transceiver module and it was at my house in two days.

Once the relays arrived it was simply a matter of connecting everything up. I used 3 female-to-female bread board jumper wires to connect the RasPi GPIO pins to the relay. To connect the relay up to the water heater receiver, I simply cut out the momentary switch and attached the two loose wires to the relay common (usually center) and NC (normally closed). The software

The python script I wrote is located in my homeautomation repository. It allows for toggling a GPIO pin as if it were a momentary switch. I used this to first validate that I had the correct wiring and could trigger the relay w/o a load connected. Then I wired the relay over the momentary switch and confirmed the recirculation pump would fire up with a call of the script.

Home Assistant. This beautiful software project really excited me because of the vast array of available integrations. Originally I was planning on writing my own integrations to a third-party service such as alexa then I found home assistant. You can read more about Home Assistant here but the importnat piece of what I’m doing is accomplished by a few configurations in HA listed below.

  1. a shell_command component that executes my python script
trigger_waterheater_relay: 'sudo /usr/local/bin/ha_trigger_wh_recirculation.py'
  1. an input variable that tracks the state of the relay
waterheater_relay_state:
  name: 'Warm up the shower'
  initial: off
  icon: mdi:water-pump
  1. an automation script that is triggered by the input variable and executes the shell_command, sleeps, then resets the input_variable
waterheater_realy_cooldown:
  alias: 'water heater relay cooldown'
  sequence:
    - service: shell_command.trigger_waterheater_relay
    - delay: '00:05:00'
    - service: input_boolean.turn_off
    entity_id: input_boolean.waterheater_relay_state
  1. An integration config such as an alexa config for HA
# Cloud
cloud:
  alexa:

Note: homeassistant was not able to run the python script because it requires escalated privileges to interact with the GPIO pins. I opted to simply add the homeassistant user account to the sudoers file but limit the commands w/ a Cmnd Alias as shown below. This is not the most secure setup, but dfinitely better than NOPASSWD for everything.

#Cmnd alias specification
Cmnd_Alias HA_COMMANDS = /usr/local/bin/ha_*.py
# User privilege specification
homeassistant ALL=(ALL) NOPASSWD: HA_COMMANDS

Thoughts

Right now, I’m using alexa to trigger the recirculation but I could have just as easily done this with Google home or any other integration provided by Home Assistant. In the future, I plan to enable out-of-home control for those sweaty drives home where all I want is a nice hot shower the second I walk in the door. Also, there might have been better components or solutions such as reed relays or transistors but I tried to keep everything cheap, simple, and fast. So, now I have 4 more relays to automate things with or as backups in-case anything happens to my setup.

Update 2022-12-30: I recently updated to homeassistant/raspberrypi3-homeassistant:stable image which does not include the python library needed to control the GPIO pins. I don’t recall having to do this for the HA2 version container but in any case, you can fix this by installing the RPi.GPIO python package in the container.

apk add gcc libc-dev && pip install RPi.GPIO