You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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: 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:
- button.press: button_m
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:
- 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:
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:
id: desk_uart
data: [0x9b, 0x06, 0x02, 0x04, 0x00, 0xac, 0xa3, 0x9d]
platform: template
name: "Preset 2"
icon: mdi:numeric-2-box
on_press:
id: desk_uart
data: [0x9b, 0x06, 0x02, 0x08, 0x00, 0xac, 0xa6, 0x9d]
platform: template
name: "Sit" # Preset 3 on some control panels
icon: mdi:chair-rolling
on_press:
id: desk_uart
data: [0x9b, 0x06, 0x02, 0x00, 0x01, 0xac, 0x60, 0x9d]
platform: template
name: "Stand"
icon: mdi:human-handsup
on_press:
id: desk_uart
data: [0x9b, 0x06, 0x02, 0x10, 0x00, 0xac, 0xac, 0x9d]
platform: template
name: "Memory"
id: button_m
icon: mdi:alpha-m-box
entity_category: "config"
on_press:
id: desk_uart
data: [0x9b, 0x06, 0x02, 0x20, 0x00, 0xac, 0xb8, 0x9d]
platform: template
name: "Wake Screen"
id: button_wake_screen
icon: mdi:gesture-tap-button
entity_category: "config"
on_press:
id: desk_uart
data: [0x9b, 0x06, 0x02, 0x00, 0x00, 0x6c, 0xa1, 0x9d]
platform: template
name: "Alarm"
id: button_alarm
icon: mdi:alarm
on_press:
id: desk_uart
data: [0x9b, 0x06, 0x02, 0x40, 0x00, 0xAC, 0x90, 0x9d]
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:
condition:
sensor.in_range:
id: desk_height
below: ${max_height}
then:
- logger.log: "Executing up command"
- cover.template.publish:
id: desk_cover
current_operation: OPENING
- uart.write:
id: desk_uart
data: [0x9b, 0x06, 0x02, 0x01, 0x00, 0xfc, 0xa0, 0x9d]
- delay: 108ms
Move desk down
close_action:
condition:
sensor.in_range:
id: desk_height
above: ${min_height}
then:
- logger.log: "Executing down command"
- cover.template.publish:
id: desk_cover
current_operation: CLOSING
- uart.write:
id: desk_uart
data: [0x9b, 0x06, 0x02, 0x02, 0x00, 0x0c, 0xa0, 0x9d]
- delay: 108ms
optimistic: true`
The text was updated successfully, but these errors were encountered: