-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathttg.yaml
148 lines (125 loc) · 3.46 KB
/
ttg.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
esphome:
name: ttg
platform: ESP32
board: featheresp32
<<: !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: GPIO18
mosi_pin: GPIO19
time:
- platform: homeassistant
id: esptime
binary_sensor:
- platform: homeassistant
entity_id: switch.tasmota
id: plug_202_state
- platform: homeassistant
entity_id: switch.tasmota_2
id: plug_204_state
- platform: gpio
pin:
number: GPIO35
inverted: true
id: tdisplay_button_input_1
on_click:
then:
- homeassistant.service:
service: switch.toggle
data:
entity_id: switch.tasmota
- platform: gpio
pin:
number: GPIO0
inverted: true
id: tdisplay_button_input_0
on_click:
then:
- homeassistant.service:
service: switch.toggle
data:
entity_id: switch.tasmota_2
- 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: plug_202_power
entity_id: sensor.tasmota_energy_power
unit_of_measurement: 'W'
- platform: homeassistant
id: plug_202_voltage
unit_of_measurement: 'V'
entity_id: sensor.tasmota_energy_voltage
- platform: homeassistant
id: plug_204_power
entity_id: sensor.tasmota_energy_power_2
unit_of_measurement: 'W'
- platform: homeassistant
id: plug_204_voltage
unit_of_measurement: 'V'
entity_id: sensor.tasmota_energy_voltage_2
- 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
backlight_pin: GPIO4
cs_pin: GPIO5
dc_pin: GPIO16
reset_pin: GPIO23
rotation: 90°
#brightness: 0.5
update_interval: 5s
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), "MICRO");
it.print(190, 120, id(font_slkscr_8), id(color_teal_blue), "TV CAMA");
if(id(plug_204_state).has_state()) {
if (id(plug_204_state).state) {
it.print(16, 18, id(font_bebas_56), id(color_green), "TV CAMA: ON");
} else {
it.print(16, 18, id(font_bebas_56), id(color_red), "TV CAMA: OFF");
}
}
if (id(plug_204_power).has_state()) {
float pwr = id(plug_204_power).state;
if (pwr > 10.0) {
it.printf(16, 72, id(font_bebas_56), id(color_orange), "%.1f W", id(plug_204_power).state);
} else {
it.printf(16, 72, id(font_bebas_56), id(color_green), "%.1f W", id(plug_204_power).state);
}
}