Yes, progress here! A few months ago I managed to integrate Grundfos CU 301 pump controller into Home Assistant - I will try to share my solution and experiences ![:wink: :wink:](https://community.home-assistant.io/images/emoji/twitter/wink.png?v=12)
KIND WARNING:
If you don’t know what you are doing, don’t do that! Your device may be damaged. There is a risk of electric injury. All you do is at your own risk!
What I wanted to achieve:
- know the state of pump (power state, if pump is running and low water level problem)
- be able to turn it on and off
- make it detachable in case of any problems (without irreversible changes)
- for safety make it electrically isolated from the pump controller
Result:
ESPHome device:
from top - on/off push button, pump is running, (extra door sensor, humidity and temperature sensor), low water level problem and on/off state
Final Lovelace card:
![image](https://community-assets.home-assistant.io/original/4X/7/6/5/765a883ca0ca7ec638b249e9ae72e6646c29c493.png)
from top: on/off switch, pump is running, low water level problem
What you need:
- ESP32 development board running ESPHome
- at least 3 optocouplers for LED state reading
- I used this PC817 4-channel optocoupler board (but additional modification is needed)
- maybe easier would be 3 single optocouplers (but more boards and cables to organize inside pump controller)
- 3.3V 1-channel relay module for on/off button pressing
- 40 pin header socket connector for connecting cables in a detachable way
- some (dupont) cables
- 5V power supply (I used this one on DIN rail)
How to do that:
Here is sketch of pins inside pump controller:
from left:
“LEDs section”
- LED plus pole (there is voltage all the time ~10.2 V)
- maintenance LED minus pole (is connected to ground when LED is active)
- pumping top LED minus pole
- pumping middle LED
- pumping bottom LED
- low water level LED
- 5.0 bar LED
- 4.5 bar LED
- 4.0 bar LED
- 3.5 bar LED
- 3.0 bar LED
- 2.5 bar LED
- 2.0 bar LED
- turned on LED
- turned off LED
- locked LED
“Buttons section” - for button pres shortly connect button to GND
- on/off button
- pressure plus button
- pressure minus button
- not used
- not used
- GND
Note: maybe it could vary based on your HW revision…don’t know
Everything else should be clear I think ![:grinning: :grinning:](https://community.home-assistant.io/images/emoji/twitter/grinning.png?v=12)
If not, in short:
LED state detection:
Use optocouplers to parallelly connect to LEDs - be careful because all optocouplers on the board have common GND but LEDs inside the pump controller have common (+) and they are turned on by connecting to GND. You cannot interchange poles on optocouplers so either use 1-channel optocouplers or “cut” the optocouplers board (on both sides) to disconnect them. Afterthat you can interconnect IN1, IN2 and IN3 on board to reduce wiring. On output side you can interconnect GNDs to reduce wiring to ESP. Then connect GND and V1, V2 and V3 to GND and GPIO pins on ESP.
On/off button press:
At first I wanted to use also optocoupler (in reverse way) to perform button press but it had too much resistance. So that I used standard relay.
Problems:
After some time I was experiencing problems with floating states on GPIOs. I also tried different GPIOs but after some time it was the same. The solution to that was to use ADC on ESP. Now I have “pump is running” and “low water level” on ADC and “power state” on digital GPIO and it is working…today I would put all the LEDs to ADCs. Note that not all pins on ESP32 can be used as ADC, see here.
ESPHome code:
...
switch:
- platform: gpio
pin:
number: GPIO19
inverted: true
name: "On/Off button"
id: on_off_button
on_turn_on:
- delay: 500ms
- switch.turn_off: on_off_button
binary_sensor:
- platform: gpio
pin:
number: GPIO22
mode:
input: true
filters:
- delayed_off: 100ms
- delayed_on: 1000ms
id: "power_gpio"
- platform: template
name: "Power"
lambda: "return id(power_gpio).state;"
filters:
- invert
- platform: template
name: "Pumping"
lambda: "return id(pumping_voltage).state < 1;"
device_class: running
filters:
- delayed_off: 5000ms
- platform: template
name: "Low water level"
lambda: "return id(low_water_level_voltage).state < 1;"
device_class: problem
sensor:
- platform: adc
pin: GPIO32
id: pumping_voltage
update_interval: 500ms
attenuation: auto
- platform: adc
pin: GPIO33
id: low_water_level_voltage
update_interval: 5s
attenuation: auto
Home Assistant switch:
- platform: template
switches:
well_pump:
unique_id: well_pump
value_template: "{{ is_state('binary_sensor.esphome_web_d0e77c_power', 'on') }}"
turn_on:
service: switch.turn_on
target:
entity_id: switch.esphome_web_d0e77c_on_off_button
turn_off:
service: switch.turn_on
target:
entity_id: switch.esphome_web_d0e77c_on_off_button
Gallery:
Good luck and hope it helps!