Linak desk controller

hi can you controll two desks with one esp32? i see a way to modifying the ID for the other components except the idasen_desk_controller component

iā€™m afraid, a lot of users (including me) are facing issues with the ble_client in ESPHome connecting to idasenā€™s controller. it just connects, but does not pair. the desk keeps blinking even after connecting and then the esphome logs show it got disconnected and then cannot connect as the desk goes out of pairing mode. this situation stays the same irrespective of whether wifi is enabled or not.

using a nodemcu esp32s board (ai thinker).

@j5lien please help whenever you get back from vacation

UPDATE: finally got it work by using github://j5lien/[email protected]

1 Like

Excellent find. Just for completeness can you post your working config?

sure this is my full working config. bluetooth_callback does not work. if enabled, this component will go into an infinite loop when trying to move the desk to a set position because it is not receiving any BLE notifications from the desk about its height. so just set it to off and then the component will get height from the same service characteristic which is used to change the height.

esphome:
  name: idasencontroller
  platform: ESP32
  board: esp32cam

logger:

# Enable Home Assistant API
api:
  password: ""

ota:
  password: ""

wifi:
  ssid: "foobar"
  password: "barfoo"

external_components:
  - source: github://j5lien/[email protected]

idasen_desk_controller:
    # Desk controller bluetooth mac address
    # -----------
    # Required
    mac_address: "C2:6F:1C:B7:D0:F9"
    # Use bluetooth callback to update sensors and cover entities
    # Deactivate this option when data are not correctly updated when using the cover entity
    # -----------
    # Optionnal (default true)
    bluetooth_callback: false

cover:
  - platform: idasen_desk_controller
    name: "Desk"

sensor:
  - platform: idasen_desk_controller
    desk_height:
      # Height in cm
      name: "Desk Height"
      # Millimeter precision
      accuracy_decimals: 1

binary_sensor:
  # Desk bluetooth connection
  - platform: idasen_desk_controller
    name: "Desk Connection"
    type: CONNECTION
  # Desk moving status
  - platform: idasen_desk_controller
    name: "Desk Moving"
    type: MOVING
2 Likes

Thanks @j5lien for writing this integration. I did a few issues like other trying to get ESPHome to talk to the Linak controller but after a few hours (days). I was able to get the integration working perfectly with Home Assistant.

My Steps:

I know some people have had issues with different versions of ESP32, I purchased mine off Amazon (https://www.amazon.com.au/gp/product/B097DCN76N/) and seems to work perfectly.

I had lots of issues with paring the desk using ā€œesp32_ble_trackerā€ component. So, I switched to the older version which uses the BLE Arduino library. I found the mac address of the desk using an android application ā€œBLE Scannerā€ and paired the desk to the ESP32. Once the pairing process was complete and I could control the desk. I switched to the latest version that uses esp32_ble_tracker and the connection has been rock steady.

Code for paring:

esphome:
  name: sam-idasen
  platform: ESP32
  board: esp32dev
  libraries:
    - "ESP32 BLE Arduino"
# Enable logging
logger:

wifi:
  ssid: !secret IoT_ssid
  password: !secret IoT_password

  # Enable fallback hotspot (for captive portal) in case wifi connection fails
  ap:
    ssid: "ESPHome $friendly_name"
    password: !secret ap_password

api:
  password: !secret api_ota_Password

ota:
  password: !secret api_ota_Password
  

external_components:
  - source: github://j5lien/[email protected]

idasen_desk_controller:
  mac_address: "00:00:00:00:00:00"

sensor:
  - platform: idasen_desk_controller
    desk_height:
      name: "Desk Height"

binary_sensor:
  - platform: idasen_desk_controller
    name: "Desk Connection"
    type: CONNECTION
  - platform: idasen_desk_controller
    name: "Desk Moving"
    type: MOVING

cover:
  - platform: idasen_desk_controller
    name: "Desk"

Once paring is complete and the desk responds to ESP Home/Home Assistant, update the code to the latest version:

esphome:
  name: sam-idasen
  platform: ESP32
  board: esp32dev

substitutions:
  friendly_name: Sam Idasen Desk

# Enable logging
logger:

# Enable Home Assistant API
wifi:
  ssid: !secret IoT_ssid
  password: !secret IoT_password

  # Enable fallback hotspot (for captive portal) in case wifi connection fails
  ap:
    ssid: "ESPHome $friendly_name"
    password: !secret ap_password

api:
  password: !secret api_ota_Password

ota:
  password: !secret api_ota_Password
    
external_components:
  - source: github://j5lien/[email protected]

esp32_ble_tracker:

globals:
  # To store the Desk Connection Status
  - id: ble_client_connected
    type: bool
    initial_value: 'false'

ble_client:
  - mac_address: "00:00:00:00:00:00"
    id: idasen_desk
    on_connect:
      then:
        # Update the Desk Connection Status
        - lambda: |-
            id(ble_client_connected) = true;
        - delay: 5s
        # Update desk height and speed sensors after bluetooth is connected
        - lambda: |-
            id(desk_height).update();
            id(desk_speed).update();
    on_disconnect:
      then:
        # Update the Desk Connection Status
        - lambda: |-
            id(ble_client_connected) = false;

idasen_desk_controller:
  ble_client_id: idasen_desk
  only_up_down_command: false

cover:
  - platform: idasen_desk_controller
    name: "Sam Desk"

sensor:
  # Desk Height Sensor
  - platform: ble_client
    ble_client_id: idasen_desk
    id: desk_height
    name: 'Sam Desk Height'
    service_uuid: '99fa0020-338a-1024-8a49-009c0215f78a'
    characteristic_uuid: '99fa0021-338a-1024-8a49-009c0215f78a'
    icon: 'mdi:arrow-up-down'
    unit_of_measurement: 'cm'
    accuracy_decimals: 1
    update_interval: never
    notify: true
    filters:
    - offset: 0.33
    lambda: |-
      uint16_t raw_height = ((uint16_t)x[1] << 8) | x[0];
      unsigned short height_mm = raw_height / 10;

      return (float) height_mm / 10;

  # Desk Speed Sensor
  - platform: ble_client
    ble_client_id: idasen_desk
    id: desk_speed
    name: 'Sam Desk Speed'
    service_uuid: '99fa0020-338a-1024-8a49-009c0215f78a'
    characteristic_uuid: '99fa0021-338a-1024-8a49-009c0215f78a'
    icon: 'mdi:speedometer'
    unit_of_measurement: 'cm/min' # I'm not sure this unit is correct
    accuracy_decimals: 0
    update_interval: never
    notify: true
    lambda: |-
      uint16_t raw_speed = ((uint16_t)x[3] << 8) | x[2];
      return raw_speed / 100;

binary_sensor:
  # Desk Bluetooth Connection Status
  - platform: template
    name: 'Sam Desk Connection'
    id: desk_connection
    lambda: 'return id(ble_client_connected);'

  # Desk Moving Status
  - platform: template
    name: 'Sam Desk Moving'
    id: desk_moving
    lambda: 'return id(desk_speed).state > 0;'
2 Likes

Thanks so much to @j5lien for his library and esphome compatibility!
Finally! This work around made my project finally working!

I transformed this old 70s alarm clock, to my preset, controller idasen desk.

3 Likes

Thanks a bunch Sam. Your method worked for me as well! However, when I update ESPHome (Docker) to the latest version, my desk is in an infinite loop and I cannot control it anymore. However, when I stay at 2021.10.0 no problems at all, but I canā€™t see the desk height or desk speedā€¦ Are you having the same problems?

Hi Justin,

I am not having any issues with mine. Seems to work well and very responsive.

Regards,
Sam

Since my message to you, Iā€™ve downgraded to 2021.10.0 and upgraded back again to the latest tag. Everythingā€™s running buttery smooth now, I can see the heights and I even mapped a W2049 Ikea controller to the desk via ControllerX. This feels so next level instead of relying on an app (oh the irony with HA) or the desk controller itself.

1 Like

When i try loading it i get error [15:06:17][W][idasen_desk_controller:104]: Error reading char at handle 26, status=5 and i dont know why, it seems to be an authentication error

i tried using 1.2.0 but i get the error ā€œidasen_desk_controller is not a correct platformā€ and ā€œThis component requred ble clientā€

In case anyone is looking for a solution NOT using an ESP32 device, but rather a good old bluetooth dongle, Iā€™ve built this https://github.com/maxime1992/linak-2-mqtt which let me integrate with HA and the linak desk card. All the info should be written in the README

2 Likes

I have tried the below configurations and the desk has stopped moving up (only down).

esphome:
  name: idasen

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Idasen Fallback Hotspot"
    password: "ym47kfFy6eEl"

external_components:
  - source: github://j5lien/[email protected]

esp32_ble_tracker:

ble_client:
  - mac_address: "D9:B7:84:82:99:0F"
    id: idasen_desk

idasen_desk_controller:
  ble_client_id: idasen_desk
  only_up_down_command: false

cover:
  - platform: idasen_desk_controller
    name: "Desk"

Full logs are published here https://github.com/j5lien/esphome-idasen-desk-controller/issues/43

Appreciate your help!

@j5lien @sumur1au any idea?

sorted by going all the way down

1 Like

i tried setting this up and got the error Error reading char at handle 26, status=5
Can you please help? Error reading char at handle 26, status=5 Ā· Issue #42 Ā· j5lien/esphome-idasen-desk-controller Ā· GitHub

probably your desk is stuck and need to be reset.
Unplug, wait some seconds, plug again and set all down, than all up.

More info here: My Standing Desk Only Goes Down: How-To Reset Your Desk - YouTube

Iā€™m having a problem with my Linak tv lift (which is basically a desk) I followed the installation but I canā€™t get the lift to move. In the log i see [10:33:58][D][idasen_desk_controller:217]: Update Desk - Move from 100 to 0
a lot, but it just doesnā€™t move! Can anybody here help me?
The full log is: INFO Reading configuration /config/esphome/tv-lift.yaml...INFO Starting log ou - Pastebin.com

Can these integration be updated using new Bluetooth integration since 2022.8?

2 Likes