-
Notifications
You must be signed in to change notification settings - Fork 0
/
ttgo-tdisplay-watt.yaml
200 lines (175 loc) · 4.62 KB
/
ttgo-tdisplay-watt.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
esphome:
name: ttgo-tdisplay-watt
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: !secret api_secret
ota:
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
power_save_mode: none
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "AP ${node_name}"
password: !secret wifi_ap_password
captive_portal:
web_server:
port: 80
font:
- file: 'fonts/slkscr.ttf'
id: font_slkscr_8
size: 8
glyphs: "!%()+,-/_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz"
- file: 'fonts/slkscr.ttf'
id: font_slkscr_16
size: 16
glyphs: "!%()+,-/_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz"
- file: 'fonts/BebasNeue-Regular.ttf'
id: font_bebas_48
size: 48
- file: 'fonts/BebasNeue-Regular.ttf'
id: font_bebas_56
size: 56
- file: 'fonts/BebasNeue-Regular.ttf'
id: font_bebas_96
size: 96
- file: 'fonts/arial.ttf'
id: font_arial_12
size: 12
- file: 'fonts/arial.ttf'
id: font_arial_16
size: 16
color:
- id: color_red
red: 1
green: 0
blue: 0
- id: color_green
red: 0
green: 1
blue: 0
- id: color_blue
red: 0
green: 0
blue: 1
- id: color_orange
red: 1
green: 0.6
blue: 0
- id: color_teal_blue
red: 0
green: 0.5
blue: 0.45
spi:
clk_pin: GPIO18
mosi_pin: GPIO19
time:
- platform: homeassistant
id: esptime
binary_sensor:
- platform: gpio
pin:
number: GPIO35
inverted: true
id: tdisplay_button_input_1
on_click:
then:
- homeassistant.service:
service: lock.unlock
data:
entity_id: lock.z_wave_controlled_door_lock_with_bluetooth_smart
- platform: gpio
pin:
number: GPIO0
inverted: true
id: tdisplay_button_input_0
on_click:
then:
- homeassistant.service:
service: lock.lock
data:
entity_id: lock.z_wave_controlled_door_lock_with_bluetooth_smart
- platform: status
name: "Node Status"
id: system_status
# We can still control the backlight independently
switch:
- platform: gpio
pin: GPIO4
name: "Backlight"
id: backlight
sensor:
- platform: homeassistant
id: dsmr_power_consumption
entity_id: sensor.power_consumption
unit_of_measurement: 'kW'
filters:
- multiply: 1000
- platform: adc
pin: 34
attenuation: 11db
filters:
- multiply: 2
name: VBatt
id: vcc
update_interval: 10s
- platform: template
name: batterylevel
id: batterylevel
unit_of_measurement: '%'
update_interval: 10s
lambda: |-
//return ((id(vcc).state /4.2) * 100.00);
return ((id(vcc).state -3) /1.2 * 100.00);
text_sensor:
- platform: homeassistant
id: lock_status
entity_id: lock.z_wave_controlled_door_lock_with_bluetooth_smart
# TODO brightness
display:
- platform: st7789v
backlight_pin: GPIO4
cs_pin: GPIO5
dc_pin: GPIO16
reset_pin: GPIO23
rotation: 90°
brightness: 25%
update_interval: 5s
lambda: |-
if (id(vcc).has_state()) {
it.printf(4, 4, id(font_arial_16), id(color_teal_blue), "%.2f V (%.2f %%)", id(vcc).state, id(batterylevel).state);
}
if (id(lock_status).has_state()) {
if (id(lock_status).state == "locked") {
it.print(192, 4, id(font_arial_16), id(color_red), "Unlock");
} else {
it.print(205, 120, id(font_arial_16), id(color_green), "Lock");
}
it.strftime(4, 120, id(font_arial_16), "%Y-%m-%d %H:%M:%S", id(esptime).now());
if (id(dsmr_power_consumption).has_state()) {
float pwr = id(dsmr_power_consumption).state;
if (pwr > 1000.0) {
it.printf(10, 18, id(font_bebas_96), id(color_red), "%.0f W", id(dsmr_power_consumption).state);
} else {
if (pwr > 750.0) {
it.printf(10, 18, id(font_bebas_96), id(color_orange), "%.0f W", id(dsmr_power_consumption).state);
} else {
it.printf(10, 18, id(font_bebas_96), id(color_green), "%.0f W", id(dsmr_power_consumption).state);
}
}
}
//if (id(lock_status).has_state()) {
//if (id(lock_status).state == "locked") {
//it.printf(100, 120, id(font_arial_16), id(color_green), "%s", id(lock_status).state.c_str());
//} else {
//it.printf(100, 120, id(font_arial_16), id(color_red), "%s", id(lock_status).state.c_str());
//}
}