forked from iMicknl/LoctekMotion_IoT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflexispot_ek5.yaml
162 lines (138 loc) · 3.61 KB
/
flexispot_ek5.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
substitutions:
device_name: Flexispot EK5
name: flexispot_ek5
min_height: "73.6" # Min height + 0.1
max_height: "122.9" # Max height - 0.1
esphome:
name: ${name}
comment: ${device_name}
platform: ESP8266 # TODO Change to your platform
board: nodemcuv2 # TODO Change to your board
includes:
- desk_height_sensor.h
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "${device_name} Fallback Hotspot"
password: !secret ap_fallback_password
captive_portal:
# Enable logging
logger:
#level: DEBUG
baud_rate: 0
# Enable Home Assistant API
api:
password: !secret ha_api_password
ota:
password: !secret ha_api_password
uart:
id: desk_uart
baud_rate: 9600
tx_pin: D5
rx_pin: D6
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"
switch:
- platform: gpio
name: "Virtual Screen"
pin:
number: D2
mode: OUTPUT
restore_mode: ALWAYS_OFF
internal: true
- platform: uart
name: "Preset 1"
id: switch_preset1
icon: mdi:numeric-1-box
data: [0x9b, 0x06, 0x02, 0x04, 0x00, 0xac, 0xa3, 0x9d]
uart_id: desk_uart
- platform: uart
name: "Preset 2"
id: switch_preset2
icon: mdi:numeric-2-box
data: [0x9b, 0x06, 0x02, 0x08, 0x00, 0xac, 0xa6, 0x9d]
uart_id: desk_uart
- platform: uart
name: "Sit" # Preset 3 on some control panels
id: switch_sit
icon: mdi:chair-rolling
data: [0x9b, 0x06, 0x02, 0x00, 0x01, 0xac, 0x60, 0x9d]
uart_id: desk_uart
- platform: uart
name: "Stand" # Not available for all control panels
id: switch_stand
icon: mdi:human-handsup
data: [0x9b, 0x06, 0x02, 0x10, 0x00, 0xac, 0xac, 0x9d]
uart_id: desk_uart
- platform: uart
name: "Up"
id: switch_up
icon: mdi:arrow-up-bold
data: [0x9b, 0x06, 0x02, 0x01, 0x00, 0xfc, 0xa0, 0x9d]
uart_id: desk_uart
internal: true
- platform: uart
name: "Down"
id: switch_down
icon: mdi:arrow-down-bold
data: [0x9b, 0x06, 0x02, 0x02, 0x00, 0x0c, 0xa0, 0x9d]
uart_id: desk_uart
internal: true
- platform: uart
name: "M"
id: switch_m
icon: mdi:alpha-m-circle
data: [0x9b, 0x06, 0x02, 0x20, 0x00, 0xac, 0xb8, 0x9d]
uart_id: desk_uart
- platform: uart
name: "(wake up)" # Not available on all control panels
id: switch_wake_up
icon: mdi:gesture-tap-button
data: [0x9b, 0x06, 0x02, 0x00, 0x00, 0x6c, 0xa1, 0x9d]
uart_id: desk_uart
cover:
- platform: template
# icon: mdi:table-chair
# icon: mdi-human-male-height-variant
name: "Desk"
assumed_state: true
# Move desk up
open_action:
- while:
condition:
sensor.in_range:
id: desk_height
below: ${max_height}
then:
- logger.log: "Executing up command"
- switch.turn_on: switch_up
- delay: 10ms
# Move desk down
close_action:
- while:
condition:
sensor.in_range:
id: desk_height
above: ${min_height}
then:
- logger.log: "Executing down command"
- switch.turn_on: switch_down
- delay: 10ms
optimistic: true