Modifying a Gaggia Brera (Coffee Machine) to integrate with Home Assistant

The Gaggia Brera is a bean-to-cup coffee machine with no smart functionality. I wanted to be able to run the machine remotely (and to be able to brew a quadruple espresso without having to keep returning to press the button several times) so I’ve modified it to allow control via an ESP running Tasmota, and hence via Home Assistant. Here’s how!

What the mod does:

  • Lets you “press” the buttons on the front-panel via Tasmota and Home Assistant.
  • Shows the current setting of the selector (e.g. Coffee/Steam, etc.) as a sensor.

What it doesn’t do:

The mod doesn’t (yet) make the machine fully smart, in that Home Assistant doesn’t know if the machine is already brewing, run out of water, in an error state etc. I suspect there’s scope (e.g. using more analog pins to monitor other functions/sensors on the machine, etc.) to improve things. I’ll think about this in future, but if you have any ideas/advice I’d love to hear it.

Before starting, please note:

  • I have an extremely rudimentary knowledge of electronics - so while don’t think anything here will damage the machine, and it’s been working happily for me for a while, bear that in mind.
  • The mod requires working on the the AC power parts of the machine.

You will need:

  • An ESP board with 5v-tolerant GPIO (e.g. NodeMCU. I used an ESP32 version).
  • An HLK-PM01 buck converter.
  • Dupont wires, soldering materials, etc.

Modification Instructions

Flash and configure the NodeMCU:

Note: It’s important to configure the chip before installing it for a couple of reasons: a) if you don’t, you can send incorrect voltages etc. to the machine/ESP and b) you can accidentally trigger the button combination for descaling mode, which cannot be cancelled for love nor money, and takes 45 minutes to complete.

  • Flash the ESP with Tasmota (e.g. via USB).
  • Apply the template.
template {"NAME":"Gaggia Brera","GPIO":[1,1,1,1,1,1,1,1,256,1,257,1,1,1,1,1,0,1,1,1,0,1,258,259,0,0,0,0,1,1,1,1,4704,0,0,0],"FLAG":0,"BASE":1}
module 0
  • Set the relays to act like momentary buttons.
powerretain off;
pulsetime1 10;
pulsetime2 5;
pulsetime3 5;
pulsetime4 5
  • Set the friendly and web names for the buttons:
FriendlyName1 Coffee Machine Power;
FriendlyName2 Coffee Machine Aroma/Pre-Ground;
FriendlyName3 Coffee Machine Espresso;
FriendlyName4 Coffee Machine Long;
WebButton1 Power;
WebButton2 Aroma/Pre-Ground;
WebButton3 Espresso;
WebButton4 Long
  • Add a rule to publish telemetry when the analog input (i.e. the selection knob) changes.
Rule1 ON Analog#A1div10 DO teleperiod ENDON
Rule1 ON


Before doing anything disconnect mains power, obvious. For general disassembly instructions, you’ll find this video helpful, as it’s very thorough:

Solder wires to the button PCB:

  • Extract the button PCB from the front of the machine (you can leave it in its plastic bracket).
  • Solder wires to the ground pad, and to the + leg of each of the four buttons, and one to the output pin of the selector dial, shown as 0-5 in the image. (I needed to drill a few small holes in the left side of the PCB bracket to route the new wires through.)

Button PCB showing solder points.

  • Re-install the button PCB assembly.
  • Terminate the newly-installed wires with female Dupont connectors.
  • Connect the all the new wires to the relevant GPIO pins on the ESP.
  6. SELECTORGPIO36 (or other analog pin, if you’re using a different board)
  • Now would be a good time to test, using USB to power the ESP. With the machine still dismantled, you won’t be able to test fully, of course, but you should be able to power up, switch aroma mode, etc.
  • Secure the ESP somehow. I used cable ties.

Add a power supply for the ESP:

Note: Since the machine already uses 5v for its low voltage stuff, it’s tempting to power the ESP directly from the machine. I chose to fit a dedicated power supply for the ESP though as a) when I tried powering it from the button PCB it wouldn’t boot and b) I worried that it would overload the onboard 5v power and shorten the life of the machine.

  • Extract the main PCB from the rear of the machine.
  • Solder live and neutral wires to the solder points for the existing mains connector (i.e. on the underside of the PCB).
  • Solder the other ends to the AC inputs on the HLK-PM01.
  • Shrink wrap any exposed metal to isolate it.
  • Solder Dupont female connectors to the VO pins on the PM01.

Main PCB with buck converter fitted.

  • Secure the PM01 somehow. I used a cable tie.
  • Run a Dupont cable from the PM01 to the button area of the machine (avoid anything that gets hot, like the boiler) and connect it to the VIN and GND pins on the ESP.
  • Re-install the main PCB.

Final fit before reassembly.
Note there is plenty of room for the ESP behind the button PCB:

With the modification done, you can re-assemble the machine.

Home Assistant

Since you’ve already configured Tasmota, the machine should now show as a new device in Home Assistant.

The selector knob on the machine is a bit strange as works by using (rough) analog voltages to indicate one of the three discrete categories you can select (e.g. Coffee/Steam/Hot Water, etc.) This requires a template sensor (configuration.yaml) with a bit of code to do the mapping:

  - sensor:
      - name: "Coffee Machine Selector"
        state: >-
            {% set threshold=10 %}
            {% set value_coffee=380 %}
            {% set value_hot_water=2277 %}
            {% set value_steam=4095 %}
            {% set value=states('sensor.coffee_machine_analog_a1') | int %}
            {% if value_coffee-threshold < value < threshold+value_coffee %} 
            {% elif value_hot_water-threshold < value < threshold+value_hot_water %} 
              Hot Water
            {% elif value_steam-threshold < value < threshold+value_steam %} 
            {% else %} 
            {% endif %}

Also, and for convenience, here’s some code to create a dashboard for the machine, as shown above:

    title: Coffee
    path: coffee
    icon: mdi:coffee-maker
    badges: []
      - type: vertical-stack
          - type: entity
            entity: sensor.coffee_machine_selector
            icon: mdi:knob
            name: Selector
          - type: horizontal-stack
              - type: vertical-stack
                  - show_name: true
                    show_icon: true
                    type: button
                      action: call-service
                      service: switch.toggle
                      data: {}
                          - switch.coffee_machine_espresso
                    entity: switch.coffee_machine_espresso
                    icon: mdi:cup
                    name: Espresso
                  - show_name: true
                    show_icon: true
                    type: button
                      action: call-service
                      service: switch.toggle
                      data: {}
                          - switch.coffee_machine_long
                    entity: switch.coffee_machine_long
                    icon: mdi:coffee
                    name: Long
              - type: vertical-stack
                  - show_name: true
                    show_icon: true
                    type: button
                      action: call-service
                      service: switch.toggle
                      data: {}
                          - switch.coffee_machine_power
                    entity: switch.coffee_machine_power
                    icon: mdi:power
                    name: Power
                  - show_name: true
                    show_icon: true
                    type: button
                      action: call-service
                      service: switch.toggle
                      data: {}
                          - switch.coffee_machine_aroma_pre_ground
                    entity: switch.coffee_machine_aroma_pre_ground
                    icon: mdi:spoon-sugar
                    name: Aroma/Pre-Ground