I’m trying to use the new ble_client.ble_write
Action to control a Snooz white noise machine. There is a great custom component for the Snooz but my HA machine is not within Bluetooth range of my Snooz and one of my ESP32 devices can see the Snooz. Based on the UUID info in the custom component, I wrote the following ESPHOME configuration:
ble_client:
- mac_address: D0:CF:5E:33:07:C8
id: snooz
switch:
- platform: template
name: "Snooz"
turn_on_action:
- ble_client.ble_write:
id: snooz
service_uuid: 729f0608-496a-47fe-a124-3a62aaa3fbc0
characteristic_uuid: 90759319-1668-44da-9ef3-492d593bd1e5
value: [0x02, 0x01]
turn_off_action:
- ble_client.ble_write:
id: snooz
service_uuid: 729f0608-496a-47fe-a124-3a62aaa3fbc0
characteristic_uuid: 90759319-1668-44da-9ef3-492d593bd1e5
value: [0x02, 0x00]
esp32_ble_tracker:
However, when I click the switch in the HA frontend, I get the following error in the ESP log:
[09:43:20][D][switch:013]: 'Snoozy Boozy' Turning ON.
[09:43:20][W][ble_client.automation:015]: Cannot write to BLE characteristic - not connected
I know the ESP32 can see the Snooz because it lists these lines in the log when scanning for BLE devices:
[09:31:20][I][ble_client:171]: Service UUID: 0x1800
[09:31:20][I][ble_client:172]: start_handle: 0x1 end_handle: 0x6
[09:31:20][I][ble_client:384]: characteristic 0x2A00, handle 0x3, properties 0x2
[09:31:20][I][ble_client:384]: characteristic 0x2A01, handle 0x6, properties 0x2
[09:31:20][I][ble_client:171]: Service UUID: 0x180A
[09:31:20][I][ble_client:172]: start_handle: 0x7 end_handle: 0x16
[09:31:20][I][ble_client:384]: characteristic 0x2A29, handle 0x9, properties 0x2
[09:31:20][I][ble_client:384]: characteristic 0x2A24, handle 0xc, properties 0x2
[09:31:20][I][ble_client:384]: characteristic 0x2A25, handle 0xf, properties 0x2
[09:31:20][I][ble_client:384]: characteristic 0x2A27, handle 0x12, properties 0x2
[09:31:20][I][ble_client:384]: characteristic 0x2A26, handle 0x15, properties 0x2
[09:31:20][I][ble_client:171]: Service UUID: 729F0608-496A-47FE-A124-3A62AAA3FBC0
[09:31:20][I][ble_client:172]: start_handle: 0x17 end_handle: 0xffff
[09:31:20][I][ble_client:384]: characteristic 90759319-1668-44DA-9EF3-492D593BD1E5, handle 0x19, properties 0x8
[09:31:20][I][ble_client:384]: characteristic 80C37F00-CC16-11E4-8830-0800200C9A66, handle 0x1b, properties 0x12
[09:31:20][I][ble_client:384]: characteristic F0499B1B-33AB-4DF8-A6F2-2484A2AD1451, handle 0x1e, properties 0x12
[09:31:20][D][ble_client.automation:061]: Found characteristic 90759319-1668-44DA-9EF3-492D593BD1E5 on device d0:cf:5e:33:07:c8
[09:31:20][D][ble_client.automation:061]: Found characteristic 90759319-1668-44DA-9EF3-492D593BD1E5 on device d0:cf:5e:33:07:c8
Do I have the wrong values or UUIDs listed? Is there a connection step required before sending the ble_client.ble_write
Action? Controlling BT and BLE devices are difficult concepts to grasp, so I’m hoping someone can share their knowledge or experience.