forked from shades66/Maidesite-standing-desk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deskcontrol.yaml
204 lines (184 loc) · 4.77 KB
/
deskcontrol.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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
esphome:
name: deskcontrol
friendly_name: DeskControl
includes:
- desk.h
on_boot:
priority: 800
then:
- uart.write: [0xf1, 0xf1, 0x07,0x00,0x07,0x7e,0xf1, 0xf1, 0x08,0x00,0x08,0x7e,0xf1, 0xf1, 0x09,0x00,0x09,0x7e,0xf1, 0xf1, 0x0c,0x00,0x0c,0x7e,0xf1, 0xf1, 0x0e,0x00,0x0e,0x7e]
esp32:
board: esp32-s3-devkitc-1
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "kkkkkkkkkkkkkkkkkkkk="
ota:
password: "kkkkkkkkkkkkkkkkkkkkkkk"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Deskcontrol Fallback Hotspot"
password: "fopfxEuvlxy3"
captive_portal:
uart:
- id: desk_uart
tx_pin: 17
rx_pin: 18
baud_rate: 9600
debug:
direction: BOTH
after:
bytes: 9
sequence:
- lambda: UARTDebug::log_int(direction, bytes, ',');
custom_component:
- lambda: |-
auto my_custom = new MyCustomComponent(id(desk_uart));
return {my_custom};
sensor:
- platform: template
name: "Desk M1 Height"
id: "deskm1"
filters:
- lambda: !lambda |-
if (x <1 ) return {};
return x/10;
- platform: template
name: "Desk M2 Height"
id: "deskm2"
filters:
- lambda: !lambda |-
if (x <1 ) return {};
return x/10;
- platform: template
name: "Desk M3 Height"
id: "deskm3"
filters:
- lambda: !lambda |-
if (x <1 ) return {};
return x/10;
- platform: template
name: "Desk M4 Height"
id: "deskm4"
filters:
- lambda: !lambda |-
if (x <1 ) return {};
return x/10;
text_sensor:
- platform: homeassistant
id: movement_status
entity_id: binary_sensor.presence
switch:
- platform: template
name: "Desk Enable"
id: deskenable
lambda: |-
if (id(movement_status).state == "on") {
return true;
} else {
return false;
}
turn_on_action:
- logger.log: Desk Enabled
on_turn_on:
- logger.log: Desk Enabled
on_turn_off:
- logger.log: Desk Disabled
- delay: 100s
- if:
condition:
text_sensor.state:
id: movement_status
state: "off"
then:
- logger.log: Reset Desk to lowest setting.
- uart.write: [0xf1, 0xf1, 0x05,0x00,0x05,0x7e]
button:
- platform: template
name: Desk UP
id: my_deskup
on_press:
if:
condition:
# Same syntax for is_off
switch.is_on: deskenable
then:
- logger.log: UP Pressed
- uart.write: [0xf1, 0xf1, 0x01,0x00,0x01,0x7e]
- platform: template
name: Desk Down
id: my_deskdown
on_press:
if:
condition:
# Same syntax for is_off
switch.is_on: deskenable
then:
- logger.log: DOWN Pressed
- uart.write: [0xf1, 0xf1, 0x02,0x00,0x02,0x7e]
- platform: template
name: Desk Sit
id: my_desksit
on_press:
if:
condition:
# Same syntax for is_off
switch.is_on: deskenable
then:
- logger.log: SIT Pressed
- uart.write: [0xf1, 0xf1, 0x05,0x00,0x05,0x7e]
- platform: template
name: Desk Stand
id: my_deskstamd
on_press:
if:
condition:
# Same syntax for is_off
switch.is_on: deskenable
then:
- logger.log: STAND Pressed
- uart.write: [0xf1, 0xf1, 0x06,0x00,0x06,0x7e]
- platform: template
name: Desk FULLUP
id: my_deskfullup
on_press:
if:
condition:
# Same syntax for is_off
switch.is_on: deskenable
then:
- logger.log: FULLUP Pressed
- uart.write: [0xf1, 0xf1, 0x28,0x00,0x28,0x7e]
- platform: template
name: Desk test
id: my_desktest
on_press:
then:
- logger.log: TEST Pressed
- uart.write: [0xf1, 0xf1, 0x07,0x00,0x07,0x7e,0xf1, 0xf1, 0x08,0x00,0x08,0x7e,0xf1, 0xf1, 0x09,0x00,0x09,0x7e,0xf1, 0xf1, 0x0c,0x00,0x0c,0x7e,0xf1, 0xf1, 0x0e,0x00,0x0e,0x7e]
number:
- platform: template
name: "Desk Height Control"
id: "deskSlider"
step: 1
min_value: 677
max_value: 1241
mode: slider
set_action:
if:
condition:
# Same syntax for is_off
switch.is_on: deskenable
then:
- uart.write: !lambda |-
int a= (int(x) & 0xff);
int b= ((int(x) >> 8) & 0xff);
int c= (a+b+0x80+0x02) & 0xff;
return {0xf1, 0xf1, 0x80, 2, b,a,c,0x7e,0xf1, 0xf1, 0x1b, 0x00, 0x1b,0x7e};