-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCode2.yaml
284 lines (254 loc) · 7.91 KB
/
Code2.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
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
#
# Ce code ESPHome pour LILYGO TTGO T-Display 1.14 Pouces LCD + ESP32 Module sans Fil
# Permet d'afficher les relevés de Flipr, en complément de l intégration: https://www.home-assistant.io/integrations/flipr/
# (ou d'une autre intégration HA qui remontrait les memes éléments)
# doc et boitier imprimable en 3D : https://github.com/Xinyuan-LilyGO/TTGO-T-Display
#
# Version 2.0 du code, qui apporte une lisibilité simple:
# le statut pH et celui du Chlore,
# la température de l'eau de la piscine,
# le taux de chlore; et la valeur du pH
# j'aurais pu ajouter le redox, la date de la mesure, mais cela sera dans la v3, avec l'utilisation des Boutons ;-)
substitutions:
# Ici personalisez le nom de votre ESP:
devicename: affichageflipr
frendlyname: Affichage de Flipr
# Ici personalisez l'adresse IP fixe de votre ESP:
# ce n'est pas obligatoire, sauf si plus bas vous retirez les #
ip_device: 192.168.1.1
ip_gateway: 192.168.1.254
ip_subnet: 255.255.255.0
# indiquez ici les sensors de votre Flipr:
entity1: sensor.flipr_N°de serie de votre Flipr_water_temperature
entity2: sensor.flipr_N°de serie de votre Flipr_ph
entity3: sensor.flipr_N°de serie de votre Flipr_chlorine
# indiquez ici les binary sensors de votre Flipr:
entity4: binary_sensor.flipr_N°de serie de votre Flipr_chlorine_status
entity5: binary_sensor.flipr_N°de serie de votre Flipr_ph_status
entity6: sensor.flipr_N°de serie de votre Flipr_last_measured
icon_signal: signal
# ici, réglage des valeurs pour la gestion des couleurs:
temp_mini: "26"
temp_maxi: "31"
ph_mini: "7"
ph_maxi: "7.4"
chlore_mini: "0.5"
chlore_maxi: "3"
#
# Dans le reste du code, tout est variabilisé sur les labels de substitution
#
esphome:
name: ${devicename}
platform: ESP32
board: featheresp32
# Enable logging
logger:
api:
encryption:
key: !secret key_display_p
ota:
password: !secret ota_display_p
# Ici, on lance la connexion de l'ESP8266 à votre WIFI,
# les paramètres sont à remplir plus haut, et dans le fichier secret.yaml
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# manual_ip:
# static_ip: ${ip_device}
# gateway: ${ip_gateway}
# subnet: ${ip_subnet}
# Ici, on active le serveur WEB du ESP8266, en allant sur l'IP du ESP8266, on tombe sur une interface pour piloter les relais
web_server:
port: 80
auth:
username: !secret server_username
password: !secret server_password
captive_portal:
color:
- id: my_red
red: 100%
green: 0%
blue: 0%
- id: my_yellow
red: 100%
green: 100%
blue: 0%
- id: my_green
red: 0%
green: 100%
blue: 0%
- id: my_blanc
red: 100%
green: 100%
blue: 100%
- id: my_black
red: 0%
green: 0%
blue: 0%
image:
- file: "alert.jpg"
id: pb_logo
resize: 50x50
type: RGB24
- file: "check-circle.jpg"
id: ok_logo
resize: 50x50
type: RGB24
font:
- file: "SFCompact.ttf"
id: sfcompact_40
size: 40
- file: "SFCompact.ttf"
id: sfcompact_37
size: 37
- file: "SFCompact.ttf"
id: sfcompact_25
size: 25
# ne pas oublier de mettre la font SFCompact.ttf dans le repertoir esphome de votre home assistant
binary_sensor:
- platform: gpio
pin:
number: GPIO35
inverted: true
name: "${frendlyname} bouton du haut"
id: tdisplay_button_input_1
- platform: gpio
pin:
number: GPIO0
inverted: true
id: tdisplay_button_input_0
name: "${frendlyname} bouton du bas"
- platform: status
name: "Etat de l'afficheur"
id: system_status
- platform: homeassistant
id: statut_chlore
name: "Statut Chlore: "
entity_id: ${entity4}
- platform: homeassistant
id: statut_ph
name: "Statut pH: "
entity_id: ${entity5}
- platform: homeassistant
id: derniere_analyse
name: "Derniere analyse: "
entity_id: ${entity6}
switch:
# - platform: template
# name: "Switch Chlore"
# id: "chlore"
# lambda: |-
# if (id(statut_chlore).state) {
# return true;
# } else {
# return false;
# }
# turn_on_action:
# - switch.turn_on: switch1
# turn_off_action:
# - switch.turn_off: switch1
# - platform: gpio
# pin: GPIO0
# name: "switch1"
# id: "switch1"
sensor:
- platform: homeassistant
id: temp_eau
name: "Température de l'eau:"
entity_id: ${entity1}
unit_of_measurement: '°C'
state_class: measurement
- platform: homeassistant
id: niveau_ph
name: "pH à : "
entity_id: ${entity2}
state_class: "measurement"
accuracy_decimals: 2
unit_of_measurement: "pH"
- platform: homeassistant
id: niveau_chlore
name: "Niveau de Chlore à "
entity_id: ${entity3}
unit_of_measurement: 'ppm'
state_class: measurement
accuracy_decimals: 2
- platform: wifi_signal
name: "Signal WiFi"
update_interval: 60s
- platform: uptime
name: "En ligne depuis"
update_interval: 60s
text_sensor:
- platform: wifi_info
ip_address:
name: "Addresse IP"
icon: "mdi:network-outline"
ssid:
name: "SSID :"
icon: "mdi:${icon_signal}"
bssid:
name: "BSSID :"
icon: "mdi:${icon_signal}"
time:
- platform: homeassistant
id: esptime
spi:
clk_pin: GPIO18
mosi_pin: GPIO19
display:
- platform: st7789v
model: TTGO TDisplay 135x240
backlight_pin: GPIO4
cs_pin: GPIO5
dc_pin: GPIO16
reset_pin: GPIO23
rotation: 90
lambda: |-
bool statutchlore = statut_chlore->state;
bool statutph = statut_ph->state;
it.printf(0, 0, id(sfcompact_25), id(my_blanc), TextAlign::TOP_LEFT, "Chlore pH Temp", id(niveau_ph).state);
it.line(0, 88, 149, 88);
it.line(85, 0, 85, 135);
it.line(149, 0, 149, 135);
if (id(temp_eau).state < ${temp_mini}) {
it.printf(150, 35, id(sfcompact_40), id(my_yellow), TextAlign::TOP_LEFT, "%.1f", id(temp_eau).state);
it.printf(180, 90, id(sfcompact_40), id(my_yellow), TextAlign::TOP_LEFT, "°C", id(niveau_ph).state);
}
else if (id(temp_eau).state > ${temp_maxi}) {
it.printf(150, 35, id(sfcompact_40), id(my_red), TextAlign::TOP_LEFT, "%.1f", id(temp_eau).state);
it.printf(180, 90, id(sfcompact_40), id(my_red), TextAlign::TOP_LEFT, "°C", id(niveau_ph).state);
}
else if (id(temp_eau).state >= ${temp_mini} && id(temp_eau).state <=${temp_maxi} ) {
it.printf(150, 35, id(sfcompact_40), id(my_green), TextAlign::TOP_LEFT, "%.1f", id(temp_eau).state);
it.printf(180, 90, id(sfcompact_40), id(my_green), TextAlign::TOP_LEFT, "°C", id(niveau_ph).state);
}
if (id(niveau_chlore).state < ${chlore_mini}) {
it.printf(0, 90, id(sfcompact_40), id(my_red), TextAlign::TOP_LEFT, "%.1f", id(niveau_chlore).state);
}
else if (id(niveau_chlore).state > ${chlore_maxi}) {
it.printf(0, 90, id(sfcompact_40), id(my_yellow), TextAlign::TOP_LEFT, "%.1f", id(niveau_chlore).state);
}
else if (id(niveau_chlore).state >= ${chlore_mini} && id(niveau_chlore).state <= ${chlore_maxi}){
it.printf(0, 90, id(sfcompact_40), id(my_green), TextAlign::TOP_LEFT, "%.1f", id(niveau_chlore).state);
}
if (id(niveau_ph).state > ${ph_maxi}) {
it.printf(88, 90, id(sfcompact_37), id(my_red), TextAlign::TOP_LEFT, "%.1f", id(niveau_ph).state);
}
else if (id(niveau_ph).state < ${ph_mini}) {
it.printf(88, 90, id(sfcompact_37), id(my_red), TextAlign::TOP_LEFT, "%.1f", id(niveau_ph).state);
}
else if (id(niveau_ph).state >= ${ph_mini} && id(niveau_ph).state <= ${ph_maxi}) {
it.printf(88, 90, id(sfcompact_37), id(my_green), TextAlign::TOP_LEFT, "%.1f", id(niveau_ph).state);
}
if (statutchlore) {
it.image(15, 33, id(pb_logo));
}
else {
it.image(15, 33, id(ok_logo));
}
if (statutph) {
it.image(92, 33, id(pb_logo));
}
else {
it.image(92, 33, id(ok_logo));
}