How to setup ESPHome to control my Bluetooth controlled (Octocontrol) bed

Thanks for sharing, very nice.
With cover setup I mean using an entity of the ‘cover’ type to be able to for example halfway ‘open’, your method does.certainly also work

Ah ok. That would is a nice idea. Thanks!

Hi Guys,
I’ve tried to edit the code listed above to accommodate our 2 beds.
Controlling the lights and reading the status is working fine.
But when i try to control the movement my logs overflow with lines and no movement.
I did use the BT debug mode on my Android phone, and the app uses the same commands as in your scripts.

Could you help me fix the script?

Kind regards!

Logs overflow with lines??? You know the logs are real useful, right?.. They tell you what the problem/s are and if its in your config it even tells you what the line numbers are that have problems.

Maybe posting the logs is something you can do? Or if you’d like, we can all take turns giving you guesses and wasting a bunch of time!

Speaking of your script or your multiple scripts, that is probably the problem or part of the problem.

You got one to many script: there

script:
  - id: control_bed_1
    mode: restart #Makes sure only 1 execution in parallel and running is cancelled # IMPROVEIMPROVEIMPROVE SENT THE COMMAND VALUE AS PARAMETER! check wat het verwachte type is en wat ik voor type als parameter mee kan sturen
    parameters:
      section: int #1 head, 2 feet, 3 both
      direction: int # 1 up, 0 down
      #percentage? voor later
    then:
      - ble_client.ble_write: #send stop command
script:
  - id: control_bed_2
    mode: restart #Makes sure only 1 execution in parallel and running is cancelled # IMPROVEIMPROVEIMPROVE SENT THE COMMAND VALUE AS PARAMETER! check wat het verwachte type is en wat ik voor type als parameter mee kan sturen
    parameters:
      section: int #1 head, 2 feet, 3 both
      direction: int # 1 up, 0 down
      #percentage? voor later
    then:
      - ble_client.ble_write: #send stop command
          id: rc2bed2
          service_uuid: ffe0
          characteristic_uuid: ffe1
          # List of bytes to write.
          value: [0x40, 0x02, 0x73, 0x00, 0x00, 0x0b, 0x40]

Also, these lambdas with switch/case. You’re repeating the same condition check for all of them in both lambdas “if (direction == 1)” That’s a problem… I assume it’s supposed to be 1, 2, 3?

script:
  - id: control_bed_2
    mode: restart #Makes sure only 1 execution in parallel and running is cancelled # IMPROVEIMPROVEIMPROVE SENT THE COMMAND VALUE AS PARAMETER! check wat het verwachte type is en wat ik voor type als parameter mee kan sturen
    parameters:
      section: int #1 head, 2 feet, 3 both
      direction: int # 1 up, 0 down
      #percentage? voor later
    then:
      - ble_client.ble_write: #send stop command
          id: rc2bed2
          service_uuid: ffe0
          characteristic_uuid: ffe1
          # List of bytes to write.
          value: [0x40, 0x02, 0x73, 0x00, 0x00, 0x0b, 0x40]
      # Check what task to perform
      - lambda: |-
          switch (section) {
            case 1: if (direction == 1) { 
              id(control_bed_head_up).execute();
              return;
            } else {
              id(control_bed_head_down).execute();
              return;
            };
            case 2: if (direction == 1){ 
              id(control_bed_feet_up).execute();
              return;
            } else {
              id(control_bed_feet_down).execute();
              return;
            };
            case 3: if (direction == 1){ 
              id(control_bed_both_up).execute();
              return;
            } else {
              id(control_bed_both_down).execute();
              return;
            };
            default: {      
              id(control_bed_stop_cmd).execute();
              return;
            }
          }
script:
  - id: control_bed_1
    mode: restart #Makes sure only 1 execution in parallel and running is cancelled # IMPROVEIMPROVEIMPROVE SENT THE COMMAND VALUE AS PARAMETER! check wat het verwachte type is en wat ik voor type als parameter mee kan sturen
    parameters:
      section: int #1 head, 2 feet, 3 both
      direction: int # 1 up, 0 down
      #percentage? voor later
    then:
      - ble_client.ble_write: #send stop command
          id: rc2bed1
          service_uuid: ffe0
          characteristic_uuid: ffe1
          # List of bytes to write.
          value: [0x40, 0x02, 0x73, 0x00, 0x00, 0x0b, 0x40]
      # Check what task to perform
      - lambda: |-
          switch (section) {
            case 1: if (direction == 1) { 
              id(control_bed_head_up).execute();
              return;
            } else {
              id(control_bed_head_down).execute();
              return;
            };
            case 2: if (direction == 1){ 
              id(control_bed_feet_up).execute();
              return;
            } else {
              id(control_bed_feet_down).execute();
              return;
            };
            case 3: if (direction == 1){ 
              id(control_bed_both_up).execute();
              return;
            } else {
              id(control_bed_both_down).execute();
              return;
            };
            default: {      
              id(control_bed_stop_cmd).execute();
              return;
            }
          }

You have to send and repeat a BLE service 100 times? Does it just move really slow or something?

 - repeat:
          count: 100
          then:
