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;'