DeLonghi Magnifica S - Home Assistant Integration With Rinse-Water Diversion

by kopytjuk in Workshop > Home Improvement

30 Views, 0 Favorites, 0 Comments

DeLonghi Magnifica S - Home Assistant Integration With Rinse-Water Diversion

Groß (IMG_0469).jpeg

Getting up in the morning and waiting for my coffee maker to heat up is not very comfortable, so I decided to enable my DeLonghi Magnifica S to be accessed by Home Assistant. My goal is to have a fresh cup of coffee waiting for me minutes after my alarm rings.

The Build:

  1. "Virtual" buttons: I connected two relays to the PCB to bridge the "Power On" and "Coffee" button presses. Those are mounted within the machine, only a cable is used as an interface to the ESP32.
  2. "Rinse Problem": These machines run a cleaning cycle on startup. To solve this, I designed and 3D printed a custom water router powered by a stepper motor and limit switches. It diverts the rinse water into one mug (black in the video) and the actual coffee into my mug.
  3. The Brains: Controlled by a NodeMCU ESP32 integrated into Home Assistant via ESPHome.

To remotely control your coffee maker (turning it on and off, preparing coffee), you have two options:

Option A: Commercial Button Pusher

Use a smart „button pusher“ like SwitchBot or Tuya Fingerbot and attach it to the front panel. This option is less visually appealing but safer than Option B.

Option B: Relays Inside the Machine

Open the machine and bypass the switches behind the buttons you need (at least two, one for Power On and one for Preparing Coffee) using a relay. Please note that this step is not recommended for individuals without electronics experience. Additionally, when you turn on the machine, some of the wires you have direct access to may have the full line voltage (230V, for example, in Europe).

I went for Option B for the rest of this guide, but do not hesitate to stay on the safe side and go with Option A.

With Option A, you will need to set up a 3-step automation in Home Assistant to turn on the machine, divert the rinse water, and prepare the coffee. With Option B, you'll have two smart buttons in HA, one for turning on and one for preparing coffee, implicitly diverting the rinse water ramp into the right position.

Supplies

20260305_192916103_iOS.jpeg
20260305_193007943_iOS.jpeg

Prerequisites:

  1. 3D (FDM) Printer
  2. Soldering Iron
  3. Silicon Wires of different colors, heat shrink tubes
  4. Adhesive Putty / Mounting Putty

Bill of Materials:

  1. 2+ Relay Modules SRD-5VDC-SL-C (alternatively: one 2 channel module)
  2. 28BYJ-48 stepper motor
  3. ULN2003 driver board
  4. 2x Micro Limit Switch
  5. Size: 12.8mm x 6,5mm (Amazon)
  6. Heat-set threaded inserts
  7. 2x for the stepper motor
  8. 4x for the limit switches
  9. 1x for the water ramp
  10. Bolts, nuts & heat inserts:
  11. Diverter Puck:
  12. 3x M4x16 DIN4762 bolts
  13. 3x M4 DIN4032 nuts
  14. Stepper motor:
  15. 2x M4x12 ISO 7380 bolts
  16. 2x M4 heat inserts, depth 6mm
  17. Limit Switches:
  18. 4x M2x10 ISO 7046-2 bolts
  19. 4x M2 heat insert, depth 3mm
  20. 5V USB power supply
  21. USB-C socket (i.e. USB-C to 5V/GND adapter)
  22. ESP32 NodeMCU Board (with WiFi)
  23. Epzilon Prototype PCB board (3,5in x 2,0in)

Bypass the Coffee Maker's Physical Buttons

20260131_135717132_iOS.jpeg
Step01_disconnect_front_panel.png
20260201_070149771_iOS.jpeg
20260201_070336600_iOS.jpeg
Step01_Solder_Cables_To_Front_Panel.jpg
Step01_Front_Panel_With_Cables.jpg
Again, please make sure that you really want to disassemble the machine! Unplug the device! Furthermore, note that you will lose the warranty of the coffee maker.


First, disassemble the machine following this video (stop at 06:00). In the end your machine should look like the first picture.

Next, disconnect the two connectors on the main board on the right side of the machine.

Now, you can dismount and remove the front panel. You see it in the third picture.

Open the front panel by loosening the bolts on the back side to get access to the circuit board of the front panel. You see both in the picture 3.

Next, you need to use your soldering iron to connect two wires to buttons you later want to trigger remotely. Retrospectively, I highly recommend to use wires with different color for each button to avoid confusion. You will need the Power-On button on the top left and at least one another "prepare coffee" button. Since I like my cup to be full, I went with "two cups" option button on the bottom right. Of course you could connect more buttons to fully control your coffee machine.

Next you need to assemble everything to its initial state. You should have at least four cables, as in my last picture. You can route the wires parallel to the ribbon cable.

This is the most challenging part of this guide. My sincere congratulations if you’ve made it so far! Of course, feel free to discover the internals of the machine.

Print the Parts

Smart Delonghi 3D printed parts.jpg

You will need to print the required parts:

  1. Rinse Water Diversion "Puck" - bottom and top part
  2. Rinse Water Ramp

If you have exact the same electronics as I do, print those, since they are optimized to the mounting holes of the ESP32 and relay modules:

  1. Relay Holder (which will installed within the machine)
  2. Case (with a lid) to hold the ESP32 module and the stepper motor driver board

Install the Relays and Assemble the Housing

20260209_095537906_iOS.jpeg
20260209_141820018_iOS.jpeg
20260215_175119329_iOS.jpeg

First, place the relays on top of the holder plate.

After that connect the button wires to the COM and NO (normally open) connections.

Mount the holder in the open volume of the coffee machine. I've used mounting putty to stick the holder onto the wall.

In addition, as shown in the second picture, I used a PCB board to reduce the amount of wires required to control the relays, from total 6 wires (Vcc-1, GND-1, Signal-1, VCC-2, etc.) to 4 wires: Vcc, GND, Signal-1 and Signal-2. However I do not recommend to do that, the effort is not worth the price, just use the 6 wires and manage them in the external electronics case. Just make sure to label the wires, so you can find the right connection later.

Alright, now you are ready to assemble the machine housing! In the last image, you can see how I routed the cables through the ventilation slots.

Prepare the Wires

20260222_163629924_iOS.jpeg
LimitSwitchWires.png

You need to connect the wires to the two limit switches (C=black and NO=color pins).

In addition, you will need a longer cable from the stepper motor to the case with the electronics: JST 5-pin male to female adapter cable (30-40cm)


Assemble the Diverter Puck

Groß (IMG_0474).jpeg
Groß (IMG_0473).jpeg

Bolts, nuts & heat inserts needed:

  1. Diverter Puck:
  2. 3x M4x16 DIN4762 bolts
  3. 3x M4 DIN4032 nuts
  4. Stepper motor:
  5. 2x M4x12 ISO 7380 bolts
  6. 2x M4 heat inserts, depth 6mm
  7. Limit Switches:
  8. 4x M2x10 ISO 7046-2 bolts
  9. 4x M2 heat insert, depth 3mm

Connect the two pieces with the three M4x16 bolts and nuts.

Using the soldering iron attach the heat-set inserts into the puck. Start with the stepper motor inserts. Mount the stepper motor with M4 bolts.

Continue with the limit-switch inserts and mount them with respective bolts in the end.

Connecting the Electronics (optionally With an Adapter PCB)

Wiring Plan_bb.png
Groß (20260224_205538125_iOS).jpeg
pcb-breakout.jpeg

Next we need to connect all the components together.

Since I wanted all the electronics in a case, I soldered a custom PCB shield to include connectors for:

  1. NodeMCU breakout board
  2. 2x Limit Switch 2-pin connectors
  3. 4-pin stepper motor connector
  4. 2-pin 5V connector (for the USB-C power supply)
  5. 2-pin relay (button) connector
  6. 2-pin 5V/GND relay power supply connector

With the connectors I could be more flexible than soldering the wires once onto the board.

Integrating Into ESPHome

Next, you need to add the NodeMCU to ESPHome as a device, so that you can flash it remotely over WiFi.

Below you see my device config. I wrote that config using an LLM, especially the auto-off timer was important to me, so that the rinse ramp is on the right position when the machine turns off automatically. Here my timer is before the factory auto-off timer, so I am certain that the rinse water will go into my rinse water cup.


esphome:
name: nodemcu-kitchen
friendly_name: NodeMCU Kitchen
# this is important, so that the stepper goes into rinse position on start up
on_boot:
priority: -10
then:
- script.execute: home_to_state_1

# board config ... (not shown here)
# wifi config ... (not shown here)

globals:
- id: machine_is_on
type: bool
restore_value: no
initial_value: 'false'

stepper:
- platform: uln2003
id: coffee_motor
pin_a: GPIO25
pin_b: GPIO26
pin_c: GPIO27
pin_d: GPIO14
# Your Arduino 'stepsPerRev' goes here
max_speed: 250 steps/s
acceleration: 50 steps/s^2

binary_sensor:
- platform: gpio
pin: {number: GPIO13, mode: INPUT_PULLUP, inverted: true} # NO switch S_L
id: limit_switch_1
on_press:
then:
- stepper.set_target: {id: coffee_motor, target: !lambda "return id(coffee_motor).current_position;"}

- platform: gpio
pin: {number: GPIO12, mode: INPUT_PULLUP, inverted: true} # NO switch S_R
id: limit_switch_2
on_press:
then:
- stepper.set_target: {id: coffee_motor, target: !lambda "return id(coffee_motor).current_position;"}

switch:
- platform: gpio
pin: GPIO23
id: relay_power
name: "Power Button"
on_turn_on:
- if:
condition:
lambda: 'return !id(machine_is_on);'
then:
- lambda: 'id(machine_is_on) = true;'
- script.execute: home_to_state_1
- script.execute: auto_off_timer # Start the 15min countdown
else:
- lambda: 'id(machine_is_on) = false;'
- script.stop: auto_off_timer
- script.execute: home_to_state_1
- delay: 500ms
- switch.turn_off: relay_power

- platform: gpio
pin: GPIO22
id: relay_coffee
name: "Brew Coffee"
on_turn_on:
- script.execute: go_to_state_2
- delay: 500ms
- switch.turn_off: relay_coffee

script:
- id: auto_off_timer
mode: restart # Restart timer if power button is pressed again
then:
- delay: 600s
- lambda: 'id(machine_is_on) = false;'
- script.execute: home_to_state_1
# rinse water position
- id: home_to_state_1
mode: restart
then:
- stepper.set_speed: {id: coffee_motor, speed: 100}
- stepper.set_target: {id: coffee_motor, target: 10000}
- wait_until:
binary_sensor.is_on: limit_switch_1
- stepper.set_target: {id: coffee_motor, target: 0}
- stepper.report_position: {id: coffee_motor, position: 0}
# preparing coffee position
- id: go_to_state_2
mode: restart
then:
- stepper.set_speed: {id: coffee_motor, speed: 100}
- stepper.set_target: {id: coffee_motor, target: -10000}
- wait_until:
binary_sensor.is_on: limit_switch_2
- stepper.set_target: {id: coffee_motor, target: !lambda "return id(coffee_motor).current_position;"}

Future Improvements

  1. Cable management
  2. Auto Off of the stepper motor driver, currently the driver holds the stepper motor in its position emitting heat. On average the device needs around 2.5W when idle.