1 Like

Thanks for the reply, and sorry for not providing the logging and leaving you blindfolded…

I will try to make some changes and copy the logging if it doesn’t work.

As for the script section, do i remove the " script: " part and let bed1 & 2 be in the same script block? Or do i have to combine more lines?

And for the Lamdas im not sure, I did not invented this script, and do not have the knowledge to answer correctly. This will be something that the logging wil provide answers to.

Kind regards

Oh man! You’re asking quite a lot from me you know? I’m thinking that it’s only fair if I take the time to help you here, I should get to use the bed, kick my feet up and take a power nap at least.

I’ve removed the scripts: line and made the id’s in the script unique for both beds.
After uploading to the ESP32 and pressed head up in HomeAssistant i’ve got the following logs; (bed did not respond)

[12:19:54][D][button:010]: 'Bed1 head up' Pressed.
[12:19:54][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:19:54][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:19:55][D][main:383]: repeat head UP
[12:19:55][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:19:55][D][main:383]: repeat head UP
[12:19:55][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:19:55][D][main:383]: repeat head UP
[12:19:55][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:19:55][D][main:383]: repeat head UP
[12:19:55][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:19:56][D][main:383]: repeat head UP
[12:19:56][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:19:56][D][main:383]: repeat head UP
[12:19:56][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:19:56][D][main:383]: repeat head UP
[12:19:56][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:19:57][D][main:383]: repeat head UP
[12:19:57][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:19:57][D][main:383]: repeat head UP
[12:19:57][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:19:57][D][main:383]: repeat head UP
[12:19:57][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:19:58][D][main:383]: repeat head UP
[12:19:58][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:19:58][D][main:383]: repeat head UP
[12:19:58][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:19:58][D][main:383]: repeat head UP
[12:19:58][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:19:59][D][main:383]: repeat head UP
[12:19:59][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:19:59][D][main:383]: repeat head UP
[12:19:59][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:19:59][D][button:010]: 'Bed1 head up' Pressed.
[12:19:59][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:19:59][D][script:077]: Script 'control_bed_1_head_up' restarting (mode: restart)
[12:19:59][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:19:59][D][main:383]: repeat head UP
[12:19:59][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:19:59][D][main:383]: repeat head UP
[12:19:59][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:00][D][main:383]: repeat head UP
[12:20:00][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:00][D][main:383]: repeat head UP
[12:20:00][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:00][D][main:383]: repeat head UP
[12:20:00][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:01][D][main:383]: repeat head UP
[12:20:01][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:01][D][main:383]: repeat head UP
[12:20:01][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:01][D][main:383]: repeat head UP
[12:20:01][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:02][D][main:383]: repeat head UP
[12:20:02][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:02][D][main:383]: repeat head UP
[12:20:02][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:02][D][main:383]: repeat head UP
[12:20:02][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:02][D][main:383]: repeat head UP
[12:20:02][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:03][D][main:383]: repeat head UP
[12:20:03][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:03][D][main:383]: repeat head UP
[12:20:03][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:04][D][main:383]: repeat head UP
[12:20:04][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:04][D][main:383]: repeat head UP
[12:20:04][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:04][D][main:383]: repeat head UP
[12:20:04][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:04][D][main:383]: repeat head UP
[12:20:04][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:05][D][main:383]: repeat head UP
[12:20:05][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:05][D][main:383]: repeat head UP
[12:20:05][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:05][D][main:383]: repeat head UP
[12:20:05][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:06][D][main:383]: repeat head UP
[12:20:06][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:06][D][main:383]: repeat head UP
[12:20:06][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:06][D][main:383]: repeat head UP
[12:20:06][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:06][D][main:383]: repeat head UP
[12:20:06][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:07][D][main:383]: repeat head UP
[12:20:07][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:07][D][main:383]: repeat head UP
[12:20:07][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:07][D][main:383]: repeat head UP
[12:20:07][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:08][D][main:383]: repeat head UP
[12:20:08][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:08][D][main:383]: repeat head UP
[12:20:08][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:08][D][main:383]: repeat head UP
[12:20:08][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:09][D][main:383]: repeat head UP
[12:20:09][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:09][D][main:383]: repeat head UP
[12:20:09][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:09][D][main:383]: repeat head UP
[12:20:09][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:09][D][main:383]: repeat head UP
[12:20:09][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:10][D][main:383]: repeat head UP
[12:20:10][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:10][D][main:383]: repeat head UP
[12:20:10][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:10][D][main:383]: repeat head UP
[12:20:10][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:11][D][main:383]: repeat head UP
[12:20:11][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:11][D][main:383]: repeat head UP
[12:20:11][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:11][D][main:383]: repeat head UP
[12:20:11][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:12][D][main:383]: repeat head UP
[12:20:12][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:12][D][main:383]: repeat head UP
[12:20:12][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:12][D][main:383]: repeat head UP
[12:20:12][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:13][D][main:383]: repeat head UP
[12:20:13][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:13][D][main:383]: repeat head UP
[12:20:13][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:13][D][main:383]: repeat head UP
[12:20:13][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:13][D][main:383]: repeat head UP
[12:20:13][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:14][D][main:383]: repeat head UP
[12:20:14][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:14][D][main:383]: repeat head UP
[12:20:14][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:14][D][main:383]: repeat head UP
[12:20:14][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:15][D][main:383]: repeat head UP
[12:20:15][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:15][D][main:383]: repeat head UP
[12:20:15][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:15][D][main:383]: repeat head UP
[12:20:15][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:16][D][main:383]: repeat head UP
[12:20:16][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:16][D][main:383]: repeat head UP
[12:20:16][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:16][D][main:383]: repeat head UP
[12:20:16][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:17][D][main:383]: repeat head UP
[12:20:17][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:17][D][main:383]: repeat head UP
[12:20:17][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:17][D][main:383]: repeat head UP
[12:20:17][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:17][D][main:383]: repeat head UP
[12:20:17][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:18][D][main:383]: repeat head UP
[12:20:18][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:18][D][main:383]: repeat head UP
[12:20:18][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:18][D][main:383]: repeat head UP
[12:20:18][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:19][D][main:383]: repeat head UP
[12:20:19][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:19][D][main:383]: repeat head UP
[12:20:19][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:19][D][main:383]: repeat head UP
[12:20:19][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:20][D][main:383]: repeat head UP
[12:20:20][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:20][D][main:383]: repeat head UP
[12:20:20][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:20][D][main:383]: repeat head UP
[12:20:20][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:20][D][main:383]: repeat head UP
[12:20:21][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:21][D][main:383]: repeat head UP
[12:20:21][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:21][D][main:383]: repeat head UP
[12:20:21][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:22][D][main:383]: repeat head UP
[12:20:22][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:22][D][main:383]: repeat head UP
[12:20:22][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:22][D][main:383]: repeat head UP
[12:20:22][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:22][D][main:383]: repeat head UP
[12:20:22][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:23][D][main:383]: repeat head UP
[12:20:23][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:23][D][main:383]: repeat head UP
[12:20:23][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:23][D][main:383]: repeat head UP
[12:20:23][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:24][D][main:383]: repeat head UP
[12:20:24][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:24][D][main:383]: repeat head UP
[12:20:24][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:24][D][main:383]: repeat head UP
[12:20:24][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:24][D][main:383]: repeat head UP
[12:20:24][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:25][D][main:383]: repeat head UP
[12:20:25][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:25][D][main:383]: repeat head UP
[12:20:25][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:25][D][button:010]: 'Bed1 end move' Pressed.
[12:20:25][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:25][D][main:383]: repeat head UP
[12:20:25][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:26][D][main:383]: repeat head UP
[12:20:26][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:26][D][main:383]: repeat head UP
[12:20:26][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:26][D][main:383]: repeat head UP
[12:20:26][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:27][D][main:383]: repeat head UP
[12:20:27][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:27][D][main:383]: repeat head UP
[12:20:27][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:27][D][main:383]: repeat head UP
[12:20:27][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:28][D][main:383]: repeat head UP
[12:20:28][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:28][D][main:383]: repeat head UP
[12:20:28][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:28][D][main:383]: repeat head UP
[12:20:28][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:29][D][main:383]: repeat head UP
[12:20:29][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:29][D][main:383]: repeat head UP
[12:20:29][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:29][D][main:383]: repeat head UP
[12:20:29][D][ble_client.automation:026]: Write type: ESP_GATT_WRITE_TYPE_RSP
[12:20:29][D][main:383]: repeat head UP

And no problem for using the bed to watch a TV show. :smiley:
But when we kill the lights, the TV should turn off and the bed should go in a horizontal possition :wink: (thats the end goal, lights and tv is allready sorted out, the beds should be added when this script is working.)

Yes, it’s just like everything else, button, switch, sensor… you define 1 button component and then under that first “button:” you just put them in a row just like you did already.

button:
  - platform: template # **Button 1**
    name: "Bed1 head up"
    icon: "mdi:bed"
    on_press:
      # Calling a script with parameters
      - script.execute:
          id: control_bed_1 #rc2bed1?
          section: 1 #head
          direction: 1 #up
  - platform: template  # **Button 2**
    name: "Bed1 head down"
    icon: "mdi:bed"
    on_press:
      # Calling a script with parameters
      - script.execute:
          id: control_bed_1 #rc2bed1?
          section: 1 #head
          direction: 0 #down
  - platform: template  # **Button 3**
    name: "Bed1 head/feet up"
    icon: "mdi:bed"
    on_press:
      - ble_client.ble_write:
          id: rc2bed1
          service_uuid: ffe0
          characteristic_uuid: ffe1
          # List of bytes to write.
          value: [0x40, 0x02, 0x70, 0x00, 0x01, 0x07, 0x06, 0x40]
  - platform: template  # **Button 4**
    name: "Bed1 head/feet down"
    icon: "mdi:bed"
    on_press:

