-
Notifications
You must be signed in to change notification settings - Fork 7
/
ttg-pages.yaml
178 lines (154 loc) · 4.6 KB
/
ttg-pages.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
esphome:
name: ttg
platform: ESP32
board: esp32dev
<<: !include base.yaml
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_pass
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Ttg Fallback Hotspot"
password: "zvmjI13rzTGs"
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
### CUSTOM!!
spi:
clk_pin: 18
mosi_pin: 19
time:
- platform: homeassistant
id: esptime
binary_sensor:
- platform: homeassistant
#name: "Input Boolean From Home Assistant"
entity_id: switch.termo
id: termo_state
- platform: homeassistant
#name: "Input Boolean From Home Assistant"
entity_id: switch.tasmota
id: plug_state
- platform: gpio
pin:
number: 35
mode: INPUT_PULLUP
inverted: true
id: ttgo_gpio35
on_click:
then:
- homeassistant.service:
service: switch.toggle
data:
entity_id: switch.tasmota
- platform: gpio
pin:
number: 0
mode: INPUT_PULLUP
inverted: true
id: ttgo_gpio0
on_click:
then:
- homeassistant.service:
service: switch.toggle
data:
entity_id: switch.termo
sensor:
- platform: homeassistant
id: termo_power
entity_id: sensor.termo_energy_power
unit_of_measurement: 'W'
#internal: true
- platform: homeassistant
id: termo_voltage
unit_of_measurement: 'V'
entity_id: sensor.termo_energy_voltage
#internal: true
- platform: homeassistant
id: plug_power
entity_id: sensor.tasmota_energy_power
unit_of_measurement: 'W'
#internal: true
- platform: homeassistant
id: plug_voltage
unit_of_measurement: 'V'
entity_id: sensor.tasmota_energy_voltage
#internal: true
- platform: adc
pin: 34
attenuation: 11db
name: VBatt
id: vcc
update_interval: 60s
- platform: template
name: batterylevel
id: batterylevel
unit_of_measurement: '%'
update_interval: 60s
lambda: |-
// I know infering the battery from voltage only is misleading, but I'll take it. Considering linear decay (again, i'll take it), max=2.23, min=1.38
return ((id(vcc).state * 118) - 162);
# TODO brightness
display:
- platform: st7789v
id: oled_display
reset_pin: 23
bl_pin: 4
cs_pin: 5
dc_pin: 16
rotation: 90°
#brightness: 0.5
update_interval: 2s
pages:
- id: page1
lambda: |-
if (id(vcc).has_state()) {
it.printf(4, 4, id(font_arial_12), id(color_teal_blue), "%.2f VBat (%.2f %%)", id(vcc).state, id(batterylevel).state);
}
it.print(212, 4, id(font_slkscr_8), id(color_teal_blue), "PLUG");
it.print(210, 120, id(font_slkscr_8), id(color_teal_blue), "TERMO");
if(id(termo_state).has_state()) {
if (id(termo_state).state) {
it.print(16, 18, id(font_bebas_56), id(color_green), "TERMO: ON");
} else {
it.print(16, 18, id(font_bebas_56), id(color_red), "TERMO: OFF");
}
}
if (id(termo_power).has_state()) {
float pwr = id(termo_power).state;
if (pwr > 10.0) {
it.printf(16, 72, id(font_bebas_56), id(color_orange), "%.1f W", id(termo_power).state);
} else {
it.printf(16, 72, id(font_bebas_56), id(color_green), "%.1f W", id(termo_power).state);
}
}
- id: page2
lambda: |-
if (id(vcc).has_state()) {
it.printf(4, 4, id(font_arial_12), id(color_teal_blue), "%.2f VBat (%.2f %%)", id(vcc).state, id(batterylevel).state);
}
it.print(212, 4, id(font_slkscr_8), id(color_teal_blue), "PLUG");
it.print(210, 120, id(font_slkscr_8), id(color_teal_blue), "TERMO");
if(id(plug_state).has_state()) {
if (id(plug_state).state) {
it.print(16, 18, id(font_bebas_56), id(color_green), "PLUG: ON");
} else {
it.print(16, 18, id(font_bebas_56), id(color_red), "PLUG: OFF");
}
}
if (id(plug_power).has_state()) {
float pwr = id(plug_power).state;
if (pwr > 10.0) {
it.printf(16, 72, id(font_bebas_56), id(color_orange), "%.1f W", id(plug_power).state);
} else {
it.printf(16, 72, id(font_bebas_56), id(color_green), "%.1f W", id(plug_power).state);
}
}
interval:
- interval: 5s
then:
- display.page.show_next: oled_display
- component.update: oled_display