Hello everyone, I’m currently working on a project to make my Delonghi Magnifica S coffee machine smart using an ESP32 and optocouplers. The goal is to monitor the status of the machine through its LED indicators and display it in a text sensor called ‘status_kaffee’. Here’s what I’m aiming for:
- Both LEDs (Coffee and Espresso) on: The machine is ready.
- Only one LED on: The machine is brewing.
- Both LEDs off: The machine is not ready.
I’ve set up the circuit on a breadboard, and while I can successfully detect when the machine is ready or not, the brewing status isn’t showing up. I suspect the issue lies with how the ESP32 is interpreting the GPIO changes, particularly in the lambda functions. I’ve included my code below for reference, but I’m not sure where the problem might be. Any insights or suggestions would be greatly appreciated!
yaml
Example code snippet
captive_portal:
binary_sensor:
- platform: gpio
pin: GPIO27
id: led_espresso
name: “Status LED Espresso”
entity_category: diagnostic
icon: mdi:led-outline
disabled_by_default: false
publish_initial_state: true
filters:
#delayed_on_off: 100ms
- platform: gpio
pin: GPIO25
id: led_kaffee
name: “Status LED Kaffe”
entity_category: diagnostic
icon: mdi:led-outline
disabled_by_default: false
publish_initial_state: true
filters:
#delayed_on_off: 100ms
- platform: template
name: “Zubereitung Kaffee”
lambda: |-
if (id(led_kaffee).state == 1 && id(led_espresso).state == 0) {
return true;
} else {
return false;
}
on_state:
- logger.log: “Zubereitung Kaffee”
- text_sensor.template.publish: id: status_kaffee state: “Zubereitung Kaffee”
- platform: template
name: “Zubereitung Espresso”
lambda: |-
if (id(led_kaffee).state == 0 && id(led_espresso).state == 1) {
return true;
} else {
return false;
}
on_state:
- logger.log: “Zubereitung Espresso”
- text_sensor.template.publish: id: status_kaffee state: “Zubereitung Espresso”
- platform: template
name: “Maschine bereit”
lambda: |-
if (id(led_kaffee).state == 1 && id(led_espresso).state == 1) {
return true;
} else {
return false;
}
on_state:
- logger.log: “Maschine Bereit”
- text_sensor.template.publish: id: status_kaffee state: “Maschine Bereit”
- platform: template
name: “Maschine nicht bereit”
lambda: |-
if (id(led_kaffee).state == 0 && id(led_espresso).state == 0) {
return true;
} else {
return false;
}
on_state:
- logger.log: “Maschine nicht Bereit / ausgeschaltet”
- text_sensor.template.publish: id: status_kaffee state: “Maschine nicht Bereit / ausgeschaltet”
I’m really excited about this project and would love to get it working smoothly. If anyone has experience with similar setups or can spot what I might be missing, I’d be grateful for your help! Thanks in advance!