So, you have these Buttons and this one for example. When it’s pressed ( on_press:) it triggers a script to execute (- script.execute:) with this ID ( id: control_bed_1 #rc2bed1?) and these Parameters
section: 1 #head
direction: 1 #up

button:
  - platform: template
    name: "Bed1 head up"
    icon: "mdi:bed"
    on_press:
      # Calling a script with parameters
      - script.execute:
          id: control_bed_1 #rc2bed1?
          section: 1 #head
          direction: 1 #up

So, we go to that script that the button executes ( id: control_bed_1 #rc2bed1?)
Here’s the first part of it. It also has 2 Parameters and these are the same ones your button uses. When you push that button, the script is executed with those 2 Parameters (Section: 1, Direction: 1) which will also be the values that the script uses when it runs, 1 and 1.

script:
  - id: control_bed_1
    mode: restart #Makes sure only 1 execution in parallel and running is cancelled # IMPROVEIMPROVEIMPROVE SENT THE COMMAND VALUE AS PARAMETER! check wat het verwachte type is en wat ik voor type als parameter mee kan sturen
    parameters:
      section: int #1 head, 2 feet, 3 both
      direction: int # 1 up, 0 down
      #percentage? voor later
    then:

Then the script checks the lambda where you have 3 Cases(options) to “switch” between, hence the name, “Switch-Case” Here though, I’m not 100% sure if this syntax is correct though. In a nutshell what’s going on. It starts at case: 1 and checks to see if it is True or False. Does Parameter: direction = 1 ?

case 1: if (direction == 1) { 

You’re button assigned these numbers(integers/int)

- script.execute:
          id: control_bed_1 #rc2bed1?
          section: 1 #head
          direction: 1 #up

So, Case: 1 is True. direction == 1 and the command underneath it get’s triggered. “id(control_bed_head_up).execute();” If direction did not = 1 then the ‘else’ part underneath would be triggered and this script would start, id(control_bed_head_down).execute();

- lambda: |-
          switch (section) {
            case 1: if (direction == 1) { 
              id(control_bed_head_up).execute();
              return;
            } else {
              id(control_bed_head_down).execute();
              return;
            };
           

The problem is. the Case 1,2,3 you have are only checking the value(int), to see if direction = 1. "case 2: if (direction == 1), case 3: if (direction == 1). I assume they are supposed to be something like this. The problem though is you have a bunch of combinations that could be possible for Section and Direction and it just needs gone through and matched up so that if for example Direction == 1 and Section == 1 then,

switch (direction) {
            case 1: if (direction == 1) { 
              id(control_bed_head_up).execute();

AND

switch (section) {
            case 1: if (section == 0) { 
              id(control_bed_head_up).execute();
              return;

equals the bed operation you want to happen…

- lambda: |-
          switch (direction) {
            case 1: if (direction == 0) { 
              id(control_bed_head_up).execute();
              return;
            } else {
              id(control_bed_head_down).execute();
              return;
            };
            case 2: if (direction == 1){ 
              id(control_bed_feet_up).execute();
              return;
            } else {
              id(control_bed_feet_down).execute();
              return;
            };
            case 3: if (direction == 2){ 
              id(control_bed_both_up).execute();
              return;
            } else {
              id(control_bed_both_down).execute();
              return;
            };
            default: {      
              id(control_bed_stop_cmd).execute();
              return;
            }
          }

You have a second lambda that is supposed to be checking the second Parameter: section(int) and it’s checking Paremter: direction(int) just like the other one. I assume it’s supposed to be something like this.

- id: control_bed_2
    mode: restart #Makes sure only 1 execution in parallel and running is cancelled # IMPROVEIMPROVEIMPROVE SENT THE COMMAND VALUE AS PARAMETER! check wat het verwachte type is en wat ik voor type als parameter mee kan sturen
    parameters:
      section: int #1 head, 2 feet, 3 both
      direction: int # 1 up, 0 down
      #percentage? voor later
    then:
      - ble_client.ble_write: #send stop command
          id: rc2bed2
          service_uuid: ffe0
          characteristic_uuid: ffe1
          # List of bytes to write.
          value: [0x40, 0x02, 0x73, 0x00, 0x00, 0x0b, 0x40]
      # Check what task to perform
      - lambda: |-
          switch (section) {
            case 1: if (section == 0) { 
              id(control_bed_head_up).execute();
              return;
            } else {
              id(control_bed_head_down).execute();
              return;
            };
            case 2: if (section == 1){ 
              id(control_bed_feet_up).execute();
              return;
            } else {
              id(control_bed_feet_down).execute();
              return;
            };
            case 3: if (section == 2){ 
              id(control_bed_both_up).execute();
              return;
            } else {
              id(control_bed_both_down).execute();
              return;
            };
            default: {      
              id(control_bed_stop_cmd).execute();
              return;
            }
          }

You need to put the MAC addresses in there. X’s and Y’s won’t do the trick.

ble_client:
  - mac_address: xx:xx:xx:xx:xx:xx
    id: rc2bed1
    on_connect:
  - mac_address: yy:yy:yy:yy:yy:yy
    id: rc2bed2
    on_connect:
      then:

Have you made any progress or updates?

Will try to convert your tips in to the code now.
Update you shortly

The MAC addresses are altered just for posting here. :wink:

In theory i think i know what you mean by using a lambda for the section and another for the direction. But i copied the initial script from _pm @ oct 30 '23 and thought i only had to implement a second bed to it.
The solutions you are providing indicate that the script of _pm never worked in the first place, so that is a bit odd, yet possible.

The second lambda was introduced by copying the first bed, changing the IDs to bed2…

The repeat 100 was implemented to continue the motion, only a single press would move the bed just a few millimeters.

Whats the best approach here? Save the current code, start over with the initial code from _pm and try to make it work for 1 bed, and then incorporate the second bed?

After looking at the lambda’s, I think I was partially wrong. There is a lot going on in that config and takes some time to get your head wrapped around everything. Before getting deeper into the lambdas, I think it’s best if we get the board connecting first, then you can try the buttons and see how close or how far off they are from what is expected then go from there. Can you post the top part of the config that deals with Wifi, esp32 board type, api, etc. etc. Also, was there anymore in the logs that you didn’t copy?

Go ahead and leave the code as it is for now, except the second ‘script:’ go ahead and just remove that part, the rest is ok for now.

script:  **#  <-------- Only remove "script:"**
  - id: control_bed_2
    mode: restart #Makes sure only 1 execution in parallel and running is cancelled # IMPROVEIMPROVEIMPROVE SENT THE COMMAND VALUE AS PARAMETER! check wat het verwachte type is en wat ik voor type als parameter mee kan sturen
    parameters:

You are 100% sure that you have the correct MAC addresses in the config? You know a MAC address isn’t sensitive information, no one is going to hack your bank account and change your Netflix password from seeing the MAC address. BT devices are openly sending out their MAC and other service and manufacturer uuid’s to anyone or any device in the area and doing right now in the background as we speak. Hide your bank account number, not necessarily your MAC.

The connection to the beds are working, i can toggle the lights and see the connection status.

There where not any other log entries regarding the bed control.

Here is the complete code:

esphome:
  name: bt-gw1
  platform: ESP32
  board: pico32

wifi:
  ssid: "xxx"
  password: "xxx"
  manual_ip:
   static_ip: xxx
   gateway: xxx
   subnet: xxx

# Enable logging
logger:

# Enable Home Assistant API
api:
  reboot_timeout: 60min
  password: "xxx"

ota:
  password: "xxx"

# Sync time with HA
time:
    - platform: homeassistant
  
# Enable Bluetooth scanning for this ESP32
esp32_ble_tracker:

sensor:
    # General
    - platform: uptime
      name: "bt-gw1 - Uptime Sensor"

    - platform: wifi_signal
      name: "bt-gw1 - WiFi Signal"
      update_interval: 60s

binary_sensor:
  - platform: template
    name: "Bed HdV remote connection status"
    id: bed_hdv_remote_connection_status

  - platform: template
    name: "Bed LdV remote connection status"
    id: bed_ldv_remote_connection_status

ble_client:
  - mac_address: E2:29:0A:3F:0F:0C
    id: rc2bedhdv
    on_connect:
      then:
        - lambda: |-
            ESP_LOGD("ble_client_lambda", "Connected to BLE device");
        - binary_sensor.template.publish:
            id: bed_hdv_remote_connection_status
            state: True
    on_disconnect:
      then:
        - lambda: |-
            ESP_LOGD("ble_client_lambda", "Disconnected from BLE device");
        - binary_sensor.template.publish:
            id: bed_hdv_remote_connection_status
            state: False

  - mac_address: E8:9C:B2:04:26:BC
    id: rc2bedldv
    on_connect:
      then:
        - lambda: |-
            ESP_LOGD("ble_client_lambda", "Connected to BLE device");
        - binary_sensor.template.publish:
            id: bed_ldv_remote_connection_status
            state: True
    on_disconnect:
      then:
        - lambda: |-
            ESP_LOGD("ble_client_lambda", "Disconnected from BLE device");
        - binary_sensor.template.publish:
            id: bed_ldv_remote_connection_status
            state: False

switch:
  - platform: template
    name: "Bed verlichting HdV"
    id: bed_verlichting_hdv
    icon: "mdi:lightbulb-outline"
    optimistic: true
    turn_on_action:
      - ble_client.ble_write:
          id: rc2bedhdv
          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: rc2bedhdv
          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]

  - platform: template
    name: "Bed verlichting LdV"
    id: bed_verlichting_ldv
    icon: "mdi:lightbulb-outline"
    optimistic: true
    turn_on_action:
      - ble_client.ble_write:
          id: rc2bedldv
          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: rc2bedldv
          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]

button:
  - platform: template
    name: "Bed hdv head up"
    icon: "mdi:bed"
    on_press:
      # Calling a script with parameters
      - script.execute:
          id: control_bed_hdv #rc2bedhdv?
          section: 1 #head
          direction: 1 #up
  - platform: template
    name: "Bed hdv head down"
    icon: "mdi:bed"
    on_press:
      # Calling a script with parameters
      - script.execute:
          id: control_bed_hdv #rc2bedhdv?
          section: 1 #head
          direction: 0 #down
  - platform: template
    name: "Bed hdv head/feet up"
    icon: "mdi:bed"
    on_press:
      - ble_client.ble_write:
          id: rc2bedhdv
          service_uuid: ffe0
          characteristic_uuid: ffe1
          # List of bytes to write.
          value: [0x40, 0x02, 0x70, 0x00, 0x01, 0x07, 0x06, 0x40]
  - platform: template
    name: "Bed hdv head/feet down"
    icon: "mdi:bed"
    on_press:
      - ble_client.ble_write:
          id: rc2bedhdv
          service_uuid: ffe0
          characteristic_uuid: ffe1
          # List of bytes to write.
          value: [0x40, 0x02, 0x71, 0x00, 0x01, 0x06, 0x06, 0x40]
  - platform: template
    name: "Bed hdv feet up"
    icon: "mdi:bed"
    on_press:
      - ble_client.ble_write:
          id: rc2bedhdv
          service_uuid: ffe0
          characteristic_uuid: ffe1
          # List of bytes to write.
          value: [0x40, 0x02, 0x70, 0x00, 0x01, 0x09, 0x04, 0x40]
  - platform: template
    name: "Bed hdv feet down"
    icon: "mdi:bed"
    on_press:
      - ble_client.ble_write:
          id: rc2bedhdv
          service_uuid: ffe0
          characteristic_uuid: ffe1
          # List of bytes to write.
          value: [0x40, 0x02, 0x71, 0x00, 0x01, 0x08, 0x04, 0x40]
  - platform: template
    name: "Bed hdv end move"
    id: bed_hdv_end_move
    icon: "mdi:stop-circle-outline"
    on_press:
      - ble_client.ble_write:
          id: rc2bedhdv
          service_uuid: ffe0
          characteristic_uuid: ffe1
          # List of bytes to write.
          value: [0x40, 0x02, 0x73, 0x00, 0x00, 0x0b, 0x40]

  - platform: template
    name: "Bed ldv head up"
    icon: "mdi:bed"
    on_press:
      # Calling a script with parameters
      - script.execute:
          id: control_bed_ldv #rc2bedldv?
          section: 1 #head
          direction: 1 #up
  - platform: template
    name: "Bed ldv head down"
    icon: "mdi:bed"
    on_press:
      # Calling a script with parameters
      - script.execute:
          id: control_bed_ldv #rc2bedldv?
          section: 1 #head
          direction: 0 #down
  - platform: template
    name: "Bed ldv head/feet up"
    icon: "mdi:bed"
    on_press:
      - ble_client.ble_write:
          id: rc2bedldv
          service_uuid: ffe0
          characteristic_uuid: ffe1
          # List of bytes to write.
          value: [0x40, 0x02, 0x70, 0x00, 0x01, 0x07, 0x06, 0x40]
  - platform: template
    name: "Bed ldv head/feet down"
    icon: "mdi:bed"
    on_press:
      - ble_client.ble_write:
          id: rc2bedldv
          service_uuid: ffe0
          characteristic_uuid: ffe1
          # List of bytes to write.
          value: [0x40, 0x02, 0x71, 0x00, 0x01, 0x06, 0x06, 0x40]
  - platform: template
    name: "Bed ldv feet up"
    icon: "mdi:bed"
    on_press:
      - ble_client.ble_write:
          id: rc2bedldv
          service_uuid: ffe0
          characteristic_uuid: ffe1
          # List of bytes to write.
          value: [0x40, 0x02, 0x70, 0x00, 0x01, 0x09, 0x04, 0x40]
  - platform: template
    name: "Bed ldv feet down"
    icon: "mdi:bed"
    on_press:
      - ble_client.ble_write:
          id: rc2bedldv
          service_uuid: ffe0
          characteristic_uuid: ffe1
          # List of bytes to write.
          value: [0x40, 0x02, 0x71, 0x00, 0x01, 0x08, 0x04, 0x40]
  - platform: template
    name: "Bed ldv end move"
    id: bed_ldv_end_move
    icon: "mdi:stop-circle-outline"
    on_press:
      - ble_client.ble_write:
          id: rc2bedldv
          service_uuid: ffe0
          characteristic_uuid: ffe1
          # List of bytes to write.
          value: [0x40, 0x02, 0x73, 0x00, 0x00, 0x0b, 0x40]

script:
  - id: control_bed_hdv
    mode: restart #Makes sure only 1 execution in parallel and running is cancelled # IMPROVEIMPROVEIMPROVE SENT THE COMMAND VALUE AS PARAMETER! check wat het verwachte type is en wat ik voor type als parameter mee kan sturen
    parameters:
      section: int #1 head, 2 feet, 3 both
      direction: int # 1 up, 0 down
      #percentage? voor later
    then:
      - ble_client.ble_write: #send stop command
          id: rc2bedhdv
          service_uuid: ffe0
          characteristic_uuid: ffe1
          # List of bytes to write.
          value: [0x40, 0x02, 0x73, 0x00, 0x00, 0x0b, 0x40]
      # Check what task to perform
      - lambda: |-
          switch (section) {
            case 1: if (direction == 1) { 
              id(control_bed_hdv_head_up).execute();
              return;
            } else {
              id(control_bed_hdv_head_down).execute();
              return;
            };
            case 2: if (direction == 1){ 
              id(control_bed_hdv_feet_up).execute();
              return;
            } else {
              id(control_bed_hdv_feet_down).execute();
              return;
            };
            case 3: if (direction == 1){ 
              id(control_bed_hdv_both_up).execute();
              return;
            } else {
              id(control_bed_hdv_both_down).execute();
              return;
            };
            default: {      
              id(control_bed_hdv_stop_cmd).execute();
              return;
            }
          }
  - id: control_bed_hdv_head_up
    mode: restart #Makes sure only 1 execution in parallel and running is cancelled
    then:
      - repeat:
          count: 100
          then:
            - ble_client.ble_write:
                id: rc2bedhdv
                service_uuid: ffe0
                characteristic_uuid: ffe1
                # List of bytes to write.
                value: [0x40, 0x02, 0x70, 0x00, 0x01, 0x0b, 0x02, 0x40]
            - delay: 300ms
            - logger.log: "repeat head UP"
  - id: control_bed_hdv_head_down
    mode: restart #Makes sure only 1 execution in parallel and running is cancelled
    then:
      - repeat:
          count: 100
          then:
            - ble_client.ble_write:
                id: rc2bedhdv
                service_uuid: ffe0
                characteristic_uuid: ffe1
                # List of bytes to write.
                value: [0x40, 0x02, 0x71, 0x00, 0x01, 0x0a, 0x02, 0x40]
            - delay: 300ms
            - logger.log: "repeat head DOWN"
  - id: control_bed_hdv_feet_up
    mode: restart #Makes sure only 1 execution in parallel and running is cancelled
    then:
      - repeat:
          count: 100
          then:
            - ble_client.ble_write:
                id: rc2bedhdv
                service_uuid: ffe0
                characteristic_uuid: ffe1
                # List of bytes to write.
                value: [0x40, 0x02, 0x70, 0x00, 0x01, 0x09, 0x04, 0x40]
            - delay: 300ms
            - logger.log: "repeat feet up"
  - id: control_bed_hdv_feet_down
    mode: restart #Makes sure only 1 execution in parallel and running is cancelled
    then:
      - repeat:
          count: 100
          then:
            - ble_client.ble_write:
                id: rc2bedhdv
                service_uuid: ffe0
                characteristic_uuid: ffe1
                # List of bytes to write.
                value: [0x40, 0x02, 0x71, 0x00, 0x01, 0x08, 0x04, 0x40]
            - delay: 300ms
            - logger.log: "repeat feet down"
  - id: control_bed_hdv_both_up
    mode: restart #Makes sure only 1 execution in parallel and running is cancelled
    then:
      - repeat:
          count: 100
          then:
            - ble_client.ble_write:
                id: rc2bedhdv
                service_uuid: ffe0
                characteristic_uuid: ffe1
                # List of bytes to write.
                value: [0x40, 0x02, 0x70, 0x00, 0x01, 0x07, 0x06, 0x40]
            - delay: 300ms
            - logger.log: "repeat both up"
  - id: control_bed_hdv_both_down
    mode: restart #Makes sure only 1 execution in parallel and running is cancelled
    then:
      - repeat:
          count: 100
          then:
            - ble_client.ble_write:
                id: rc2bedhdv
                service_uuid: ffe0
                characteristic_uuid: ffe1
                # List of bytes to write.
                value: [0x40, 0x02, 0x71, 0x00, 0x01, 0x06, 0x06, 0x40]
            - delay: 300ms
            - logger.log: "repeat both down"
  - id: control_bed_hdv_stop_cmd
    mode: restart #Makes sure only 1 execution in parallel and running is cancelled
    then:
      - ble_client.ble_write:
          id: rc2bedhdv
          service_uuid: ffe0
          characteristic_uuid: ffe1
          # List of bytes to write.
          value: [0x40, 0x02, 0x73, 0x00, 0x00, 0x0b, 0x40]

  - id: control_bed_ldv
    mode: restart #Makes sure only 1 execution in parallel and running is cancelled # IMPROVEIMPROVEIMPROVE SENT THE COMMAND VALUE AS PARAMETER! check wat het verwachte type is en wat ik voor type als parameter mee kan sturen
    parameters:
      section: int #1 head, 2 feet, 3 both
      direction: int # 1 up, 0 down
      #percentage? voor later
    then:
      - ble_client.ble_write: #send stop command
          id: rc2bedldv
          service_uuid: ffe0
          characteristic_uuid: ffe1
          # List of bytes to write.
          value: [0x40, 0x02, 0x73, 0x00, 0x00, 0x0b, 0x40]
      # Check what task to perform
      - lambda: |-
          switch (section) {
            case 1: if (direction == 1) { 
              id(control_bed_ldv_head_up).execute();
              return;
            } else {
              id(control_bed_ldv_head_down).execute();
              return;
            };
            case 2: if (direction == 1){ 
              id(control_bed_ldv_feet_up).execute();
              return;
            } else {
              id(control_bed_ldv_feet_down).execute();
              return;
            };
            case 3: if (direction == 1){ 
              id(control_bed_ldv_both_up).execute();
              return;
            } else {
              id(control_bed_ldv_both_down).execute();
              return;
            };
            default: {      
              id(control_bed_ldv_stop_cmd).execute();
              return;
            }
          }
  - id: control_bed_ldv_head_up
    mode: restart #Makes sure only 1 execution in parallel and running is cancelled
    then:
      - repeat:
          count: 100
          then:
            - ble_client.ble_write:
                id: rc2bedldv
                service_uuid: ffe0
                characteristic_uuid: ffe1
                # List of bytes to write.
                value: [0x40, 0x02, 0x70, 0x00, 0x01, 0x0b, 0x02, 0x40]
            - delay: 300ms
            - logger.log: "repeat head UP"
  - id: control_bed_ldv_head_down
    mode: restart #Makes sure only 1 execution in parallel and running is cancelled
    then:
      - repeat:
          count: 100
          then:
            - ble_client.ble_write:
                id: rc2bedldv
                service_uuid: ffe0
                characteristic_uuid: ffe1
                # List of bytes to write.
                value: [0x40, 0x02, 0x71, 0x00, 0x01, 0x0a, 0x02, 0x40]
            - delay: 300ms
            - logger.log: "repeat head DOWN"
  - id: control_bed_ldv_feet_up
    mode: restart #Makes sure only 1 execution in parallel and running is cancelled
    then:
      - repeat:
          count: 100
          then:
            - ble_client.ble_write:
                id: rc2bedldv
                service_uuid: ffe0
                characteristic_uuid: ffe1
                # List of bytes to write.
                value: [0x40, 0x02, 0x70, 0x00, 0x01, 0x09, 0x04, 0x40]
            - delay: 300ms
            - logger.log: "repeat feet up"
  - id: control_bed_ldv_feet_down
    mode: restart #Makes sure only 1 execution in parallel and running is cancelled
    then:
      - repeat:
          count: 100
          then:
            - ble_client.ble_write:
                id: rc2bedldv
                service_uuid: ffe0
                characteristic_uuid: ffe1
                # List of bytes to write.
                value: [0x40, 0x02, 0x71, 0x00, 0x01, 0x08, 0x04, 0x40]
            - delay: 300ms
            - logger.log: "repeat feet down"
  - id: control_bed_ldv_both_up
    mode: restart #Makes sure only 1 execution in parallel and running is cancelled
    then:
      - repeat:
          count: 100
          then:
            - ble_client.ble_write:
                id: rc2bedldv
                service_uuid: ffe0
                characteristic_uuid: ffe1
                # List of bytes to write.
                value: [0x40, 0x02, 0x70, 0x00, 0x01, 0x07, 0x06, 0x40]
            - delay: 300ms
            - logger.log: "repeat both up"
  - id: control_bed_ldv_both_down
    mode: restart #Makes sure only 1 execution in parallel and running is cancelled
    then:
      - repeat:
          count: 100
          then:
            - ble_client.ble_write:
                id: rc2bedldv
                service_uuid: ffe0
                characteristic_uuid: ffe1
                # List of bytes to write.
                value: [0x40, 0x02, 0x71, 0x00, 0x01, 0x06, 0x06, 0x40]
            - delay: 300ms
            - logger.log: "repeat both down"
  - id: control_bed_ldv_stop_cmd
    mode: restart #Makes sure only 1 execution in parallel and running is cancelled
    then:
      - ble_client.ble_write:
          id: rc2bedldv
          service_uuid: ffe0
          characteristic_uuid: ffe1
          # List of bytes to write.
          value: [0x40, 0x02, 0x73, 0x00, 0x00, 0x0b, 0x40]

Oohh!! Payday!

ble_client:
  - mac_address: E2:29:0A:3F:0F:0C
    id: rc2bedhdv

LOL, I’m kidding.

So, this was unexpected and i didn’t realize you were using a pico32. Most likely it doesn’t matter but, if you’re using less common Dev boards, it’s arguably information that you should make known to people when they are helping with troubleshooting. Some boards have known “quirks” or broader issues in certain areas and the board is an important detail. This is the board you’re using, correct?

DARN! Did i forgot to remove the MAC addresses?? :dizzy_face:

Im using this board;
https://www.tinytronics.nl/nl/development-boards/microcontroller-boards/met-wi-fi/m5stack-atom-lite-esp32-development-board

I’m eating good tonight, no McDonalds 1$ menu now that i’ve got that MAC. lol.

So, Did you do “auto detect” and that’s the board it selected? or where did that board selection come from? I’ve used esp32 NodeMCU and D1 mini or esp8266 boards pretty much exclusively the last few years so i’m not super familiar with your board but, I’d think the board in your config should be one of these M5Stack boards and not a Pico32.

esphome:
  name: bt-gw1
  platform: ESP32
  board: pico32

I’m just trying to make sure you have the right board setup and eliminate that as a current or future problem.
Screenshot from 2024-03-06 14-51-31