Learn how to connect your Flexispot (LoctekMotion) desk to the internet. This repository contains a collection of scripts to get your started, combined with research and instructions.
MIT License
625
stars
61
forks
source link
Working Setup for CB28M1B-1 (2 RJ45-ports) with HS13A-1 and ESP32dev #29
Disclaimer: I´m from germany and my englisch isn´t very good ... Sorry
Hello. With help from @iMicknl i was able to get my desk smart. Wanted to share my setup so that others may have an easy way to smart-up their desks :)
platform: custom
lambda: |-
auto desk_height_sensor = new DeskHeightSensor(id(desk_uart));
App.register_component(desk_height_sensor);
return {desk_height_sensor};
sensors:
id: "desk_height"
name: Desk Height
unit_of_measurement: cm
accuracy_decimals: 1
icon: "mdi:counter"
state_class: "measurement"
on_value:
then:
cover.template.publish:
id: desk_cover
position: !lambda |-
// The sensor outputs values from min_height (cm) to max_height (cm)
// We need to translate this to 0 - 1 scale.
float position = (float(x) - float(${min_height})) / (float(${max_height}) - float(${min_height}));
ESP_LOGD("main", "X is %f", x);
ESP_LOGD("main", "Current position is %f", position);
return position;
switch:
platform: template
id: "desk_cover"
icon: mdi:desk # or mdi:human-male-height-variant
name: "Desk"
device_class: blind # makes it easier to integrate with Google/Alexa
has_position: true
position_action:
Disclaimer: I´m from germany and my englisch isn´t very good ... Sorry
Hello. With help from @iMicknl i was able to get my desk smart. Wanted to share my setup so that others may have an easy way to smart-up their desks :)
Hardware
Wiring
ESPHome
`substitutions: device_name: Schreibtisch name: esp-schreibtisch min_height: "75.1" # Min height + 0.1 max_height: "109.1" # Max height - 0.1
esphome: name: ${name} comment: ${device_name} platform: esp32 board: esp32dev includes:
desk_height_sensor.h
project: name: "imicknl.loctekmotion_iot" version: "1.0.0"
Wake Desk by sending the "M" command
This will pull the current height after boot
on_boot: priority: -10 then:
wifi: ssid: !secret wifi_ssid password: !secret wifi_password
Enable fallback hotspot (captive portal) in case wifi connection fails
ap: ssid: "Esp-Schreibtisch" password: ""
captive_portal:
Enable logging
logger: level: DEBUG
level: VERBOSE # Makes uart stream available in esphome logstream
baud_rate: 0 # Disable logging over uart
Enable Home Assistant API
api:
ota: password: ""
uart: id: desk_uart baud_rate: 9600 tx_pin: GPIO17 rx_pin: GPIO16
sensor:
platform: wifi_signal name: "WiFi Signal" update_interval: 60s
platform: uptime name: Uptime
platform: custom lambda: |- auto desk_height_sensor = new DeskHeightSensor(id(desk_uart)); App.register_component(desk_height_sensor); return {desk_height_sensor}; sensors: id: "desk_height" name: Desk Height unit_of_measurement: cm accuracy_decimals: 1 icon: "mdi:counter" state_class: "measurement" on_value: then:
PIN20
platform: gpio name: "Virtual Screen" pin: number: GPIO23 mode: OUTPUT restore_mode: ALWAYS_ON entity_category: "config" internal: true
platform: uart name: "Up" id: switch_up2 icon: mdi:arrow-up-bold data: [0x9b, 0x06, 0x02, 0x01, 0x00, 0xfc, 0xa0, 0x9d] uart_id: desk_uart send_every: 108ms
platform: uart name: "Down" id: switch_down2 icon: mdi:arrow-down-bold data: [0x9b, 0x06, 0x02, 0x02, 0x00, 0x0c, 0xa0, 0x9d] uart_id: desk_uart send_every: 108ms
button:
platform: template name: "Preset 1" icon: mdi:numeric-1-box on_press:
platform: template name: "Preset 2" icon: mdi:numeric-2-box on_press:
platform: template name: "Sit" # Preset 3 on some control panels icon: mdi:chair-rolling on_press:
platform: template name: "Stand" icon: mdi:human-handsup on_press:
platform: template name: "Memory" id: button_m icon: mdi:alpha-m-box entity_category: "config" on_press:
platform: template name: "Wake Screen" id: button_wake_screen icon: mdi:gesture-tap-button entity_category: "config" on_press:
platform: template name: "Alarm" id: button_alarm icon: mdi:alarm on_press:
platform: restart name: "Restart" entity_category: "config"
cover:
platform: template id: "desk_cover" icon: mdi:desk # or mdi:human-male-height-variant name: "Desk" device_class: blind # makes it easier to integrate with Google/Alexa has_position: true position_action:
Move desk up
open_action:
Move desk down
close_action: