Declaring the issue
About a year ago I joined the ‘standing desk’ community by investing in a IKEA IDÅSEN desk powered by a Linak BLE adapter. A part of me wanted to reverse all the strain bolted onto my back from sitting through at least 8 hours a day.
The desk controls are minimal, but it bothered me from the start that I had to hold the button until the desk reached the desired height. The desire of a fully automated desk was not fulfilled.
How will I approach it?
Well, the desk controller uses Low Energy Bluetooth (BLE), which is a handy protocol which in itself defines services needed to operate the underlying functionalities. But this was not needed. The wheel was already built and we are certainly not going to reinvent it.
We need a few things…
The steps
- First we need to find out the MAC address of our desk controller. We’ll use the BLE Scanner Android app to find out the address.
- Add a HA support for IKEA Linak (Idasen) by following the installation in the GitHub repository.
- Install the HACS Lovelace plugin called LinakDesk Card
- Add a new ESPHome device configuration and add this to the end of the yaml file
ESPHome configurationyaml
esphome:name: ikea-deskesp32:board: esp32devframework:type: arduinologger:api:encryption:key: "your_api_key"ota:password: "your_ota_password"wifi:ssid: !secret wifi_ssidpassword: !secret wifi_password# Optional static IPmanual_ip:static_ip: x.x.x.xgateway: x.x.x.xsubnet: 255.255.255.0ap:ssid: "Ikea-Desk Fallback Hotspot"password: "your fallback hotspot password"captive_portal:external_components:- source: github://j5lien/esphome-idasen-desk-controller@v3.0.0globals:- id: ble_client_connectedtype: boolinitial_value: "false"esp32_ble_tracker:ble_client:# Replace with the desk bluetooth mac address- mac_address: "11:22:33:44:55:66"id: idasen_deskon_connect:then:- lambda: |-id(ble_client_connected) = true;- delay: 5s- lambda: |-id(desk_height).update();id(desk_speed).update();on_disconnect:then:- lambda: |-id(ble_client_connected) = false;idasen_desk_controller:ble_client_id: idasen_deskonly_up_down_command: falsecover:- platform: idasen_desk_controllername: "Desk"sensor:# Desk Height Sensor- platform: ble_clienttype: characteristicble_client_id: idasen_deskid: desk_heightname: "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: 1update_interval: nevernotify: truelambda: |-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_clienttype: characteristicble_client_id: idasen_deskid: desk_speedname: "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 correctaccuracy_decimals: 0update_interval: nevernotify: truelambda: |-uint16_t raw_speed = ((uint16_t)x[3] << 8) | x[2];return raw_speed / 100;binary_sensor:# Desk Bluetooth Connection Status- platform: templatename: "Desk Connection"id: desk_connectionlambda: "return id(ble_client_connected);"# Desk Moving Status- platform: templatename: "Desk Moving"id: desk_movinglambda: "return id(desk_speed).state > 0;"
- That’s it. Our card is now available in the Lovelace GUI. We need to add the card and paste the raw yaml configuration provided below. Be sure to change the desk heights to your needs.
Lovelace card configurationyaml
type: "custom:linak-desk-card"desk: cover.deskheight_sensor: sensor.desk_heightmoving_sensor: binary_sensor.desk_movingconnection_sensor: binary_sensor.desk_connectionmin_height: 60max_height: 126presets:- label: Staytarget: 120- label: Sittarget: 76
An output is needed
The IKEA IDÅSEN (Linak) desk is now a bit smarter. You no longer have to hold the height buttons. Just press a button and let the smart home system do its magic.
Of course, if you integrate it with Google Home, you can control it by voice. The Google home system will see it as window blinds.