Tips for automating spa controller

I have a spa which is branded avenli but is also sold under other brands. The display/controller connects to the pump and heater with three wires labeled gnd, hx, +5v.
I think i have two options

  1. hack the control interface between display and pump. Any ideas how to proceed
  2. wire the relevant switches and use an esphome device to trigger them as needed. I would also in that case like to monitor the leds. In that case at least heater and filter control but optionally also bubbled and temperature up and down. That would mean 3 leds and 5 switches max.

Does anyone have tips on how to proceed for case 1 and 2? I have attached images of the pump and display board

It depends on your current capabilities. This is a reverse engineering problem. Generally to reverse engineer something you need to have enough knowledge to be able to engineer it in the first place. If you do, then it is a simple matter of studying the circuit and figuring out what it does.

There is likely some (UNdocumented) protocol that the control board uses to talk to the display board. You need to figure out that protocol.

If you can achieve what you want by pressing buttons, that is the other way that is sometimes simpler.

So, start with figuring out what are your goals. What do you want to be able to control?
What do you want to be able to see?

Why do you want to do each of the above?

It seems my best option would be to try to control the buttons instead. Any tips on where to get started in order to trigger the contacts? I guess I could power an ESP from the 3 wire cable so it has common ground with the display and then try injecting 5V into one of the button terminals to simulate a button press?
How would I go on to detect LED on / off?

Maybe, maybe not. You can’t be sure the device can supply extra current Esp draws.

Esp is 3.3V controller, so you might need some additional circuit.
On the other hand buttons are more often connected to GND, so you need to sink that instead of sourcing. In any case you need to study the circuit.

You wrote, the display/button unit is connected to spa through single data wire. Does that display unit receive some info from spa, or is it only transmitting data to it?

You didn’t really state what you are trying to achieve, nor did you state how much you know about HW and SW components, or what tools you have and how well you know how to use them.

I have a heat pump water heater and it has a digital controller and the ability to connect it to the Internet. I was not really interested in controlling it, but I was interested in seeing if I could figure out what it was doing. This was not an easy project. I started with finding the schematic (which was nicely provided on the WH itself). I can’t over estimate how much easier this made the (what was still a hard) project. With the schematic, I knew that there were several temperature sensors. So my goal was trivial. I wanted to get the data from those sensors. That was it, anything more would be a bonus.

The schematic said there were RS485 data lines going to a connection and 5V (to power the optional network controller). The first thing I did was get out my DVM and measure the various pins to make sure I understood what was what. This is critical because some of the pins have 240VAC on them, which will kill you if you are not careful.

I found the 5V logic pins and it looked like there was a pin that was outputting something. I then got my oscilloscope to see the shape of the data. It looked digital. I then got out my logic analyzer and captured some data. I was lucky that the WH is very chatty so there was lots of data. My logic analyzer was unable to automatically make sense of the data. It certainly looked like UART data, but it wasn’t quite right. I then had to spend some time pondering the signal and counting the bits. It was then that I realized there were 9 data bits and 1 stop bit. This is not terribly surprising for RS485, but I am not an expert in that form of communication so it took me a little while to figure it out (completely obvious now).

Once I had the basic data format, I wrote a simple program to print out the data to see if I could make any sense of it. This took awhile to figure out that it was using a packet format. Then more time to understand the different packets and what the data meant.

So, think about what you are really trying to achieve and how much effort you are willing to put into it. There have been a few reverse engineering projects where I decided I really didn’t need to know, since I wasn’t willing to put the effort into it. But, most of the time, I have found someone else was willing to put in the effort to figure it out and then generous enough to document it well enough for others to easily follow. It appears no one has done that yet for your exact controller.

As @Karosm said many buttons are controlled by a button that shorts a pin to ground. That is pretty easy to automate, but usually you need to see what is going on to make sense. More than a decade ago years before the esp8266 was a gleam is some designers eye, I created some automation that used the RF wireless switches. I first started by hacking the remotes (adding wires to let my MCU push the buttons). Many of the controllers of the time had one button that switched the state of the relay. That would make it easy for the automation to be completely wrong. So, I made sure to only buy switches/relays that had both on and off buttons. Later, I reverse engineered the RF protocol to allow me to generate it directly. Now, I just use Wi-Fi switches with Tasmota or esphome on them. They aren’t really better at the basic function (how hard is on or off really) but do provide a better experience and more data (that I rarely look at).

The display unit receives temperature of water from the spa and displays it.

I am really only trying to achieve heater on/off in a more reliable way than using a pushbot. If I could also adjust target temperature that would be a bonus!
The heater also has a status led which blinks when it is on but not heating and is solidly lit while heating.

So it’s probably some more exotic communication line.
I wouldn’t waste too much time with that…

You can start studying the circuit for buttons and LEDs. Multimeter is must for that.

I guess the most simple would be to have a dry switch toggle the buttons I need?

That is the control panel.

That will be challenging to get it to do just about anything reliably using automation that can only press buttons.

The current design depends on having a human there that can see the display and understand what they are doing. It isn’t clear where the “brains” of the built-in control live. Is it the display board. Is the the board with the relays? Is it some other board that they both talk to?

This is why understanding what your real goal is, is so important. Maybe you need a “man in the middle” that allows both HA/esphome and the display panel to control things. But then who gets the final answer, and for how long. Requirements matter :wink:.

My real goal is to control heating so that the spa does not heat while electricity prices are high. I can live with disabling local control of e.g. temperature so maybe the easiest would be to automate the temperature up and down buttons using dry switches and then keep track of the set temperature inside home assistant. I monitor the energy usage of the spa as well as the temperature with external sensors so I can quite easily detect if it is heating or not.

Well then, the simplest solution would be to interrupt the power to the heating element. A relay/contactor controlled by an ESP board would do the trick. Or even an off-the-shelf smart plug. Insert an outlet and a plug in the circuit to the heating element and just plug the smart device in between.

I’ve looked at controlling my spa via HA, and I’m seeing all the roadblocks @neel-m mentions. If and when I go down that path, I think my approach would be to buy an ESP-controlled multi-relay board, capable of handling the currents involved, and take the existing, proprietary control panel out of the loop completely.

The problem is there’s then a useless control panel, or a hole where it used to be, in the spa. The shape and size don’t match any existing water-resistant screen I’ve seen. And controlling the spa through HA, while using the spa, would probably require voice control. Personally I’d prefer old-fashioned buttons or a screen, but they’d have to be totally waterproof. Remember electricity and water don’t play well together with human bodies.

Well, that is a much easier problem to solve. As @CaptTom suggested, all you need is a HA controlled relay that interrupts the power to the heater(s). The power usage is only 1.2KW so well within the ability of off-the-shelf parts to control. Shelly and SonOff both make devices that work with HA and/or can be converted to esphome. This is probably a plugin device so it could be as simple as a smart plug. Or you could integrate it so it only turns off the heater.

I think that might be the best option and then just set the spa controller to heat to a higher temperature than I want… Then I can override with e.g. a shelly mini:


Basically just wiring it up inside the pump. So mains to L/N and then take the live wire to the heating element and split using 0 and SW?

Just like the image presents. Heating element connected to Neutral and O.
Switch connected to Live and SW.

Right. Just be sure the Shelly is capable of handling the voltage and current the heater uses. With a bit of a safety margin. I assume it’s 120V, but check the current draw of the heater, too.

In the wiring diagram above, the shelly would be inserted in the hot wire from the controller to the heater. That would come in as “L” at the top of the diagram, but you probably wouldn’t want a switch, as shown. It would just feed the SW and L terminals on the Shelly. The wire would continue to the heater from “O”. You’d also need to bring a neutral from somewhere to connect to “N”.

If the Shelly works the way I think it does, It will toggle any time “L” is switched on or off. So, yes, you’d want to be sure your existing controller never tries to turn the power to the heater off. Not only will that down-power the Shelly, but it could turn it back on when the Shelly powers back up. You might be better off finding a non-switched power terminal on the control board, and connecting to that instead of using the existing heater wire.

I think a Shelly 1 in dry contact mode is probably simpler as that will just disconnect one of the wires to the heater on my request. Then I can power the Shelly from elsewhere

1 Like

hmm. Heater seems to have four wires on the main board if I guess correctly labelled A, B, C, D.
Red circle are the four wires I think are for heating, blue go to a large airpump and yellow to the circulation pump

It’s not anyhow simpler, actually there is one more wire…

I like Shelly1 more though…

Where do the white wires go? Can you see them all connect at the heater? In other words, is it a multi-stage heater (with like 3 different heating elements)?

Finally, did we ever resolve what voltage (US 120 or 240, EU/UK 240, or what)?

Looks like 2x PTC heating elements.
Why don’t you pull the control board out to see the whole circuit. There are probably separate relays switching the elements.