-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathatoms3.yml
263 lines (231 loc) · 6.23 KB
/
atoms3.yml
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
esphome:
name: esphome-web-5c4f38
friendly_name: 8sleep
platformio_options:
build_flags:
- "-w"
esp32:
board: m5stack-atoms3
variant: esp32s3
framework:
type: esp-idf
version: 5.3.1
platform_version: 6.9.0
sdkconfig_options:
CONFIG_SPIFFS_DBG: n
wifi:
# networks:
# - ssid: !secret wifi_ssid
# password: !secret wifi_password
ap: {}
captive_portal:
logger:
baud_rate: 0
api:
# encryption:
# key: "" # optional, recommended, generate here https://esphome.io/components/api.html
ota:
platform: esphome
# esp32_ble_tracker:
# bluetooth_proxy:
# active: false
i2c:
- id: bus_a
sda: GPIO38
scl: GPIO39
globals:
- id: show_temp_selection
type: bool
initial_value: 'false'
- id: temp_selection_time
type: uint32_t
initial_value: '0'
sensor:
# - platform: mpu6886
# address: 0x68
# accel_x:
# name: "$device_name MPU6886 Accel X"
# accel_y:
# name: "$device_name MPU6886 Accel Y"
# accel_z:
# name: "$device_name MPU6886 Accel Z"
# gyro_x:
# name: "$device_name MPU6886 Gyro X"
# gyro_y:
# name: "$device_name MPU6886 Gyro Y"
# gyro_z:
# name: "$device_name MPU6886 Gyro Z"
# temperature:
# name: "$device_name MPU6886 Temperature"
# - platform: wifi_signal
# name: "WiFi Signal Sensor"
# update_interval: 120s
- platform: homeassistant
name: "Temperature"
entity_id: sensor.jack_bed_state_template
id: temperature
unit_of_measurement: ""
- platform: homeassistant
name: "Target Heating Level"
entity_id: sensor.8_sleep_target_temperature_template
id: target_heating_level
unit_of_measurement: ""
- platform: homeassistant
name: "Temperature Selection"
entity_id: input_select.eight_sleep_temperature_choices
id: temp_selection
internal: true
text_sensor:
- platform: homeassistant
name: "Sleep Stage"
entity_id: sensor.jack_s_eight_sleep_side_sleep_stage
id: sleep_stage
- platform: homeassistant
name: "Bed State Type"
entity_id: sensor.8_sleep_bed_state_template
id: bed_state_type
spi:
clk_pin: GPIO17
mosi_pin: GPIO21
color:
- id: my_red
red: 100%
green: 0%
blue: 0%
- id: my_green
red: 0%
green: 100%
blue: 0%
- id: my_gray
red: 50%
green: 50%
blue: 50%
- id: my_black
red: 0%
green: 0%
blue: 0%
- id: my_white
red: 100%
green: 100%
blue: 100%
font:
- file: "gfonts://Roboto"
id: roboto_32
size: 32
- file: "gfonts://Roboto"
id: roboto_24
size: 24
- file: "gfonts://Roboto"
id: roboto_18
size: 18
- file: "gfonts://Roboto"
id: roboto_12
size: 12
output:
- platform: ledc
pin: 16
min_power: 0.30
max_power: 0.99
zero_means_zero: true
id: backlightdim
light:
- platform: monochromatic
output: backlightdim
restore_mode: RESTORE_DEFAULT_ON
name: "Backlight"
id: backlightlight
display:
- platform: ili9xxx
model: ST7789V
id: disp
cs_pin: 15
dc_pin: 33
reset_pin: 34
rotation: 0
invert_colors: true
update_interval: 250ms
dimensions:
height: 128
width: 128
offset_height: 1
offset_width: 2
lambda: |-
// Check if we should show temperature selection
if (id(show_temp_selection)) {
// Check if 2 seconds have passed
if (millis() - id(temp_selection_time) > 2000) {
id(show_temp_selection) = false;
}
// Show large temperature selection
it.fill(id(my_black));
// Get the current temperature selection and convert to string
float temp_val = id(temp_selection).state;
char temp_str[8];
snprintf(temp_str, sizeof(temp_str), "%.0f", temp_val);
// Center the text - estimate width based on text length
int16_t char_width = 18; // Approximate width of each character
int16_t text_len = strlen(temp_str);
int16_t x_pos = (128 - (text_len * char_width)) / 2;
int16_t y_pos = 48; // Center vertically (128/2 - 32/2)
// Draw the temperature
it.print(x_pos, y_pos, id(roboto_32), id(my_white), temp_str);
} else {
// Normal display code
it.fill(id(my_black));
// Print "8sleep" at the top
it.print(0, 0, id(roboto_24), id(my_white), "8sleep");
// Print Temperature
if (!isnan(id(temperature).state)) {
it.printf(0, 24, id(roboto_18), id(my_white), "Temp: %.1f", id(temperature).state);
} else {
it.print(0, 24, id(roboto_18), id(my_white), "Temp: N/A");
}
// Print Target Heating Level
if (!isnan(id(target_heating_level).state)) {
it.printf(0, 48, id(roboto_18), id(my_white), "Target: %.1f", id(target_heating_level).state);
} else {
it.print(0, 48, id(roboto_18), id(my_white), "Target: N/A");
}
// Print Sleep Stage
if (!id(sleep_stage).state.empty()) {
it.printf(0, 72, id(roboto_18), id(my_white), "Stage: %s", id(sleep_stage).state.c_str());
} else {
it.print(0, 72, id(roboto_18), id(my_white), "Stage: N/A");
}
// Print Bed State Type
if (!id(bed_state_type).state.empty()) {
it.printf(0, 96, id(roboto_18), id(my_white), "State: %s", id(bed_state_type).state.c_str());
} else {
it.print(0, 96, id(roboto_18), id(my_white), "State: N/A");
}
}
binary_sensor:
- platform: gpio
name: Button
pin:
number: GPIO41
inverted: true
mode:
input: true
pullup: true
filters:
- delayed_off: 10ms
on_press:
then:
- logger.log: Button Pressed
- lambda: |-
// Only trigger the temperature display if the backlight is on
if (id(backlightlight).current_values.is_on()) {
id(show_temp_selection) = true;
id(temp_selection_time) = millis();
}
- platform: template
name: Temperature Selection Changed
id: temp_selection_changed
lambda: |-
return false; // Initial state
on_press:
then:
- lambda: |-
id(show_temp_selection) = true;
id(temp_selection_time) = millis();