ESP smart сoffee machine Philips 5400 Series

I figured it out a bit and found the sensors of the drink counter. Created a table of what and how to parse bytes. It turns out that bytes of this type AA:AA:AA:FF are sensors

image


AA:AA:AA:FF:B0:01:B0:30:A5:65:E8:55 - Drinks counter (Cappuccino) - number 65
AA:AA:AA:FF:CB:01:CB:35:8A:16:77:55 - Drink counter (Latte ma.) - digit 16
AA:AA:AA:FF:2D:01:2D:6A:61:10:93:55 - Drinks counter (Hot) - digit 10
AA:AA:AA:FF:B4:01:B4:F5:C9:01:E8:55 - Drinks counter (Coffee with mo.) - digit 01
AA:AA:AA:FF:18:01:18:32:82:03:E7:55 - Drink counter (Espresso) - digit 03
AA:AA:AA:FF:36:01:36:17:E4:06:09:55 - Drinks counter (Dairy) - digit 6
AA:AA:AA:FF:23:01:23:67:61:36:7E:55 - The drinks counter (Coffee with m.) is the number 36
AA:AA:AA:FF:D1:01:D1:E9:55:C5:9B:55 - Drinks counter (Express) - digit 197
AA:AA:AA:FF:66:01:66:53:9B:D1:0E:55 - Beverage counter (America.) - digit 521
AA:AA:AA:FF:A5:01:A5:40:20:55:9F:55 - Drinks counter (Coffee) - number 55

I’m not good at ESPHome. How do I create sensors to extract bytes, because they have changing data. ChatGPT shows me some kind of game and I have already stopped believing it, because it often gives false answers. Below I made a config with the iron-specified bits. For example bytes[9]==0xC5 is the number 197 if translated from HEX to a number. So the data bytes[7]==XX && bytes[8]==XX && bytes[9]==XX && bytes[10]==XX change here, but it needs to be displayed in the sensor as numbers

uart:
 - id: uart_display
   rx_pin: GPIO16
   tx_pin: GPIO17
   baud_rate: 115200
   stop_bits: 1
   data_bits: 8
   parity: NONE
#   rx_buffer_size: 256
#   debug:
#    direction: BOTH
#    dummy_receiver: false


 - id: uart_mainboard
   rx_pin: GPIO3
   tx_pin: GPIO1
   baud_rate: 115200
   stop_bits: 1
   data_bits: 8
   parity: NONE
   rx_buffer_size: 256
   debug:
     direction: BOTH
     dummy_receiver: false
     sequence: 
      - lambda: |-
          UARTDebug::log_hex(direction, bytes, ':');
            if (bytes[0]==0xAA && bytes[3]==0xFF && bytes[4]==0xD1 && bytes[5]==0x01 && bytes[9]==0xC5 && bytes[11]==0x55) { id(idDrinkscountEspress).publish_state("197"); }
            else if (bytes[0]==0xAA && bytes[3]==0xFF && bytes[4]==0x18 && bytes[5]==0x01 && bytes[9]==0x03 && bytes[11]==0x55) { id(idDrinkscounterEspresso).publish_state("03"); }
            else if (bytes[0]==0xAA && bytes[3]==0xFF && bytes[4]==0x23 && bytes[5]==0x01 && bytes[9]==0x36 && bytes[11]==0x55) { id(idDrinkscounterCoffeeMilk).publish_state("36"); }
            else if (bytes[0]==0xAA && bytes[3]==0xFF && bytes[4]==0xA5 && bytes[5]==0x01 && bytes[9]==0x55 && bytes[11]==0x55) { id(idDrinkscounterCoffee).publish_state("55"); }
            else if (bytes[0]==0xAA && bytes[3]==0xFF && bytes[4]==0x66 && bytes[5]==0x01 && bytes[9]==0xD1 && bytes[11]==0x55) { id(idDrinkscounterAmerica).publish_state("521"); }


text_sensor:
##### Drinks counter
#Drink counter: Espresso 1
  - platform: template
    id: idDrinkscountEspress
    name: "Espress counter"
    update_interval: 30s

#Drink counter: Espresso 2
  - platform: template
    id: idDrinkscounterEspresso
    name: "Espresso counter"
    update_interval: 30s

#Beverage Counter: Coffee
  - platform: template
    id: idDrinkscounterCoffee
    name: "Coffee Counter"
    update_interval: 30s

#Beverage counter: Coffee with milk (Coffee with m.)
  - platform: template
    id: idDrinkscounterCoffeeMilk
    name: "Coffee Counter with Milk"
    update_interval: 30s

#Drinks counter: America.
  - platform: template
    id: idDrinkscounterAmerica
    name: "Counter Americano"
    update_interval: 30s

That's what GhatGPT offers me, utter nonsense. I will give examples to understand why I don't trust GhatGPT
text_sensor:
  - platform: template
    id: idDrinkscounterEspresso1
    name: "Drink counter: Espresso 1"
    update_interval: 60s
    lambda: |-
      if (id(uart_mainboard).state.length() >= 12 &&
          id(uart_mainboard).state[0] == 0xAA &&
          id(uart_mainboard).state[3] == 0xFF &&
          id(uart_mainboard).state[9] == 0xE0 &&
          id(uart_mainboard).state[11] == 0x55) {
        char byte4Str[3];
        snprintf(byte4Str, sizeof(byte4Str), "%02X", id(uart_mainboard).state[4]);
        return std::string(byte4Str);
      } else {
        return std::string("");
      }
text_sensor:
  - platform: template
    id: idDrinkscounterEspresso1
    name: "Drink counter: Espresso 1"
    update_interval: 60s
    lambda: |-
      if (bytes[0] == 0xAA && bytes[3] == 0xFF && bytes[9] == 0xE0 && bytes[11] == 0x55) {
        char byte4Str[3];
        snprintf(byte4Str, sizeof(byte4Str), "%02X", bytes[4]);
        return std::string(byte4Str);
      } else {
        return std::string("");
      }

and when you try to upload the firmware, I get this error

/config/esphome/esp32-smart-coffee-philips.yaml: In lambda function:
/config/esphome/esp32-smart-coffee-philips.yaml:135:11: error: 'bytes' was not declared in this scope
       if (bytes[0] == 0xAA && bytes[3] == 0xFF && bytes[9] == 0xE0 && bytes[11] == 0x55) {
           ^~~~~
/config/esphome/esp32-smart-coffee-philips.yaml:135:11: note: suggested alternative: 'byte'
       if (bytes[0] == 0xAA && bytes[3] == 0xFF && bytes[9] == 0xE0 && bytes[11] == 0x55) {
           ^~~~~
           byte
/config/esphome/esp32-smart-coffee-philips.yaml:142:3: warning: control reaches end of non-void function [-Wreturn-type]
 
   ^
*** [/data/esp32-smart-coffee-philips/.pioenvs/esp32-smart-coffee-philips/src/main.cpp.o] Error 1
========================== [FAILED] Took 7.20 seconds ==========================

Hi again,

I faced the same challenge, but for my stove i just used esp-link to set up the serial line, and build a custom integration (now on HAcs) from there using python.

Maybe it has some usefull info?

@aceindy The option that was offered is too complicated, you need something simpler. You need something like this. This is a very similar option for this project. I need to extract 9 bytes with changeable bits and show them in the sensor as numbers.

I tried to do it like his, but I ran into a problem. After filling in the code after successful compilation on ESP, an error occurs:

WARNING Can’t connect to ESPHome API for esp32-smart-coffee-philips.local: Error connecting to (‘192.168.1.52’, 6053): [Errno 111] Connect call failed (‘192.168.1.52’, 6053)

and the web interface becomes unavailable. If I comment out the user sensor, the web interface becomes available. I don’t understand how the user sensor blocks the web interface?

Here’s what I did that causes the API to be blocked and after that esp is not available either through the Home Assistant or through the web interface, but I can upload the firmware via ESPHome

esphome:
  name: ${node_name}
  friendly_name: esp32-smart-coffee-philips
  comment: ESP32 Smart Coffee Philips
  includes:
    - /config/esphome/components/smart_coffee_philips_5400/philips5400_sensor.h

sensor:
- platform: custom
  lambda: |-
    auto coffeedrinkcount = new DrinkCountSensor(id(uart_mainboard));
    App.register_component(coffeedrinkcount);
    return {
      coffeedrinkcount->counter_espress,
      coffeedrinkcount->counter_espresso,
      coffeedrinkcount->counter_coffee,
      coffeedrinkcount->counter_coffee_milk,
      coffeedrinkcount->counter_america
      };

  sensors:
    - name: "Espress"
      id: "counter_espress"
    - name: "Espresso"
      id: "counter_espresso"
    - name: "Coffee"
      id: "counter_coffee"
    - name: "Coffee Milk"
      id: "counter_coffee_milk"
    - name: "America"
      id: "counter_america"

The code in the philips 5400_sensor.h component itself

#include "esphome.h"

class DrinkCountSensor : public PollingComponent, public Sensor, public UARTDevice {
  public:
    DrinkCountSensor(UARTComponent *parent) : PollingComponent(600), UARTDevice(parent) {}

  Sensor *counter_espress = new Sensor();
  Sensor *counter_espresso = new Sensor();
  Sensor *counter_coffee = new Sensor();
  Sensor *counter_coffee_milk = new Sensor();
  Sensor *counter_america = new Sensor();

  void setup() override {}

  std::vector<int> bytes;

  void update() override {
    if (bytes[0] == 0xAA && bytes[3] == 0xFF && bytes[11] == 0x55) {
      uint8_t counter_byte = static_cast<uint8_t>(bytes[9]);
      const uint8_t BIT_COUNTER_ESPRESS = 0xD1; 
      const uint8_t BIT_COUNTER_ESPRESSO = 0x18; 
      const uint8_t BIT_COUNTER_COFFEE = 0xA5; 
      const uint8_t BIT_COUNTER_COFFEE_MILK = 0x23;
      const uint8_t BIT_COUNTER_AMERICA = 0x66;

      counter_espress->publish_state(static_cast<bool>(counter_byte & BIT_COUNTER_ESPRESS));
      counter_espresso->publish_state(static_cast<bool>(counter_byte & BIT_COUNTER_ESPRESSO));
      counter_coffee->publish_state(static_cast<bool>(counter_byte & BIT_COUNTER_COFFEE));
      counter_coffee_milk->publish_state(static_cast<bool>(counter_byte & BIT_COUNTER_COFFEE_MILK));
      counter_america->publish_state(static_cast<bool>(counter_byte & BIT_COUNTER_AMERICA));

      bytes.clear();
    }
  }
};

The API found the reason for the breakdown, it turns out that you need to specify a restriction and a condition like this, but the problem with the output of counters is not solved.

if (bytes.size() < 12) {
        continue;

ChatGPT advises me a lot of things. Below is the code for his answers and nothing works, the sensors are not displayed

So prescribed in the configuration

text_sensor:
  - platform: custom
    lambda: |-
      auto coffeedrinkcount = new DrinkCountSensor(id(uart_mainboard));
      App.register_component(coffeedrinkcount);
      return {
        coffeedrinkcount->counter_espress,
        coffeedrinkcount->counter_espresso,
        coffeedrinkcount->counter_coffee,
        coffeedrinkcount->counter_coffee_milk,
        coffeedrinkcount->counter_america
        };

    text_sensors:
      - name: "Espress"
        id: "counter_espress"
      - name: "Espresso"
        id: "counter_espresso"
      - name: "Coffee"
        id: "counter_coffee"
      - name: "Coffee Milk"
        id: "counter_coffee_milk"
      - name: "America"
        id: "counter_america"

In the philips 5400_sensor.h file

#include "esphome.h"

class DrinkCountSensor : public PollingComponent, public UARTDevice {
 public:
  DrinkCountSensor(UARTComponent *parent) : PollingComponent(10000), UARTDevice(parent) {}

  TextSensor *counter_espress           = new TextSensor();
  TextSensor *counter_espresso          = new TextSensor();
  TextSensor *counter_coffee            = new TextSensor();
  TextSensor *counter_coffee_milk       = new TextSensor();
  TextSensor *counter_america           = new TextSensor();

  std::vector<uint8_t> bytes;

  void update() override {
    while (available() > 0) {
      bytes.push_back(read());

      if (bytes.size() < 12) {
        continue;
      } else {
        if (bytes.size() == 12 && bytes[3] == 0xFF && bytes[11] == 0x55) {
          uint8_t counter_byte = bytes[9];
          const uint8_t BIT_COUNTER_ESPRESS[] = {0xD1, 0x01, 0xD1}; // Beverage Counter (Express)
          const uint8_t BIT_COUNTER_ESPRESSO[] = {0x18, 0x01, 0x18}; // Beverage counter (Espresso)
          const uint8_t BIT_COUNTER_COFFEE[] = {0xA5, 0x01, 0xA5}; // Beverage counter (Coffee)
          const uint8_t BIT_COUNTER_COFFEE_MILK[] = {0x23, 0x01, 0x23}; // Drinks counter (Coffee with milk)
          const uint8_t BIT_COUNTER_AMERICA[] = {0x66, 0x01, 0x66}; // Beverage Counter (Americano)

          counter_espress->publish_state(std::string(reinterpret_cast<const char*>(BIT_COUNTER_ESPRESS), 3));
          counter_espresso->publish_state(std::string(reinterpret_cast<const char*>(BIT_COUNTER_ESPRESSO), 3));
          counter_coffee->publish_state(std::string(reinterpret_cast<const char*>(BIT_COUNTER_COFFEE), 3));
          counter_coffee_milk->publish_state(std::string(reinterpret_cast<const char*>(BIT_COUNTER_COFFEE_MILK), 3));
          counter_america->publish_state(std::string(reinterpret_cast<const char*>(BIT_COUNTER_AMERICA), 3));

          bytes.clear();  // Reset the bytes vector
        }
      }
    }
  }
};

This version of the code works, but there the bytes are specified rigidly and if the bit changes, the sensor will not be displayed correctly. you need to somehow extract bits from 9 bytes and forward them to the sensor

 - id: uart_mainboard
   rx_pin: GPIO3
   tx_pin: GPIO1
   baud_rate: 115200
   stop_bits: 1
   data_bits: 8
   parity: NONE
   rx_buffer_size: 256
   debug:
     direction: BOTH
     dummy_receiver: false
     sequence: 
      - lambda: |-
          UARTDebug::log_hex(direction, bytes, ':');
          if (bytes[0]==0xAA && bytes[3]==0xFF && bytes[4]==0xD1 && bytes[5]==0x01 && bytes[9]==0xC5 && bytes[11]==0x55) { id(idDrinkscountEspress).publish_state("197"); }
          else if (bytes[0]==0xAA && bytes[3]==0xFF && bytes[4]==0x18 && bytes[5]==0x01 && bytes[9]==0x03 && bytes[11]==0x55) { id(idDrinkscounterEspresso).publish_state("03"); }
          else if (bytes[0]==0xAA && bytes[3]==0xFF && bytes[4]==0x23 && bytes[5]==0x01 && bytes[9]==0x36 && bytes[11]==0x55) { id(idDrinkscounterCoffeeMilk).publish_state("36"); }
          else if (bytes[0]==0xAA && bytes[3]==0xFF && bytes[4]==0xA5 && bytes[5]==0x01 && bytes[9]==0x55 && bytes[11]==0x55) { id(idDrinkscounterCoffee).publish_state("55"); }
          else if (bytes[0]==0xAA && bytes[3]==0xFF && bytes[4]==0x66 && bytes[5]==0x01 && bytes[9]==0xD1 && bytes[11]==0x55) { id(idDrinkscounterAmerica).publish_state("521"); }

The good thing is, you got to the point of using a lambda to introduce C code into your ESPHome. Now it’s just a matter of defining the proper mask bit variables and moving the code out of the 5400_sensor.h. For a good example of bit manipulation, review Samuel Seib’s Wiegand component in the ESPHome GitHub

I’m not a programmer and I don’t know esphome well, I use mostly ready-made options. But since I really want to integrate my coffee machine into the Home Assistant, I put all my efforts to what I can. Now I decided to switch to byte search and found the following. I checked and it works. But I can’t find the commands to control. Later I will describe how I found these bytes. If someone undertakes to write code, I will be only glad

And also took aim at these bytes. I think it reflects what kind of drink we are preparing. In order for me to understand this, I will prepare different drinks and compare

Here is my code for ESPHome
substitutions:
  board_name: ESP32 Smart Coffee Philips
  node_name: esp32-smart-coffee-philips

esphome:
  name: ${node_name}
  friendly_name: esp32-smart-coffee-philips
  comment: ESP32 Smart Coffee Philips

esp32:
  board: esp32dev
  framework:
    type: arduino

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: on
  reboot_timeout: 10min
  ap:
    ssid: ESP SmartCoffeePhilips
    password: !secret ap_esp_password

captive_portal:

web_server:
  port: 80

logger:
  level: DEBUG
  baud_rate: 0

ota:
  password: "esphome"

api:
  encryption:
    key: !secret api_key


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


uart:
 - id: uart_mainboard
   rx_pin: GPIO3
   tx_pin: GPIO1
   baud_rate: 115200
   stop_bits: 1
   data_bits: 8
   parity: NONE
   rx_buffer_size: 256
   debug:
     direction: TX
     dummy_receiver: false


 - id: uart_display
   rx_pin: GPIO16
   tx_pin: GPIO17
   baud_rate: 115200
   stop_bits: 1
   data_bits: 8
   parity: NONE
   rx_buffer_size: 256
   debug:
     direction: TX
     dummy_receiver: false
     sequence: 
      - lambda: |-
          UARTDebug::log_hex(direction, bytes, ':');
          //AA:AA:AA:B0
          if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[6]==0x06 && bytes[9]==0x00) { 
            id(idWater).publish_state("There is water");
            id(idCoffeeGroundsContainer).publish_state("Inserted");
            id(idMakingCoffee).publish_state("Choose a drink");
            }
          //AA:AA:AA:B0 "Took out the container with water"
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[6]==0x0E && bytes[9]==0x40) { id(idWater).publish_state("There is no water"); }
          //AA:AA:AA:B0 "Removed the pallet"  
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[6]==0x0E && bytes[9]==0x80) { id(idCoffeeGroundsContainer).publish_state("Retrieved"); }

          //AA:AA:AA:B0 "The pallet and the container with water were taken out"
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[6]==0x0E && bytes[9]==0xC0) { 
            id(idWater).publish_state("There is no water"); 
            id(idCoffeeGroundsContainer).publish_state("Retrieved");
            }

          //AA:AA:AA:B0 "Making coffee"
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x0C && bytes[7]==0x01) { id(idMakingCoffee).publish_state("Enjoy (01)"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x07 && bytes[7]==0x0E) { id(idMakingCoffee).publish_state("Pause (0E)"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x07 && bytes[7]==0x0D) { id(idMakingCoffee).publish_state("Grinding grains (0D)"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x07 && bytes[7]==0x10) { id(idMakingCoffee).publish_state("Pour milk (10)"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x07 && bytes[7]==0x11) { id(idMakingCoffee).publish_state("Pour coffee (11)"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x07 && bytes[7]==0x12) { id(idMakingCoffee).publish_state("12"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x07 && bytes[7]==0x13) { id(idMakingCoffee).publish_state("Creating pressure for milk (13)"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x07 && bytes[7]==0x14) { id(idMakingCoffee).publish_state("14"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x07 && bytes[7]==0x15) { id(idMakingCoffee).publish_state("15"); }
          
          //AA:AA:AA:B5 "Status 1"
          if (bytes[0]==0xAA && bytes[3]==0xB5 && bytes[5]==0x06 && bytes[10]==0x00 && bytes[11]==0x00) { id(idStatusUnknown1).publish_state("00"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB5 && bytes[5]==0x06 && bytes[10]==0x00 && bytes[11]==0x0B) { id(idStatusUnknown1).publish_state("0B"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB5 && bytes[5]==0x06 && bytes[10]==0x00 && bytes[11]==0xE6) { id(idStatusUnknown1).publish_state("E6"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB5 && bytes[5]==0x06 && bytes[10]==0x00 && bytes[11]==0x80) { id(idStatusUnknown1).publish_state("80"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB5 && bytes[5]==0x06 && bytes[10]==0x00 && bytes[11]==0xCB) { id(idStatusUnknown1).publish_state("CB"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB5 && bytes[5]==0x06 &&& bytes[10]==0x00 & bytes[11]==0xFF) { id(idStatusUnknown1).publish_state("FF"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB5 && bytes[5]==0x06 && bytes[10]==0x00 && bytes[11]==0xA0) { id(idStatusUnknown1).publish_state("A0"); }
          
          //AA:AA:AA:B5 "Status 2"
          else if (bytes[0]==0xAA && bytes[3]==0xB5 && bytes[5]==0x06 && bytes[10]==0x00) { id(idStatusUnknown2).publish_state("00"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB5 && bytes[5]==0x06 && bytes[10]==0x01) { id(idStatusUnknown2).publish_state("01"); }



philips_series_2200:
  display_uart: uart_display
  mainboard_uart: uart_mainboard
  power_pin: GPIO12
  id: philip


text_sensor:
  - platform: template
    id: idWater
    name: "Water"
    update_interval: 10s

  - platform: template
    id: idCoffeeGroundsContainer
    name: "Coffee Grounds Container"
    update_interval: 10s

  - platform: template
    id: idUnknown
    name: "Unknown"
    update_interval: 10s

  - platform: template
    id: idStatusCoffee
    name: "Status Coffee"
    update_interval: 10s

  - platform: template
    id: idMakingCoffee
    name: "Stages of coffee preparation"
    update_interval: 10s


button:
  - platform: restart
    name: Restart
    icon: mdi:restart

  - platform: template
    name: "Turn off" 
    on_press:
      - uart.write:
          id: uart_mainboard
          data: [0xAA, 0xAA, 0xAA, 0xFE, 0x00, 0x00, 0xC8, 0x87, 0x1B, 0x40, 0x55] #AA:AA:AA:FE:00:00:C8:87:1B:40:55

I will share my experience of how I found bytes. this can help others who want to join this project and bring it to the end.

In order to find the necessary bytes, you do not need to press the same buttons many times and time the time, because even if you fix the time of pressing, the execution in the logs will be as we fixed.

The first thing to do is install ESPHome on Windows and write all the data to a log file.

Copy the configuration file from ESPHome to Home Assistant on Windows to the ESPHome folder and run the log entry with the command, specifying our configuration file and the name of the text file for the logs

esphome logs esp32-smart-coffee-philips.yaml > esp32_philips5400_protocol.txt

Next, I copied the text file into Word and specified the key bytes, these are the address and functions

Function Description

AA:AA:AA:93 - display of the selected program on the LCD
AA:AA:AA:90 - a set of recipes
AA:AA:AA:91 - starting the preparation of a drink
AA:AA:AA:B0 - sensors of water container, tray, coffee grounds, coffee preparation statuses
AA:AA:AA:B5 - counters for making coffee and milk drinks
AA:AA:AA:BA - apparently service information, firmware version, date
AA:AA:AA:BB - rarely comes across
AA:AA:AA:FF - data from the control panel
AA:AA:AA:FE - turning off the coffee machine


If we see differences, we insert them into a notepad and compare them, and we see how the bytes change. This is the anomaly, this is our bytes

We look in word, where the countdown started at 07:07:10 96:00:00 / 96:00:02 / 96:00:05 / 96:00:06

This can be used in the sensor if there is a desire to track the status of the preparation of milk foam from 0 to 100%

For example, we are looking for bytes for a container with water and a pallet



Hooray :partying_face:, I found how to operate a coffee machine. To make coffee, we look in the logs for the address and functions that are listed below, this is the command to start making coffee. Start recording in the log, select the parameters we need (strength, amount of water, number of cups) to make coffee and run, then we find the command in the logs. Why is that? Because then we run what we set in the settings, so you can create a lot of different scripts with different parameters.

AA AA AA 93 
AA AA AA 90 
AA AA AA 91

The commands must go strictly in this order, although they may be scattered in the logs, but in ESPHome we specify in this sequence

AA AA AA 93 07 01 01 04 86 E2 E5 55 
AA AA AA 90 08 0A 00 02 00 02 03 00 1E 00 00 00 98 80 81 70 55
AA AA AA 91 09 01 03 A9 02 7B AB 55
This is how the commands in the logs look like



Example of a button to run a command from a log in ESPHome

button:
  - platform: template
    name: "Espresso X1" 
    on_press:
      - uart.write:
          id: uart_mainboard
          data: [0xAA, 0xAA, 0xAA, 0x93, 0x07, 0x01, 0x01, 0x04, 0x86, 0xE2, 0xE5, 0x55]
      - uart.write:    
          id: uart_mainboard
          data: [0xAA, 0xAA, 0xAA, 0x90, 0x08, 0x0A, 0x00, 0x02, 0x00, 0x02, 0x03, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x98, 0x80, 0x81, 0x70, 0x55]
      - uart.write:    
          id: uart_mainboard
          data: [0xAA, 0xAA, 0xAA, 0x91, 0x09, 0x01, 0x03, 0xA9, 0x02, 0x7B, 0xAB, 0x55]

What is implemented in the code?

  1. Status of the water container
  2. Pallet status (coffee grounds container)
  3. Coffee grounds sensor
  4. Coffee preparation statuses
  5. Sensor for the presence of coffee beans
  6. One recipe for making Espresso for 30 ml for the dough, then you can create buttons with recipes yourself
  7. Turning off the coffee machine
Full and working code
substitutions:
  board_name: ESP32 Smart Coffee Philips
  node_name: esp32-smart-coffee-philips

esphome:
  name: ${node_name}
  friendly_name: esp32-smart-coffee-philips
  comment: ESP32 Smart Coffee Philips

esp32:
  board: esp32dev
  framework:
    type: arduino

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: on
  reboot_timeout: 10min
  ap:
    ssid: ESP SmartCoffeePhilips
    password: !secret ap_esp_password

captive_portal:

web_server:
  port: 80

logger:
  level: DEBUG
  baud_rate: 0

ota:
  password: "esphome"

api:
  encryption:
    key: !secret api_key


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


uart:
 - id: uart_mainboard
   rx_pin: GPIO3
   tx_pin: GPIO1
   baud_rate: 115200
   stop_bits: 1
   data_bits: 8
   parity: NONE
   rx_buffer_size: 256
   debug:
     direction: TX
     dummy_receiver: false


 - id: uart_display
   rx_pin: GPIO16
   tx_pin: GPIO17
   baud_rate: 115200
   stop_bits: 1
   data_bits: 8
   parity: NONE
   rx_buffer_size: 256
   debug:
     direction: TX
     dummy_receiver: false
     sequence: 
      - lambda: |-
          UARTDebug::log_hex(direction, bytes, ':');
          //AA:AA:AA:B0
          if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[6]==0x06 && bytes[9]==0x00) { 
            id(idWater).publish_state("There is water");
            id(idPallet).publish_state("Inserted");
            id(idMakingCoffee).publish_state("Choose a drink");
            id(idCoffeeGroundsContainer).publish_state("Empty");
            id(idGrainTray).publish_state("There are coffee beans");
            }

          //AA:AA:AA:B0 "Availability of coffee beans"
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x08 && bytes[7]==0x05) { id(idGrainTray).publish_state("Coffee beans are out"); }

          //AA:AA:AA:B0 "Took out the container with water"
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[6]==0x0E && bytes[9]==0x40) { id(idWater).publish_state("There is no water"); }

          //AA:AA:AA:B0 "Removed the pallet"  
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[6]==0x0E && bytes[9]==0x80) { id(idPallet).publish_state("Retrieved"); }

          //AA:AA:AA:B0 "The container with coffee grounds is filled"
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x0E && bytes[9]==0x00) { id(idCoffeeGroundsContainer).publish_state("Oporozhe. container for coffee grounds"); }


          //AA:AA:AA:B0 "The pallet and the container with water were taken out"
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[6]==0x0E && bytes[9]==0xC0) { 
            id(idWater).publish_state("There is no water"); 
            id(idPallet).publish_state("Retrieved");
            }

          //AA:AA:AA:B0 "Making coffee"
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x0C && bytes[7]==0x01) { id(idMakingCoffee).publish_state("Enjoy (01)"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x07 && bytes[7]==0x0E) { id(idMakingCoffee).publish_state("Pause (0E)"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x07 && bytes[7]==0x0D) { id(idMakingCoffee).publish_state("Grinding grains (0D)"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x07 && bytes[7]==0x10) { id(idMakingCoffee).publish_state("Pour milk (10)"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x07 && bytes[7]==0x11) { id(idMakingCoffee).publish_state("Pour coffee (11)"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x07 && bytes[7]==0x12) { id(idMakingCoffee).publish_state("12"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x07 && bytes[7]==0x13) { id(idMakingCoffee).publish_state("Creating pressure for milk (13)"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x07 && bytes[7]==0x14) { id(idMakingCoffee).publish_state("14"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x07 && bytes[7]==0x15) { id(idMakingCoffee).publish_state("15"); }
          
          //AA:AA:AA:B5 "Status 1"
          if (bytes[0]==0xAA && bytes[3]==0xB5 && bytes[5]==0x06 && bytes[10]==0x00 && bytes[11]==0x00) { id(idStatusUnknown1).publish_state("00"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB5 && bytes[5]==0x06 && bytes[10]==0x00 && bytes[11]==0x0B) { id(idStatusUnknown1).publish_state("0B"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB5 && bytes[5]==0x06 && bytes[10]==0x00 && bytes[11]==0xE6) { id(idStatusUnknown1).publish_state("E6"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB5 && bytes[5]==0x06 && bytes[10]==0x00 && bytes[11]==0x80) { id(idStatusUnknown1).publish_state("80"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB5 && bytes[5]==0x06 && bytes[10]==0x00 && bytes[11]==0xCB) { id(idStatusUnknown1).publish_state("CB"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB5 && bytes[5]==0x06 &&& bytes[10]==0x00 & bytes[11]==0xFF) { id(idStatusUnknown1).publish_state("FF"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB5 && bytes[5]==0x06 && bytes[10]==0x00 && bytes[11]==0xA0) { id(idStatusUnknown1).publish_state("A0"); }
          
          //AA:AA:AA:B5 "Status 2"
          else if (bytes[0]==0xAA && bytes[3]==0xB5 && bytes[5]==0x06 && bytes[10]==0x00) { id(idStatusUnknown2).publish_state("00"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB5 && bytes[5]==0x06 && bytes[10]==0x01) { id(idStatusUnknown2).publish_state("01"); }



philips_series_2200:
  display_uart: uart_display
  mainboard_uart: uart_mainboard
  power_pin: GPIO12
  id: philip


text_sensor:
  - platform: template
    id: idWater
    name: "Water"
    update_interval: 10s

  - platform: template
    id: idCoffeeGroundsContainer
    name: "Coffee Grounds Container"
    update_interval: 10s

  - platform: template
    id: idPallet
    name: "Coffee Pallet"
    update_interval: 10s

  - platform: template
    id: idUnknown
    name: "Unknown"
    update_interval: 10s

  - platform: template
    id: idStatusCoffee
    name: "Status Coffee"
    update_interval: 10s

  - platform: template
    id: idMakingCoffee
    name: "Stages of coffee preparation"
    update_interval: 10s

  - platform: template
    id: idGrainTray
    name: "Grain Tray"
    update_interval: 10s


button:
  - platform: restart
    name: Restart
    icon: mdi:restart

  - platform: template
    name: "Turn off" 
    on_press:
      - uart.write:
          id: uart_mainboard
          data: [0xAA, 0xAA, 0xAA, 0xFE, 0x00, 0x00, 0xC8, 0x87, 0x1B, 0x40, 0x55] #AA:AA:AA:FE:00:00:C8:87:1B:40:55
2 Likes

Extracted recipes for making coffee drinks. Not all work and the program does not always run correctly. Probably because it is necessary to substitute only certain bytes, and not all where there are generated and managed bytes, and probably because I insert the generated bytes, this confuses the program, since the generated bytes go as a counter

In the screenshot, I highlighted bytes that indicate which drink needs to be made, strong, with or without milk

Recipes for making coffee drinks

Drink: Espresso. Grain: Minimum. Coffee: 30 ml. Serving: 1

AA:AA:AA:93:07:01:01:04:86:E2:E5:55
AA:AA:AA:90:08:0A:00:02:00:02:03:00:1E:00:00:00:98:80:81:70:55
AA:AA:AA:91:09:01:03:A9:02:7B:AB:55


Drink: Espresso X1. Grain: Medium. Coffee: 40 ml. Serving: 1

AA:AA:AA:93:25:01:01:8A:14:2B:DE:55
AA:AA:AA:90:26:0A:00:01:00:02:03:00:28:00:00:00:C6:13:4C:6D:55
AA:AA:AA:91:27:01:03:43:69:A8:99:55


Drink: Espresso X1. Grain: Maximum. Coffee: 40 ml. Serving: 1

AA:AA:AA:93:05:01:01:6A:52:66:E6:55
AA:AA:AA:90:06:0A:00:02:00:01:01:00:28:00:00:00:6D:4F:D0:30:55
AA:AA:AA:91:07:01:03:A3:2F:E5:A1:55


Drink: Espresso X2. Grain: Maximum. Coffee: 40 ml. Serving: 2
AA:AA:AA:93:19:01:01:7E:08:5A:F3:55
AA:AA:AA:90:1A:0A:00:02:01:01:01:00:28:00:00:00:8E:EF:68:F5:55
AA:AA:AA:91:1B:01:03:B7:75:D9:B4:55


Drink: Espresso X1. Grain: Extra Shot. Coffee: 90 ml. Serving: 1

AA:AA:AA:93:09:01:01:0E:AB:7C:EF:55
AA:AA:AA:90:0A:0A:00:02:02:01:01:00:5A:00:00:00:86:6D:C9:B6:55
AA:AA:AA:91:0B:01:03:C7:D6:FF:A8:55


Drink: Coffee X1. Grain: Maximum. Coffee: 150 ml. Serving: 1

AA:AA:AA:93:15:01:01:1A:F1:40:FA:55
AA:AA:AA:90:16:0A:00:02:00:02:02:00:96:00:00:00:0B:F3:19:76:55
AA:AA:AA:91:17:01:03:D3:8C:C3:BD:55


Drink: Americano X1. Grain: Maximum. Coffee: 100 ml. Serving: 1

AA:AA:AA:93:21:01:01:56:BC:22:D9:55
AA:AA:AA:90:22:0A:01:02:00:02:02:00:28:00:3C:00:18:D5:AA:00:55
AA:AA:AA:91:23:01:03:9F:C1:A1:9E:55


Drink: Cappuccino. Grain: Maximum. Coffee: 80 ml. Milk: 150 ml

AA:AA:AA:93:1D:01:01:A2:A0:53:F4:55
AA:AA:AA:90:1E:0A:03:02:00:02:03:02:50:00:96:00:75:22:83:5E:55
AA:AA:AA:91:1F:01:03:6B:DD:D0:B3:55


Drink: Latte Macchiato. Grain: Maximum. Coffee: 40 ml. Milk: 200 ml

AA:AA:AA:93:11:01:01:C6:59:49:FD:55
AA:AA:AA:90:12:0A:03:02:00:02:02:02:28:00:C8:00:F8:44:66:1A:55
AA:AA:AA:91:13:01:03:0F:24:CA:BA:55


Drink: Coffee with milk. Grain: Maximum. Coffee: 150 ml. Milk: 90 ml

AA:AA:AA:93:0F:01:01:BC:D7:F1:EB:55
AA:AA:AA:90:10:0A:02:02:00:02:01:02:96:00:5A:00:C6:12:D1:21:55
AA:AA:AA:91:11:01:03:61:F0:4E:B9:55

AA:AA:AA:93:0D:01:01:D2:03:75:E8:55
AA:AA:AA:90:0E:0A:02:02:00:02:01:02:96:00:5A:00:24:2C:F8:C4:55
AA:AA:AA:91:0F:01:03:1B:7E:F6:AF:55

To run any recipe, create a button

An example of launching a Cappuccino drink. Grain: Maximum. Coffee: 80 ml. Milk: 150 ml

button:
#Drink: Cappuccino. Grain: Maximum. Coffee: 80 ml. Milk: 150 ml
  - platform: template
    name: "Cappuccino. Grain: Maximum. Coffee: 80 ml. Milk: 150 ml" 
    on_press:
      - uart.write:
          id: uart_mainboard
          data: [0xAA, 0xAA, 0xAA, 0x93, 0x07, 0x01, 0x01, 0x04, 0x86, 0xE2, 0xE5, 0x55] 
      - uart.write:    
          id: uart_mainboard
          data: [0xAA, 0xAA, 0xAA, 0x90, 0x08, 0x0A, 0x03, 0x02, 0x00, 0x02, 0x03, 0x02, 0x50, 0x00, 0x96, 0x00, 0x69, 0x6A, 0xA6, 0xBD, 0x55] 
      - uart.write:    
          id: uart_mainboard
          data: [0xAA, 0xAA, 0xAA, 0x91, 0x09, 0x01, 0x03, 0xA9, 0x02, 0x7B, 0xAB, 0x55] 

An example of launching an Espresso drink. Grain: Extra Shot. Coffee: 90 ml. Serving: 1

button:
#Drink: Espresso. Grain: Extra Shot. Coffee: 90 ml. Serving: 1
  - platform: template
    name: "Espresso X1 Extra Shot 90ml" 
    on_press:
      - uart.write:
          id: uart_mainboard
          data: [0xAA, 0xAA, 0xAA, 0x93, 0x09, 0x01, 0x01, 0x0E, 0xAB, 0x7C, 0xEF, 0x55]
      - uart.write:    
          id: uart_mainboard
          data: [0xAA, 0xAA, 0xAA, 0x90, 0x0A, 0x0A, 0x00, 0x02, 0x02, 0x01, 0x01, 0x00, 0x5A, 0x00, 0x00, 0x00, 0x86, 0x6D, 0xC9, 0xB6, 0x55]
      - uart.write:    
          id: uart_mainboard
          data: [0xAA, 0xAA, 0xAA, 0x91, 0x0B, 0x01, 0x03, 0xC7, 0xD6, 0xFF, 0xA8, 0x55]
2 Likes

I partially deciphered the protocol of coffee drinks, if in the future I understand what the remaining bytes mean, I will definitely update the information. If you understand what it could be, write. I didn’t quite understand what the 7, 8, 9 and 10 bytes mean. I assume that some of them are responsible for the fortress, grain or ground.

Using a calculator with the selected programmer mode, you can enter HEX and get DEC and find out the volume of coffee and milk


I found a specific oddity in launching the found recipes via ESPHome. If bytes are found in PulseView and pulled out through export to a file, then this will not work.

It’s just that the bytes are clearly visible in PulseView and there is an understanding of what the command should look like, but unfortunately I couldn’t get the recipes to run

In order for the recipes to run, it is necessary to make changes to the coffee parameters and save them to the profile, then it will be possible to catch a working team and it will work.

Step-by-step instructions

  1. Make sure that direction: RX is enabled in the configuration, it is not recommended to use BOTH or TX. If you turn on BOTH or TX, then when you change the coffee settings on the control panel, the changes will not be saved and what is in the ESP logs will start and this also prevents you from getting data.
An example of how to configure debugging to catch recipes for further launch
uart:
 - id: uart_display
   rx_pin: GPIO16
   tx_pin: GPIO17
   baud_rate: 115200
   stop_bits: 1
   data_bits: 8
   parity: NONE
   rx_buffer_size: 256
   debug:
     direction: RX
     dummy_receiver: false


 - id: uart_mainboard
   rx_pin: GPIO3
   tx_pin: GPIO1
   baud_rate: 115200
   stop_bits: 1
   data_bits: 8
   parity: NONE
   rx_buffer_size: 256
   debug:
     direction: RX
     dummy_receiver: false
  1. We turn on the coffee machine, as it turns off after we fill the firmware on the esp

  2. Enable logging to a file on your computer. This is very important and it must be started before the preparation of the drink is started. Read more about this here.

  3. Select the desired program. For example, choose a cappuccino, then change the strength, volume of coffee and milk by pressing OK until a picture appears on the screen with a message that you need to install a jug of milk and press start. It is important that the settings are saved in the profile, you need to change something

  4. After clicking on start, if the settings have been changed, a message will appear on the screen that the changes will be saved to such and such a profile, for example in green. Which profile, it doesn’t matter, we just need the recipe to be saved to the profile, and at this moment the data will be captured and written to a log file.

  5. We stop writing to the log

  6. Open a text file with logs and look for 3 lines with bytes, look for AA at once:AA:AA:90, these are our coffee drink recipes

AA:AA:AA:93 - display of the selected program on the LCD
AA:AA:AA:90 - a set of recipes
AA:AA:AA:91 - starting the preparation of a drink

Look carefully, they may be hidden among other bytes. I’ve highlighted how I found them and show how it might look

  1. Let’s say we found the necessary bytes. Below is an example of how I pull out the necessary bytes and create a button with a coffee drink recipe

For convenience, I will take out the code separately and it may be updated from time to time if new sensors and commands for control are found.

What is implemented in the code?

  1. Status of the water container
  2. Pallet status (coffee grounds container)
  3. Coffee grounds sensor
  4. Coffee preparation statuses
  5. Sensor for the presence of coffee beans
  6. Turning off the coffee machine
  7. System sensors showing: switching on, flushing, warming up, turning off
Full and working code
substitutions:
  board_name: ESP32 Smart Coffee Philips
  node_name: esp32-smart-coffee-philips

esphome:
  name: ${node_name}
  friendly_name: esp32-smart-coffee-philips
  comment: ESP32 Smart Coffee Philips

esp32:
  board: esp32dev
  framework:
    type: arduino

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: on
  reboot_timeout: 10min
  ap:
    ssid: ESP SmartCoffeePhilips
    password: !secret ap_esp_password

captive_portal:

web_server:
  port: 80

logger:
  level: DEBUG
  baud_rate: 0

ota:
  password: "esphome"

api:
  encryption:
    key: !secret api_key


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


uart:
 - id: uart_mainboard
   rx_pin: GPIO3
   tx_pin: GPIO1
   baud_rate: 115200
   stop_bits: 1
   data_bits: 8
   parity: NONE
   rx_buffer_size: 256
   debug:
     direction: RX
     dummy_receiver: false


 - id: uart_display
   rx_pin: GPIO16
   tx_pin: GPIO17
   baud_rate: 115200
   stop_bits: 1
   data_bits: 8
   parity: NONE
   rx_buffer_size: 256
   debug:
     direction: RX
     dummy_receiver: false
     sequence: 
      - lambda: |-
          UARTDebug::log_hex(direction, bytes, ':');
          //AA:AA:AA:B0
          if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x06 && bytes[9]==0x00) { 
            id(idWater).publish_state("There is water");
            id(idPallet).publish_state("Inserted");
            id(idMakingCoffee).publish_state("Not preparing");
            id(idCoffeeGroundsContainer).publish_state("Empty");
            id(idGrainTray).publish_state("There are coffee beans");
            id(idSystemStatus).publish_state("Choose a drink");
            }
          //AA:AA:AA:B0 "Availability of coffee beans"
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x08 && bytes[7]==0x05) { id(idGrainTray).publish_state("Coffee beans are out"); }

          //AA:AA:AA:B0 "Took out the container with water"
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x0E && bytes[9]==0x40) { id(idWater).publish_state("There is no water"); }

          //AA:AA:AA:B0 "Removed the pallet"
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x0E && bytes[9]==0x80) { id(idPallet).publish_state("Retrieved"); }

          //AA:AA:AA:B0 "The container with coffee grounds is filled"
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x0E && bytes[9]==0x00) { id(idCoffeeGroundsContainer).publish_state("Oporozhe. container for coffee grounds"); }

          //AA:AA:AA:B0 "The pallet and the container with water were taken out"
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x0E && bytes[9]==0xC0) { 
            id(idWater).publish_state("There is no water"); 
            id(idPallet).publish_state("Retrieved");
            }
          
          //AA:AA:AA:B0 "System statuses"
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x0C && bytes[7]==0x01) { id(idMakingCoffee).publish_state("Enjoy"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x0C && bytes[7]==0x02) { id(idMakingCoffee).publish_state("Something (07 0C 02)"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x07 && bytes[7]==0x0E) { id(idMakingCoffee).publish_state("Water heating"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x07 && bytes[7]==0x0D) { id(idMakingCoffee).publish_state("Grinding the grains"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x07 && bytes[7]==0x10) { id(idMakingCoffee).publish_state("Pour the milk"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x07 && bytes[7]==0x11) { id(idMakingCoffee).publish_state("Pour the coffee"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x07 && bytes[7]==0x12) { id(idMakingCoffee).publish_state("12"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x07 && bytes[7]==0x13) { id(idMakingCoffee).publish_state("Creating steam for milk"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x07 && bytes[7]==0x14) { id(idMakingCoffee).publish_state("14"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x07 && bytes[7]==0x15) { id(idMakingCoffee).publish_state("15"); }

          //AA:AA:AA:B0 "Flushing and other"
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x01 && bytes[7]==0x00) { id(idSystemStatus).publish_state("Something (07 01 00)"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x02 && bytes[7]==0x00) { id(idSystemStatus).publish_state("Enabled"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x05 && bytes[7]==0x00) { id(idSystemStatus).publish_state("Off"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x08 && bytes[7]==0x0E) { id(idSystemStatus).publish_state("Heating"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x08 && bytes[7]==0x02) { id(idSystemStatus).publish_state("Flushing"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB0 && bytes[5]==0x07 && bytes[6]==0x08 && bytes[7]==0x14) { id(idSystemStatus).publish_state("Something (07 08 14)"); }

          //AA:AA:AA:B5 "Status 1"
          if (bytes[0]==0xAA && bytes[3]==0xB5 && bytes[5]==0x06 && bytes[10]==0x00 && bytes[11]==0x00) { id(idStatusUnknown1).publish_state("00"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB5 && bytes[5]==0x06 && bytes[10]==0x00 && bytes[11]==0x0B) { id(idStatusUnknown1).publish_state("0B"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB5 && bytes[5]==0x06 && bytes[10]==0x00 && bytes[11]==0xE6) { id(idStatusUnknown1).publish_state("E6"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB5 && bytes[5]==0x06 && bytes[10]==0x00 && bytes[11]==0x80) { id(idStatusUnknown1).publish_state("80"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB5 && bytes[5]==0x06 && bytes[10]==0x00 && bytes[11]==0xCB) { id(idStatusUnknown1).publish_state("CB"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB5 && bytes[5]==0x06 &&& bytes[10]==0x00 & bytes[11]==0xFF) { id(idStatusUnknown1).publish_state("FF"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB5 && bytes[5]==0x06 && bytes[10]==0x00 && bytes[11]==0xA0) { id(idStatusUnknown1).publish_state("A0"); }
          
          //AA:AA:AA:B5 "Status 2"
          else if (bytes[0]==0xAA && bytes[3]==0xB5 && bytes[5]==0x06 && bytes[10]==0x00) { id(idStatusUnknown2).publish_state("00"); }
          else if (bytes[0]==0xAA && bytes[3]==0xB5 && bytes[5]==0x06 && bytes[10]==0x01) { id(idStatusUnknown2).publish_state("01"); }


philips_series_5400:
  display_uart: uart_display
  mainboard_uart: uart_mainboard
  power_pin: GPIO12
  id: philip



#####################################################################################
################################### Text Sensor ################################
text_sensor:
  - platform: wifi_info
    ip_address:
      name: ${board_name} IP

  - platform: template
    name: "Water"
    id: idWater
    update_interval: 60s

  - platform: template
    name: "Coffee Grounds Container"
    id: idCoffeeGroundsContainer
    update_interval: 60s

  - platform: template
    name: "Coffee Pallet"
    id: idPallet
    update_interval: 60s

  - platform: template
    name: "Status 1"
    id: idStatusUnknown1
    update_interval: 60s

  - platform: template
    name: "Status 2"
    id: idStatusUnknown2
    update_interval: 60s

  - platform: template
    name: "Making Coffee"
    id: idMakingCoffee
    update_interval: 10s

  - platform: template
    name: "Grain Tray"
    id: idGrainTray
    update_interval: 60s

  - platform: template
    id: idSystemStatus
    name: "System Status"
    update_interval: 60s


button:
  - platform: restart
    name: Restart
    icon: mdi:restart

  - platform: template
    name: "Turn off" 
    on_press:
      - uart.write:
          id: uart_mainboard
          data: [0xAA, 0xAA, 0xAA, 0xFE, 0x00, 0x00, 0xC8, 0x87, 0x1B, 0x40, 0x55] #AA:AA:AA:FE:00:00:C8:87:1B:40:55


#####################################################################################
############################ Coffee Recipes #############################

#Drink: Coffee X1. Grain: Maximum. Coffee: 150 ml. Serving: 1
  - platform: template
    name: "Coffee Max 150ml" 
    on_press:
      - uart.write:
          id: uart_mainboard
          data: [0xAA, 0xAA, 0xAA, 0x93, 0x05, 0x01, 0x01, 0x6A, 0x52, 0x66, 0xE6, 0x55]
      - uart.write:    
          id: uart_mainboard
          data: [0xAA, 0xAA, 0xAA, 0x90, 0x06, 0x0A, 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x78, 0x00, 0x00, 0x00, 0xFC, 0x28, 0xA1, 0x4C, 0x55]
      - uart.write:    
          id: uart_mainboard
          data: [0xAA, 0xAA, 0xAA, 0x91, 0x07, 0x01, 0x03, 0xA3, 0x2F, 0xE5, 0xA1, 0x55]


#Drink: Cappuccino. Grain: Minimum (2 out of 5 level scale). Coffee: 20 ml. Milk 100 ml.
  - platform: template
    name: "Cappuccino Min 20/100ml" 
    on_press:
      - uart.write:
          id: uart_mainboard
          data: [0xAA, 0xAA, 0xAA, 0x93, 0x05, 0x01, 0x01, 0x6A, 0x52, 0x66, 0xE6, 0x55]
      - uart.write:    
          id: uart_mainboard
          data: [0xAA, 0xAA, 0xAA, 0x90, 0x06, 0x0A, 0x03, 0x01, 0x00, 0x02, 0x03, 0x02, 0x14, 0x00, 0x64, 0x00, 0xE7, 0xC9, 0xE6, 0x5F, 0x55]
      - uart.write:    
          id: uart_mainboard
          data: [0xAA, 0xAA, 0xAA, 0x91, 0x07, 0x01, 0x03, 0xA3, 0x2F, 0xE5, 0xA1, 0x55]


#Drink: Cappuccino. Grain: Maximum. Coffee: 60 ml. Milk: 150 ml
  - platform: template
    name: "Cappuccino Max 60/150ml" 
    on_press:
      - uart.write:
          id: uart_mainboard
          data: [0xAA, 0xAA, 0xAA, 0x93, 0x05, 0x01, 0x01, 0x6A, 0x52, 0x66, 0xE6, 0x55]
      - uart.write:
          id: uart_mainboard
          data: [0xAA, 0xAA, 0xAA, 0x90, 0x06, 0x0A, 0x03, 0x02, 0x00, 0x02, 0x03, 0x02, 0x3C, 0x00, 0x96, 0x00, 0xCC, 0xF1, 0x67, 0x25, 0x55]
      - uart.write:
          id: uart_mainboard
          data: [0xAA, 0xAA, 0xAA, 0x91, 0x07, 0x01, 0x03, 0xA3, 0x2F, 0xE5, 0xA1, 0x55]


2 Likes

There are unresolved issues and I need help

  1. The coffee machine cannot be turned on remotely or via the command AA:AA:AA:FE:00:00:C8:87:1B:40:55, neither via transistor. I drew and tracked where the tracks lead from the coffee machine power button and rang them. The track from the power button goes to the resistor R220, then goes to the K73 chip, and then goes to the chip, the third leg. These are 100% correct tracks and they ring, but I don’t know where you can solder so that you can send a signal or GND or something else from ESP so that you can turn on the coffee machine.
Photos of the board and the rendered tracks




The fact that on the K73 board it turned out to be a small signal Schottky diode and the documentation for it itself

K73 BAS70TW 10PCS SOT-363 SCHOTTKY BARRIER DIODE ARRAYS CHIP IC


image


If you do a solder to the contacts as a similar person did here, will it turn on and off the coffee machine or not?

  1. The recipe can be run only once, then you need to restart the coffee machine. I can’t understand why this is happening. We turn on the coffee machine, do not run programs from the control panel, but run them from esphome. The process of making a coffee drink starts, and if you start it again, it no longer works. For this to work, you need to turn off and turn on the coffee machine. It seems that this happens because when sending a command to prepare a coffee drink, the counter is knocked off and the protection is turned on in the coffee machine and the commands are ignored further. How can I send a recipe in such a way that it can be sent many times without knocking down the coffee machine counter? for example, to send certain bytes, those that we know, and not all that we know and random bytes

I have been watching this thread quietly for a while now, and its awesome to see the reverse engineering involved.

i was playing with a device that interfaces with daiken heatpumps etc, and i see quite a few similarities

one thing i noticed in one of your tables above, bytes 16 thru 19 are likely CRC (the last 4 before the stop byte). im wondering if the checksum algorithm could be reversed using a tool like https://github.com/colinoflynn/crcbeagle
later if you want app control of levels or change settings you will need to calculate the correct CRC for the message. i found confirming things like this means you can tick off a load of bytes, just like finding the start and end bytes.

i learned so much by reading about the daiken protocol from here, Arnold has done a fantastic job documenting things.
https://github.com/Arnold-n/P1P2Serial/tree/main/LogicalFormat

one thing i would suggest is for any bytes you dont know convert them to decimal and send to HA so you can graph/trend. you may need to combine adjacent bytes, they may be 16bit for volumes or temperatures.

looking again through your information above, i think one you know the header and crc/stop bit there is no need to log them.

can you create a program that passes the data between the end of the header and before the crc?
also it would be wise to have a timestamp and a direction. and one message packet per line
something like
millis,send,program,byte1,byte2,byte3
millis,rec,program,byte1,byte2,byte3
millis,send,program,byte1,byte2,byte3

if you send and characters between the packets (after 55 and before AAAAAA) as
millis,send,error,bytes until next header

this makes it easy to cut and paste data into excel. i found filtering by columns allowed me to notice trends. for example filter by program and compare the bytes

you may gather more info about neighboring cells by increasing volumes above what the first byte allows, eg if you can set 260ml milk volume you may find byte 14 is 04 and byte 15 is 01.

I tried CRC Beagle and it doesn’t fit, it just doesn’t work correctly and reports some nonsense

I created a file philips5400.py and pointed out as an example from the author of the CRC Beagle project

This is an example from the author

I did this following the example of the author

from crcbeagle import crcbeagle

crcb = crcbeagle.CRCBeagle()

#Example 1 - CRC16 with non-standard xor output

crcb.search([[AA, AA, AA, 90, 08, 0A, 00, 02, 00, 02, 03, 00, 1E, 00, 00, 00, 98, 80, 81, 70, 55],
[AA,AA,AA,90,26,0A,00,01,00,02,03,00,28,00,00,00,C6,13,4C,6D,55],
[AA,AA,AA,90,06,0A,00,02,00,01,01,00,28,00,00,00,6D,4F,D0,30,55],
[AA,AA,AA,90,1A,0A,00,02,01,01,01,00,28,00,00,00,8E,EF,68,F5,55],
[AA,AA,AA,90,0A,0A,00,02,02,01,01,00,5A,00,00,00,86,6D,C9,B6,55],
[AA,AA,AA,90,0D,0A,00,02,02,02,03,00,46,00,00,00,B8,D7,BE,A4,55],
[AA,AA,AA,90,06,0A,00,01,00,02,03,00,37,00,00,00,F7,8F,07,7D,55]],
)

crcb = crcbeagle.CRCBeagle()

#Example 2 - linear checksum when you think it might be a CRC8

crcb.search([[0xAA, 0xAA, 0xAA, 0x90, 0x08, 0x0A, 0x00, 0x02, 0x00, 0x02, 0x03, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x98, 0x80, 0x81, 0x70, 0x55],
[0xAA, 0xAA, 0xAA, 0x90, 0x26, 0x0A, 0x00, 0x01, 0x00, 0x02, 0x03, 0x00, 0x28, 0x00, 0x00, 0x00, 0xC6, 0x13, 0x4C, 0x6D, 0x55],
[0xAA, 0xAA, 0xAA, 0x90, 0x06, 0x0A, 0x00, 0x02, 0x00, 0x01, 0x01, 0x00, 0x28, 0x00, 0x00, 0x00, 0x6D, 0x4F, 0xD0, 0x30, 0x55],
[0xAA, 0xAA, 0xAA, 0x90, 0x1A, 0x0A, 0x00, 0x02, 0x01, 0x01, 0x01, 0x00, 0x28, 0x00, 0x00, 0x00, 0x8E, 0xEF, 0x68, 0xF5, 0x55],
[0xAA, 0xAA, 0xAA, 0x90, 0x0A, 0x0A, 0x00, 0x02, 0x02, 0x01, 0x01, 0x00, 0x5A, 0x00, 0x00, 0x00, 0x86, 0x6D, 0xC9, 0xB6, 0x55],
[0xAA, 0xAA, 0xAA, 0x90, 0x0D, 0x0A, 0x00, 0x02, 0x02, 0x02, 0x03, 0x00, 0x46, 0x00, 0x00, 0x00, 0xB8, 0xD7, 0xBE, 0xA4, 0x55],
[0xAA, 0xAA, 0xAA, 0x90, 0x06, 0x0A, 0x00, 0x01, 0x00, 0x02, 0x03, 0x00, 0x37, 0x00, 0x00, 0x00, 0xF7, 0x8F, 0x07, 0x7D, 0x55]],

)

Launching philips5400.py and I get errors where Syntax Error is written: leading zeros in decimal integer literals are not allowed; use an 0o prefix for octal integers. What kind of nonsense is this?

also it would be wise to have a timestamp and a direction. and one message packet per line
something like
millis,send,program,byte1,byte2,byte3
millis,rec,program,byte1,byte2,byte3
millis,send,program,byte1,byte2,byte3

If you look at the data from the logic analyzer, there are no delays, but there is one long command AA AA AA 93 0D 01 01 D2 03 75 E8 55 AA AA AA 90 0E 0A 02 02 00 02 01 02 96 00 5A 00 24 2C F8 C4 55 AA AA AA 91 0F 01 03 1B 7E F6 AF 55. You can take the files from the logic analyzer here and see what the bytes for recipes look like personally



I send this command in such a way that we get one long command at the output. If you send with delays, even with 1 ms, then the command to run recipes will not work.

button:
  - platform: template
    name: "Coffee with milk Max 120/120ml" 
    on_press:
      - uart.write:
          id: uart_mainboard
          data: [0xAA, 0xAA, 0xAA, 0x93, 0x0D, 0x01, 0x01, 0xD2, 0x03, 0x75, 0xE8, 0x55]
      - uart.write:
          id: uart_mainboard
          data: [0xAA, 0xAA, 0xAA, 0x90, 0x0E, 0x0A, 0x02, 0x02, 0x00, 0x02, 0x01, 0x02, 0x96, 0x00, 0x5A, 0x00, 0x24, 0x2C, 0xF8, 0xC4, 0x55]
      - uart.write:
          id: uart_mainboard
          data: [0xAA, 0xAA, 0xAA, 0x91, 0x0F, 0x01, 0x03, 0x1B, 0x7E, 0xF6, 0xAF, 0x55]

I would like to try to send those bytes that have logical values, and do not send the rest that change, i.e. indicate somehow that we are sending such and such a byte, but esphome does not allow this, reports an error. I do not know how this can be done

button:
  - platform: template
    name: "Coffee with milk Max 120/120ml" 
    on_press:
      - uart.write:
          id: uart_mainboard
          data: [bytes[0]==0xAA && bytes[3]==0x93]
      - uart.write:
          id: uart_mainboard
          data: [bytes[0]==0xAA && bytes[3]==0x90 && bytes[5]==0x01 && bytes[6]==0x02 && bytes[10]==0x01 && bytes[11]==0x02 && bytes[12]==0x5A && bytes[14]==0x5A]
      - uart.write:
          id: uart_mainboard
          data: [bytes[0]==0xAA && bytes[3]==0x91]

ERROR Error while reading config: Invalid YAML syntax:

while parsing a flow sequence
in “/config/esphome/coffee-philips-5400.yaml”, line 413, column 17:
data: [bytes[0]==0xAA && bytes[3]==0x93]
^
expected ‘,’ or ‘]’, but got ‘[’
in “/config/esphome/coffee-philips-5400.yaml”, line 413, column 23:
data: [bytes[0]==0xAA && bytes[3]==0x93]

I’m not in front of my computer, it’s a little hard to see on my phone, I think with the crc you need to remove the header and the crc and stop bit. You pass 2 arrays,

Crcb.search ( [[data1],[data2],[data3]],[[crc1],[crc2],[crc3]])

chris.huitema

The author does not have 0 in bytes at all, and I often have 0 in bytes, so his project is not suitable. You can try it yourself when you have time




If you look closely, I see in its bytes addresses 165 16 2 7 it’s like AA AA AA 93.

the warnings are the leading 0 in a decimal, so 0 is OK, but 00 is not.
the second error is because there is no 0x in front of the byte indicating that its a hex number, hence why it throws an error when it gets a letter
I dont have a computer i can test this on till the weekend, travelling light… see if this fixes the errors, then we can play with the bytes its checking

from crcbeagle import crcbeagle

crcb = crcbeagle.CRCBeagle()
crcb.search([[0x90, 0x08, 0x0A, 0x00, 0x02, 0x00, 0x02, 0x03, 0x00, 0x1E, 0x00, 0x00, 0x00],
[0x90, 0x26, 0x0A, 0x00, 0x01, 0x00, 0x02, 0x03, 0x00, 0x28, 0x00, 0x00, 0x00],
[0x90, 0x06, 0x0A, 0x00, 0x02, 0x00, 0x01, 0x01, 0x00, 0x28, 0x00, 0x00, 0x00],
[0x90, 0x1A, 0x0A, 0x00, 0x02, 0x01, 0x01, 0x01, 0x00, 0x28, 0x00, 0x00, 0x00],
[0x90, 0x0A, 0x0A, 0x00, 0x02, 0x02, 0x01, 0x01, 0x00, 0x5A, 0x00, 0x00, 0x00],
[0x90, 0x0D, 0x0A, 0x00, 0x02, 0x02, 0x02, 0x03, 0x00, 0x46, 0x00, 0x00, 0x00],
[0x90, 0x06, 0x0A, 0x00, 0x01, 0x00, 0x02, 0x03, 0x00, 0x37, 0x00, 0x00, 0x00]],
[[0x98, 0x80, 0x81, 0x70],
[0xC6, 0x13, 0x4C, 0x6D],
[0x6D, 0x4F, 0xD0, 0x30],
[0x8E, 0xEF, 0x68, 0xF5],
[0x86, 0x6D, 0xC9, 0xB6],
[0xB8, 0xD7, 0xBE, 0xA4],
[0xF7, 0x8F, 0x07, 0x7D]]
)

Actually i found an online tool
https://crc-reveng.septs.app

i threw in a few to check initially, then added a few more and then the power on command for good measure, this was the result eack time

so this confirms the CRC is the last 4 bytes before the stop bit

width=32 poly=0x04c11db7 init=0xffffffff refin=true refout=true xorout=0xffffffff check=0xcbf43926 residue=0xdebb20e3 name="CRC-32/ISO-HDLC"

a quick check to generate a checksum

it would be wise to validate the checksum for each message you read, to make sure its not corrupt. this may be too much for the processor… i dont know.

the positive of this is you now know what the bytes are. and if you want to change a parameter you know how to calculate the CRC for the message…

1 Like

@DivanX10 can you put some hex dumps for both the motherboard and display in the drive the other data is in for me to analyze. looks like the ones you put up are just for the display to the motherboard. I cant install software on the PC i have access to…

i can see from the ones i looked at there is a counter that increments, there is also some data corruption as some checksums dont match, not many but more than one in the file i looked at.

i notice one of your tables above with drinks counter, but t believe that’s the checksum.

but to really see what’s happening i need to look at both sides of the conversation… every command from the display will likely have a response from the motherboard, but it could be that the motherboard polls the display, if the display wants something it will respond only when its polled.

ideally if you could get the data from power on all the way to making a coffee. i think there would be some status info coming from the motherboard to the display

edit: i just found some of your replies on github, and the service manual you linked. i would start by putting the unit in service mode and manually test the functions, this way you can decode large amounts of the data quickly and in an isolated manner. i found it best to record a video of each thing i did while logging the data. if i stated the video at the same time as the logging i could correlate the info.
now you know the start AAAAAA and stop 55 and last 4 bytes before the stop you should be able to group the packets and analyse quickly.

also can you connect the wakeup to a pin on the ESP, and add a gpio binary sensor. i think there may be a state change on this for a millisecond when you power on. i dont think it will work with pull ups as there is already micro controllers on the line. i think the display pulls it low normally and it goes high to power on. that’s why when you disconnect the line it turns on (pullup on the mainboard)

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO13
      mode:
        input: true
    name: wakeup