-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delonghi Coffee Machine Example #22
Comments
Hello, it's doesn't work with latest versions of ESPHome, something was changed with ble_client text_sensor. Last working version of ESPHome was 2022.11.5. You can check if it's communicate with machine if in the log you see Update: After I back to 2022.11.5 it's start working, then I update again to 2023.2.2 it's keep working, so probably the problem was with machine itself and complete powering off/on helps.
|
Hello! Yes I can see the BT sign on the screen...let's try to downgrade and see |
Which model of Delonghi do you have? |
The Dinamica Plus |
This HACS plugin works same way, so probably something was changed in machine side :( |
Yes, I think so too, I was hoping it was something common to all models but I'm starting to think it's only on my model |
the very strange thing is that with this https://github.com/mmastrac/longshot the machine works...can't understand |
ok i think i understand the problem. The machine doesn't accept more than one command simultaneously so if I monitor the status I can't launch the command to make a coffee so I can't connect to the machine continuously but only when I start the command |
Hi, I noticed your example for the delonghi.
I compiled the code without problems adapting it to my machine and it seems to connect correctly. None of the switches seem to work though:
logs_cucina_logs.txt
Could it be a machine setting? Or did something change with a firmware update?
Does it work without problems for you?
and thus is my configuration:
`substitutions:
name: "cucina"
delonghi_mac: !secret delonghi_mac
delonghi_name_prefix: Coffee Machine
delonghi_id_prefix: coffee_machine
delonghi_service_uuid: 00035b03-58e6-07dd-021a-08123a000300
delonghi_characteristic_uuid: 00035b03-58e6-07dd-021a-08123a000301
delonghi_update_interval: '5000'
packages:
esphome.bluetooth-proxy: github://esphome/bluetooth-proxies/esp32-generic.yaml@main
globals:
type: uint32_t
restore_value: false
initial_value: '0'
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
esphome:
name: ${name}
name_add_mac_suffix: false
on_loop:
then:
- lambda: |-
if (!id(delonghi_millis)) {
id(binary_sensor_${delonghi_id_prefix}connected).publish_initial_state(false);
id(binary_sensor${delonghi_id_prefix}).publish_initial_state(false);
id(delonghi_millis) = millis();
}
static unsigned char CMD_HEALTH_CHECK[] = {0x0d, 0x05, 0x75, 0x0f, 0xda, 0x25};
if (id(binary_sensor_${delonghi_id_prefix}connected).state && (millis() - id(delonghi_millis) > ${delonghi_update_interval})) {
auto chr = id(ble_client${delonghi_id_prefix}).get_characteristic(
esp32_ble_tracker::ESPBTUUID::from_raw("${delonghi_service_uuid}"),
esp32_ble_tracker::ESPBTUUID::from_raw("${delonghi_characteristic_uuid}"));
if (chr) {
ESP_LOGD("${delonghi_id_prefix}", ">>> %s", format_hex_pretty(CMD_HEALTH_CHECK, sizeof(CMD_HEALTH_CHECK)).c_str());
chr->write_value(CMD_HEALTH_CHECK, sizeof(CMD_HEALTH_CHECK));
}
id(delonghi_millis) = millis();
}
esp32_ble_tracker:
mqtt:
topic_prefix: dinamica
discovery: false
broker: 192.168.1.2
port: 1883
username: michele
password: hd0806681
ble_client:
id: ble_client_${delonghi_id_prefix}
on_connect: [lambda: "id(binary_sensor_${delonghi_id_prefix}connected).publish_state(true);"]
on_disconnect: [lambda: "id(binary_sensor${delonghi_id_prefix}_connected).publish_state(false);"]
binary_sensor:
platform: template
id: binary_sensor_${delonghi_id_prefix}_connected
name: ${delonghi_name_prefix}
device_class: connectivity
entity_category: diagnostic
platform: template
id: binary_sensor_${delonghi_id_prefix}
internal: true
sensor:
id: sensor_${delonghi_id_prefix}_alarm
name: ${delonghi_name_prefix} Alarm
icon: mdi:alert
state_class: measurement
accuracy_decimals: 0
switch:
platform: ble_client
id: switch_${delonghi_id_prefix}enable
name: ${delonghi_name_prefix} Enable
ble_client_id: ble_client${delonghi_id_prefix}
disabled_by_default: true
entity_category: config
platform: template
id: switch_${delonghi_id_prefix}
name: ${delonghi_name_prefix}
icon: mdi:coffee
lambda: return id(binary_sensor_${delonghi_id_prefix}).state;
turn_on_action:
if (!id(binary_sensor_${delonghi_id_prefix}connected).state)
return;
static unsigned char CMD_POWER_ON[] = {0x0d, 0x07, 0x84, 0x0f, 0x02, 0x01, 0x55, 0x12};
auto chr = id(ble_client${delonghi_id_prefix}).get_characteristic(
esp32_ble_tracker::ESPBTUUID::from_raw("${delonghi_service_uuid}"),
esp32_ble_tracker::ESPBTUUID::from_raw("${delonghi_characteristic_uuid}"));
if (chr)
chr->write_value(CMD_POWER_ON, sizeof(CMD_POWER_ON));
button:
platform: template
id: button_${delonghi_id_prefix}americano
name: ${delonghi_name_prefix} Americano
icon: mdi:coffee-to-go-outline
on_press:
then:
- lambda: |-
if (!id(binary_sensor${delonghi_id_prefix}connected).state)
return;
static unsigned char CMD_AMERICANO_ON[] = {0x0d, 0x12, 0x83, 0xf0, 0x06, 0x01, 0x01, 0x00, 0x28, 0x02, 0x03, 0x0f, 0x00, 0x6e, 0x00, 0x00, 0x06, 0x47, 0x8b};
static unsigned char CMD_AMERICANO_OFF[] = {0x0d, 0x08, 0x83, 0xf0, 0x06, 0x02, 0x06, 0x18, 0x71};
auto chr = id(ble_client${delonghi_id_prefix}).get_characteristic(
esp32_ble_tracker::ESPBTUUID::from_raw("${delonghi_service_uuid}"),
esp32_ble_tracker::ESPBTUUID::from_raw("${delonghi_characteristic_uuid}"));
if (chr)
chr->write_value(CMD_AMERICANO_ON, sizeof(CMD_AMERICANO_ON));
platform: template
id: button_${delonghi_id_prefix}coffe
name: ${delonghi_name_prefix} Coffe
icon: mdi:coffee-to-go-outline
on_press:
then:
- lambda: |-
if (!id(binary_sensor${delonghi_id_prefix}connected).state)
return;
static unsigned char COFFE_ON[] = {0x0d, 0x0f, 0x83, 0xf0, 0x02, 0x01, 0x01, 0x00, 0x67, 0x02, 0x02, 0x00, 0x00, 0x06, 0x77, 0xff};
static unsigned char COFFE_OFF[] = {0x0d, 0x08, 0x83, 0xf0, 0x02, 0x02, 0x06, 0xc4, 0xb1};
auto chr = id(ble_client${delonghi_id_prefix}).get_characteristic(
esp32_ble_tracker::ESPBTUUID::from_raw("${delonghi_service_uuid}"),
esp32_ble_tracker::ESPBTUUID::from_raw("${delonghi_characteristic_uuid}"));
if (chr)
chr->write_value(COFFE_ON, sizeof(COFFE_ON));
platform: template
id: button_${delonghi_id_prefix}espresso
name: ${delonghi_name_prefix} Espresso
icon: mdi:coffee-to-go-outline
on_press:
then:
- lambda: |-
if (!id(binary_sensor${delonghi_id_prefix}connected).state)
return;
static unsigned char ESPRESSO_ON[] = {0x0d, 0x11, 0x83, 0xf0, 0x01, 0x01, 0x01, 0x00, 0x28, 0x02, 0x03, 0x08, 0x00, 0x00, 0x00, 0x06, 0x8f, 0xfc};
static unsigned char ESPRESSO_OFF[] = {0x0d, 0x08, 0x83, 0xf0, 0x01, 0x02, 0x06, 0x9d, 0xe1};
auto chr = id(ble_client${delonghi_id_prefix}).get_characteristic(
esp32_ble_tracker::ESPBTUUID::from_raw("${delonghi_service_uuid}"),
esp32_ble_tracker::ESPBTUUID::from_raw("${delonghi_characteristic_uuid}"));
if (chr)
chr->write_value(ESPRESSO_ON, sizeof(ESPRESSO_ON));
text_sensor:
platform: ble_client
id: text_sensor_${delonghi_id_prefix}
internal: true
ble_client_id: ble_client_${delonghi_id_prefix}
service_uuid: ${delonghi_service_uuid}
characteristic_uuid: ${delonghi_characteristic_uuid}
notify: true
update_interval: never
on_notify:
then:
lambda: |-
static unsigned char packet[19];
static uint8_t index = 0;
id(delonghi_millis) = millis();
ESP_LOGD("${delonghi_id_prefix}", "%s", format_hex_pretty((uint8_t *) x.c_str(), x.size()).c_str());
if (index + x.size() > sizeof(packet))
ESP_LOGE("${delonghi_id_prefix}", "Packet longer than (%d) bytes", sizeof(packet));
else {
memcpy(&packet[index], x.c_str(), x.size());
index += x.size();
if (index > 0 && packet[0] != 0xD0)
ESP_LOGE("${delonghi_id_prefix}", "Packet has wrong signature (0x%02X)", packet[0]);
else if (index >= 2 && index >= packet[1] + 1) {
ESP_LOGD("${delonghi_id_prefix}", "<<< %s", format_hex_pretty(packet, index).c_str());
uint16_t deviser = 0x1D0F, i3, i4, i5, crc = packet[index - 2] << 8 | packet[index - 1];
for (int i = 0; i < index - 2; i++) {
i3 = (((deviser << 8) | (deviser >> 8)) & 0x0000FFFF) ^ packet[i];
i4 = i3 ^ ((i3 & 0xFF) >> 4);
i5 = i4 ^ ((i4 << 12) & 0x0000FFFF);
deviser = i5 ^ (((i5 & 0xFF) << 5) & 0x0000FFFF);
}
if (deviser != crc)
ESP_LOGE("${delonghi_id_prefix}", "CRC error, expected (0x%04X) received (0x%04X)", deviser, crc);
else {
switch (packet[2]) {
case 0x75:
id(binary_sensor_${delonghi_id_prefix}).publish_state(packet[9] != 0);
id(sensor_${delonghi_id_prefix}_alarm).publish_state((int32_t) packet[7] +
(int32_t)(packet[8] << 8) + (int32_t)(packet[12] << 16) + (int32_t)(packet[13] << 24));
break;
default:
ESP_LOGW("${delonghi_id_prefix}", "Unknown packet type (0x%02X)", packet[2]);
}
}
}
else
return;
}
index = 0;`
The text was updated successfully, but these errors were encountered: