-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeskController.yaml
More file actions
172 lines (150 loc) · 4.09 KB
/
DeskController.yaml
File metadata and controls
172 lines (150 loc) · 4.09 KB
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
163
164
165
166
167
168
169
170
171
172
substitutions:
display_name: "Nextion Display Name" # Enter a descriptive display name
device_name: "Standing Desk Model" # Desk model or identifier
name: "standing_desk"
min_height: "XX.X" # Minimum desk height (cm), adjust to your desk
max_height: "XXX.X" # Maximum desk height (cm), adjust to your desk
esphome:
name: nextion_desk_controller
platform: ESP32
board: esp32dev
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
ssid: "Fallback Hotspot"
password: "fallback_password"
captive_portal:
api:
encryption:
key: "<insert_api_encryption_key_here>"
ota:
password: "<insert_ota_password_here>"
logger:
baud_rate: 0
external_components:
source: github://iMicknl/LoctekMotion_IoT@v2
components: [loctekmotion_desk_height]
uart:
- id: desk_uart
tx_pin: GPIO17
rx_pin: GPIO16
baud_rate: 9600
- id: nextion_uart
tx_pin: GPIO4
rx_pin: GPIO5
baud_rate: 9600
time:
- platform: sntp
id: sntp_time
sensor:
- platform: loctekmotion_desk_height
uart_id: desk_uart
id: desk_height
name: "Desk Height"
on_value_range:
- below: ${min_height}
then:
- switch.turn_off: switch_down
- above: ${max_height}
then:
- switch.turn_off: switch_up
on_value:
then:
- cover.template.publish:
id: desk_cover
position: !lambda |-
return (x - ${min_height}) / (${max_height} - ${min_height});
- component.update: set_desk_height
- lambda: |-
char buf[30];
sprintf(buf, "t0.txt=\"%.1f cm\"", x);
id(my_nextion).send_command(buf);
- platform: wifi_signal
name: "WiFi Signal"
update_interval: 60s
- platform: uptime
name: "Uptime"
switch:
# Desk movement commands
# Commands are specific to desk model; replace if different.
- platform: uart
id: switch_up
data: [0x9b, 0x06, 0x02, 0x01, 0x00, 0xfc, 0xa0, 0x9d]
uart_id: desk_uart
send_every: 108ms
internal: true
- platform: uart
id: switch_down
data: [0x9b, 0x06, 0x02, 0x02, 0x00, 0x0c, 0xa0, 0x9d]
uart_id: desk_uart
send_every: 108ms
internal: true
# Nextion display brightness control
- platform: template
name: "Nextion Display On"
turn_on_action:
- uart.write:
id: nextion_uart
data: ["0x64", "0x69", "0x6d", "0x3d", "0x31", "0x30", "0x30", "0xff", "0xff", "0xff"]
turn_off_action:
- logger.log: "Display On switch does not support off."
- platform: template
name: "Nextion Display Off"
turn_on_action:
- uart.write:
id: nextion_uart
data: ["0x64", "0x69", "0x6d", "0x3d", "0x30", "0xff", "0xff", "0xff"]
turn_off_action:
- logger.log: "Display Off switch does not support on."
binary_sensor:
# Nextion touchscreen buttons (replace component IDs/pages as needed)
- platform: nextion
page_id: 1
component_id: 1
filters:
- delayed_off: 100ms
on_press:
then:
- homeassistant.service:
service: light.toggle
data:
entity_id: "light.your_entity_here"
cover:
- platform: template
id: desk_cover
name: "Desk Height Control"
device_class: blind
has_position: true
optimistic: false
open_action:
- switch.turn_on: switch_up
close_action:
- switch.turn_on: switch_down
stop_action:
- switch.turn_off: switch_up
- switch.turn_off: switch_down
number:
- platform: template
name: "Set Desk Height"
id: set_desk_height
min_value: ${min_height}
max_value: ${max_height}
step: 0.1
lambda: return id(desk_height).state;
set_action:
- cover.control:
id: desk_cover
position: !lambda return (x - ${min_height}) / (${max_height} - ${min_height});
display:
- platform: nextion
id: my_nextion
uart_id: nextion_uart
update_interval: 700ms
script:
# Desk preset scripts; customize as needed
- id: desk_sit_script
then:
- uart.write:
id: desk_uart
data: [/* your preset command bytes here */]