TillFleisch / ESPHome-Philips-Smart-Coffee

ESPHome components which implement a Philips Series 2200/3200 Coffee Machine into HomeAssistant. Capable of brewing automatic coffee.
Other
172 stars 28 forks source link

Random behavior - not brewing and resetting itself for EP_3246 #83

Open p1ranha opened 1 month ago

p1ranha commented 1 month ago

Hi, I finally managed to receive your original assembled PCB from JLC today, and after mounting the connectors, I programmed the ESP.

The whole machine started behaving erratically, I am not even able to control it properly using the screen nor ESP commands. I have following config: philips_coffee_machine: display_uart: uart_display mainboard_uart: uart_mainboard power_pin: GPIO12 id: coffee_machine language: en-US model: EP_3246

It seems like reset cycle comes in after the grinding and when brewing starts. Nothing comes out to the glass.

After manually turning on the machine, it waits for selection. I select espresso and press play. It start grinding, espresso is lit and then after grinding, all the buttons get animation of the circle. No coffee actually came out.

In the log, I see following: 14:35:56 [D] [switch:055] 'Power': Sending state ON
14:36:00 [D] [text_sensor:064] 'Status': Sending state 'Preparing'
14:36:05 [D] [text_sensor:064] 'Status': Sending state 'Idle'
14:36:08 [D] [sensor:093] 'Service Interval Counter': Sending state 8.00000 count with 0 decimals of accuracy
14:36:11 [D] [sensor:093] 'Brew Count': Sending state 8.00000 count with 0 decimals of accuracy
14:36:14 [D] [text_sensor:064] 'Status': Sending state 'Espresso selected'
14:36:35 [D] [text_sensor:064] 'Status': Sending state 'Brewing Espresso'
14:36:53 [D] [text_sensor:064] 'Status': Sending state 'Preparing'
14:37:02 [D] [text_sensor:064] 'Status': Sending state 'Idle'

Since no espresso came out, I tried coffee by selecting coffee and pressing play: 14:37:06 | [D] | [text_sensor:064] | 'Status': Sending state 'Coffee selected' 14:37:08 | [D] | [sensor:093] | 'Service Interval Counter': Sending state 9.00000 count with 0 decimals of accuracy 14:37:11 | [D] | [sensor:093] | 'Brew Count': Sending state 9.00000 count with 0 decimals of accuracy 14:37:15 | [D] | [text_sensor:064] | 'Status': Sending state 'Preparing' 14:37:28 | [D] | [text_sensor:064] | 'Status': Sending state 'Idle' 14:38:08 | [D] | [sensor:093] | 'Service Interval Counter': Sending state 9.00000 count with 0 decimals of accuracy 14:38:11 | [D] | [sensor:093] | 'Brew Count': Sending state 9.00000 count with 0 decimals of accuracy

There was no coffee coming out, and after grinding the animated loop of all buttons went thru.

Then without pressing nothing, I see some button presses happening: 14:38:35 | [D] | [text_sensor:064] | 'Status': Sending state 'Hot water selected' | nothing was pressed 14:38:38 | [D] | [text_sensor:064] | 'Status': Sending state 'Cleaning' 14:38:45 | [D] | [text_sensor:064] | 'Status': Sending state 'Preparing' 14:38:53 | [D] | [switch:055] | 'Power': Sending state OFF 14:38:53 | [D] | [switch:055] | 'PowerWithClean': Sending state OFF 14:38:53 | [D] | [text_sensor:064] | 'Status': Sending state 'Off'

Any ideas what may be wrong? Anything I do, either using normal buttons or "make espresso" has the same loop: grinding, start brewing, reset (with button led animation) before anything comes out to the glass.

p1ranha commented 1 month ago

This is when I just press "select espresso" and wait in the ESPhome:

It marks as espresso selected, then after some time it starts brewing it, never actually outputs anything and then turns itself off.

14:51:57 [D] [switch:012] 'Power' Turning ON.
14:51:58 [W] [component:237] Component esphome.coroutine took a long time for an operation (500 ms).
14:51:58 [W] [component:238] Components should block for at most 30 ms.
14:51:58 [D] [philips_power_switch:089] Performed 1 power trip(s).
14:51:58 [D] [switch:055] 'Power': Sending state ON
14:51:58 [D] [switch:055] 'PowerWithClean': Sending state ON
14:51:59 [D] [text_sensor:064] 'Status': Sending state 'Preparing'
14:52:08 [D] [sensor:093] 'Service Interval Counter': Sending state 9.00000 count with 0 decimals of accuracy
14:52:10 [D] [text_sensor:064] 'Status': Sending state 'Idle'
14:52:10 [D] [button:010] 'Select Espresso' Pressed.
14:52:11 [D] [sensor:093] 'Brew Count': Sending state 9.00000 count with 0 decimals of accuracy
14:52:12 [D] [text_sensor:064] 'Status': Sending state 'Espresso selected'
14:52:18 [D] [text_sensor:064] 'Status': Sending state 'Brewing Espresso'
14:52:26 [D] [text_sensor:064] 'Status': Sending state 'Preparing'
14:52:40 [D] [text_sensor:064] 'Status': Sending state 'Idle'
14:52:47 [D] [text_sensor:064] 'Status': Sending state 'Hot water selected'
14:52:51 [D] [text_sensor:064] 'Status': Sending state 'Cleaning'
14:53:00 [D] [text_sensor:064] 'Status': Sending state 'Preparing'
14:53:06 [D] [switch:055] 'Power': Sending state OFF
14:53:07 [D] [switch:055] 'PowerWithClean': Sending state OFF
14:53:07 [D] [text_sensor:064] 'Status': Sending state 'Off'
p1ranha commented 1 month ago

and the yaml config:

substitutions:
  name: "philips-coffee-machine"
  friendly_name: "Coffee Machine"

esphome:
  name: "${name}"
  friendly_name: "${friendly_name}"
  name_add_mac_suffix: true

  project:
    name: TillFleisch.ESPHome-Philips-Smart-Coffee
    version: "1.0"

esp8266:
  board: esp12e

logger:
  baud_rate: 0

api:

ota:
  platform: esphome
web_server:
  port: 80

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: 192.168.3.192
    gateway: 192.168.3.1
    subnet: 255.255.255.0
  ap:
    ssid: "Philips Fallback Hotspot"
    password: !secret wifi_password

time:
  - platform: homeassistant
    id: homeassistant_time

globals:
  - id: service_interval_counter
    type: int
    restore_value: true
    #initial_value: '0'
  - id: brew_count
    type: int
    restore_value: true
    #initial_value: '0'  

captive_portal:

external_components:
  - source: github://TillFleisch/ESPHome-Philips-Smart-Coffee@main

uart:
  # UART connected to the mainboard
  - tx_pin: GPIO1
    rx_pin: GPIO3
    baud_rate: 115200
    id: uart_mainboard

  # UART connected to the display
  - tx_pin: GPIO15
    rx_pin: GPIO13
    baud_rate: 115200
    id: uart_display

philips_coffee_machine:
  display_uart: uart_display
  mainboard_uart: uart_mainboard
  power_pin: GPIO12
  id: coffee_machine
  language: en-US
  model: EP_3246

text_sensor:
  - platform: philips_coffee_machine
    controller_id: coffee_machine
    id: status
    name: "Status"
    on_value:
      then:
        - lambda: |-
            if (id(status).state.find("Brewing 2x") != std::string::npos) {
              id(brew_count) += 2;
              id(service_interval_counter) += 2;
            } else if (id(status).state.find("Brewing") != std::string::npos) {
              id(brew_count) += 1;
              id(service_interval_counter) += 1;
            }       
switch:
  - platform: philips_coffee_machine
    controller_id: coffee_machine
    name: "Power"
    clean: false
    icon: mdi:coffee-maker

  - platform: philips_coffee_machine
    controller_id: coffee_machine
    name: "PowerWithClean"
    icon: mdi:coffee-maker

button:
  - platform: restart
    name: $friendly_name Restart

  - platform: philips_coffee_machine
    controller_id: coffee_machine
    action: SELECT_COFFEE
    name: "Select Coffee"
    icon: mdi:coffee
  - platform: philips_coffee_machine
    controller_id: coffee_machine
    action: MAKE_COFFEE
    name: "Make Coffee"
    icon: mdi:coffee

  - platform: philips_coffee_machine
    controller_id: coffee_machine
    action: SELECT_ESPRESSO
    name: "Select Espresso" 
    icon: mdi:coffee
  - platform: philips_coffee_machine
    controller_id: coffee_machine
    action: MAKE_ESPRESSO
    name: "Make Espresso" 
    icon: mdi:coffee

  - platform: philips_coffee_machine
    controller_id: coffee_machine
    action: PLAY_PAUSE
    name: "Select play/pause"
    icon: mdi:play-pause

sensor:
  - platform: template
    name: "Service Interval Counter"
    lambda: |-
      return id(service_interval_counter);
    state_class: measurement
    unit_of_measurement: "count"
    accuracy_decimals: 0

  - platform: template
    name: "Brew Count"
    lambda: |-
      return id(brew_count);
    state_class: measurement
    unit_of_measurement: "count"
    accuracy_decimals: 0     
p1ranha commented 1 month ago

I also just checked, and it never even created a single coffee puck. I just see grinded coffee in the coffee waste bin. so it somehow resets between grinding and making a puck. I disconnected the board today, and the machine works fine.

quack3d commented 1 month ago

Can you show your wiring? I don't use a PCB but I had lots of erratic behaviour when I used an ESP8266. When I switched to ESP32 it worked fine.

p1ranha commented 1 month ago

I ordered the original PCB with all parts assembled, so there is not much special wiring i have done.

image

image

TillFleisch commented 1 month ago

Which coffee machine model do you have?

I disconnected the board today, and the machine works fine.

That's good, the PCB also looks good.

Unfortunately, I have not yet heard of this kind of behaviour and since this modification does not change the inner working of the machine it's unexpected to see this kind of mischievous behaviour.

This component assumes that the EP_3246 is the same as the EP_3243 as the commands have been proven to work on the EP_3246 before. It may be the case that your machine is different for some reason.

I would recommend starting with a minimal configuration to figure out which part causes problems. Use a minimal configuration (generated by ESPHome) and add the external component as well the UART config and the philips_coffee_machine component.

philips_coffee_machine:
  display_uart: uart_display
  mainboard_uart: uart_mainboard
  power_pin: GPIO12
  id: coffee_machine
  language: en-US
  model: EP_3246

This should not affect the machine, as the component is only forwarding messages in both directions. Please test if the erroneous behaviour persists (while the machine is idling/has a beverage selected). If this does not help, the following configuartion can simplify the setup even more. Use a minimal ESPHome configuration, add the UART config from above and use this UART MITM external component.

Please also make sure nothing external is affecting your setup (an automation in Home Assistant for instance). I would also like to point out that ESPHome restarts the ESP every 15 min. if it's not connected to HA or WiFi, which may cause problems.

This could also be a power-related issue. Does the machine beep in the above scenario? Does the LED on the ESP blink when the machine resets/aborts?

p1ranha commented 1 month ago

Sorry, I was busy this weekend, and can only answer now. The model is: Philips 3200 series ‎EP3246/70 bought in May 2022 There are no automations yet, and no issues connecting to wifi. The led doesn't blink.

I have started with minimal yaml:

esphome:
  name: "philips-coffee-machine"
  friendly_name: "Coffee Machine"

esp8266:
  board: esp01_1m

# Enable logging
logger:
  baud_rate: 0
# Enable Home Assistant API
api:
  encryption:
    key: *redacted*

ota:
  - platform: esphome
    password: *redacted*

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: 192.168.3.192
    gateway: 192.168.3.1
    subnet: 255.255.255.0
  ap:
    ssid: "Philips Fallback Hotspot"
    password: !secret wifi_password

captive_portal:

external_components:
  - source: github://TillFleisch/ESPHome-Philips-Smart-Coffee@main

globals:
  - id: service_interval_counter
    type: int
    restore_value: true
    #initial_value: '0'
  - id: brew_count
    type: int
    restore_value: true
    #initial_value: '0' 

uart:
  # UART connected to the mainboard
  - tx_pin: GPIO1
    rx_pin: GPIO3
    baud_rate: 115200
    id: uart_mainboard

  # UART connected to the display
  - tx_pin: GPIO15
    rx_pin: GPIO13
    baud_rate: 115200
    id: uart_display

philips_coffee_machine:
  display_uart: uart_display
  mainboard_uart: uart_mainboard
  power_pin: GPIO12
  id: coffee_machine
  language: en-US
  model: EP_3246

text_sensor:
  - platform: philips_coffee_machine
    controller_id: coffee_machine
    id: status
    name: "Status"
    on_value:
      then:
        - lambda: |-
            if (id(status).state.find("Brewing 2x") != std::string::npos) {
              id(brew_count) += 2;
              id(service_interval_counter) += 2;
            } else if (id(status).state.find("Brewing") != std::string::npos) {
              id(brew_count) += 1;
              id(service_interval_counter) += 1;
            }           

log: INFO ESPHome 2024.9.1 INFO Reading configuration /config/esphome/philips-coffee-machine.yaml... INFO Starting log output from 192.168.3.192 using esphome API INFO Successfully connected to philips-coffee-machine @ 192.168.3.192 in 0.145s INFO Successful handshake with philips-coffee-machine @ 192.168.3.192 in 2.595s [12:35:31][I][app:100]: ESPHome version 2024.9.1 compiled on Sep 30 2024, 12:33:17

[12:35:31][C][wifi:428]: Local MAC: C4:D8:D5:29:EB:9E [12:35:31][C][wifi:433]: SSID: [redacted] [12:35:31][C][wifi:436]: IP Address: 192.168.3.192 [12:35:31][C][wifi:439]: BSSID: [redacted]

[12:35:31][C][wifi:443]: Signal strength: -51 dB ▂▄▆█ [12:35:31][C][wifi:447]: Channel: 1 [12:35:31][C][wifi:448]: Subnet: 255.255.255.0 [12:35:31][C][wifi:449]: Gateway: 192.168.3.1 [12:35:31][C][wifi:450]: DNS1: 0.0.0.0 [12:35:31][C][wifi:451]: DNS2: 0.0.0.0

[12:35:31][C][logger:186]: Level: DEBUG [12:35:31][C][logger:188]: Log Baud Rate: 0 [12:35:31][C][logger:189]: Hardware UART: UART0 [12:35:31][C][uart.arduino_esp8266:118]: UART Bus: [12:35:31][C][uart.arduino_esp8266:119]: TX Pin: GPIO1 [12:35:31][C][uart.arduino_esp8266:120]: RX Pin: GPIO3 [12:35:31][C][uart.arduino_esp8266:122]: RX Buffer Size: 256 [12:35:31][C][uart.arduino_esp8266:124]: Baud Rate: 115200 baud [12:35:31][C][uart.arduino_esp8266:125]: Data Bits: 8 [12:35:31][C][uart.arduino_esp8266:126]: Parity: NONE [12:35:31][C][uart.arduino_esp8266:127]: Stop bits: 1 [12:35:31][C][uart.arduino_esp8266:129]: Using hardware serial interface. [12:35:31][C][uart.arduino_esp8266:118]: UART Bus: [12:35:31][C][uart.arduino_esp8266:119]: TX Pin: GPIO15 [12:35:31][C][uart.arduino_esp8266:120]: RX Pin: GPIO13 [12:35:31][C][uart.arduino_esp8266:122]: RX Buffer Size: 256 [12:35:31][C][uart.arduino_esp8266:124]: Baud Rate: 115200 baud [12:35:31][C][uart.arduino_esp8266:125]: Data Bits: 8 [12:35:31][C][uart.arduino_esp8266:126]: Parity: NONE [12:35:31][C][uart.arduino_esp8266:127]: Stop bits: 1 [12:35:31][C][uart.arduino_esp8266:131]: Using software serial [12:35:31][C][philips_coffee_machine:132]: Philips Coffee Machine [12:35:31][C][philips_status_sensor:018]: Philips Status Text Sensor [12:35:31][C][captive_portal:089]: Captive Portal:

[12:35:31][C][mdns:117]: Hostname: philips-coffee-machine [12:35:31][C][esphome.ota:073]: Over-The-Air updates: [12:35:31][C][esphome.ota:074]: Address: 192.168.3.192:8266 [12:35:31][C][esphome.ota:075]: Version: 2 [12:35:31][C][esphome.ota:078]: Password configured [12:35:31][C][safe_mode:018]: Safe Mode: [12:35:31][C][safe_mode:019]: Boot considered successful after 60 seconds [12:35:31][C][safe_mode:021]: Invoke after 10 boot attempts [12:35:31][C][safe_mode:022]: Remain in safe mode for 300 seconds [12:35:31][C][api:139]: API Server: [12:35:31][C][api:140]: Address: 192.168.3.192:6053 [12:35:31][C][api:142]: Using noise encryption: YES [12:36:18][I][safe_mode:041]: Boot seems successful; resetting boot loop counter [12:36:49][D][text_sensor:064]: 'Status': Sending state 'Preparing' [12:37:24][D][text_sensor:064]: 'Status': Sending state 'Idle' [12:37:31][D][text_sensor:064]: 'Status': Sending state 'Brewing Espresso' [12:37:40][D][text_sensor:064]: 'Status': Sending state 'Preparing' [12:37:54][D][text_sensor:064]: 'Status': Sending state 'Idle'

Below you can find the whole video what happens since I press Power button till I press Espresso. It basically starts brewing on it's own, and resets itself abruptly. The led doesn't flash. (I cut down the video part where it's heating up and nothing happens). In the end just spewed some water in the container and unfinished puck.

https://github.com/user-attachments/assets/5e353058-8eca-48de-8dd9-c33bfc733a2d

p1ranha commented 1 month ago

Do you see anything else I could try to get it resolved?