I’m working on controlling my bed (Bluetooth Octocontrol, which is supplied with remotes and an App).
My primary goal was to control the under-bed light as also part of my setup.
I got that part working with an ESP32, ESPHome resulting in an on/off switch in Home Assistant (my first time analyzing bluetooth traffic ).
I used wireshark to analyze the bluetooth commands to control the bed (as send from the app on my Android phone). I got all commands logged and all are working.
My challenge… I also want to control bed movement and when I send the bed-head-up command it moves the bed-head up for a fraction of a second and then stops. In the wireshark logging I see a continuous (every +/-300ms) repeat of this command which results in a continuous move.
I wonder what the best approach to create similar behaviour in ESPHome would be and home somebody can help me. I looked into a first button to start movement (start while loop) and a second button to stop movement (stop the running while loop). Or possibly use the cover component (time based?).
What would be the best approach? And how could I set this up?
To also share my work so-far:
All controls (head / feet / head/feet combined / lamp) all use:
[Service UUID: 0xffe0]
[UUID: 0xffe1]
Specific commands:
Head up : 40 02 70 00 01 0b 02 40
Head down : 40 02 71 00 01 0a 02 40
Both up : 40 02 70 00 01 07 06 40
Both down : 40 02 71 00 01 06 06 40
Foot up : 40 02 70 00 01 09 04 40
Foot down : 40 02 71 00 01 08 04 40
When logging I see repeating the commands above, for as long as the button
is pressed. After that I see the following command: 40 02 73 00 00 0b 40
(which does stop movement I guess, even in shorter than 300ms period?)
Lamp control
ON 40 20 72 00 08 de 00 01 02 01 01 01 01 01 40
OFF: 40 20 72 00 08 df 00 01 02 01 01 01 01 00 40
And in addition my existing ESPHome control for the lamp
ble_client:
- mac_address: AA:11:AA:11:AA:11
id: rc2bed
on_connect:
then:
- lambda: |-
ESP_LOGD("ble_client_lambda", "Connected to BLE device");
on_disconnect:
then:
- lambda: |-
ESP_LOGD("ble_client_lambda", "Disconnected from BLE device");
switch:
- platform: template
name: "Bed verlichting"
id: bed_verlichting
icon: "mdi:lightbulb-outline"
optimistic: true
turn_on_action:
- ble_client.ble_write:
id: rc2bed
service_uuid: ffe0
characteristic_uuid: ffe1
# List of bytes to write.
value: [0x40, 0x20, 0x72, 0x00, 0x08, 0xde, 0x00, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x40]
turn_off_action:
- ble_client.ble_write:
id: rc2bed
service_uuid: ffe0
characteristic_uuid: ffe1
# List of bytes to write.
value: [0x40, 0x20, 0x72, 0x00, 0x08, 0xdf, 0x00, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x40]