-
Notifications
You must be signed in to change notification settings - Fork 1
/
a_master_c3_oled.yaml
231 lines (176 loc) · 5.5 KB
/
a_master_c3_oled.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
#------------------------------
#-- a_master_c3_oled.yaml
#-- Petit code générique minimaliste pour des projets à base d'esp32-c3-oled
#-- ATTENTION: je ne sais pas pourquoi mais il faut le flasher via https://web.esphome.io (maintenir la touche BOOT pendant le RESET), via le port USB en ESPHOME cela ne fonctionne pas !
#--
#-- REMARQUE: au 29 décembre 2022, je ne sais pas pourquoi la luminosité du display OLED est très très faible !
#-- REMARQUE2: au 28 juillet 2023, il n'y a plus le problème de luminosité, par contre on affiche en négatif !
#--
#-- location: xxx
#-- zf221229.1836, zf230728.2256
#--
# sources:
# https://github.com/01Space/ESP32-C3-0.42LCD
# https://github.com/01Space/ESP32-C3-0.42LCD/blob/main/Schematic/ESP32-C3-0.42OED%20Schematic.pdf
esphome:
name: a_master_c3_oled
# platformio_options:
# board_build.flash_mode: dio
on_boot:
- switch.turn_on: led
# - switch.turn_off: led
esp32:
board: esp32-c3-devkitm-1
framework:
type: arduino
# version: 2.0.5
# platform_version: 5.2.0
# Configuration WIFI
wifi:
ssid: !secret wifi_ssid_3G_zf2
password: !secret wifi_pass_3G_zf2
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "a_master_c3_oled Fallback"
password: !secret ap_wifi_password
captive_portal:
# Enable logging
logger:
level: VERBOSE
# Enable Home Assistant API
api:
password: !secret api_password
ota:
password: !secret ota_password
# WEB Server
web_server:
port: 80
# Définition des Switch's
switch:
- platform: gpio
name: "a_master_c3_oled LED"
# inverted: True
id: led
pin: GPIO9
on_turn_on:
- light.turn_on:
id: a_master_c3_oled_rgb
brightness: 30%
red: 100%
green: 0%
blue: 0%
on_turn_off:
- light.turn_off:
id: a_master_c3_oled_rgb
- platform: restart
name: "a_master_c3_oled Restart"
# Définition des Sensors
sensor:
- platform: wifi_signal
name: "a_master_c3_oled Signal Wi-Fi"
update_interval: 5s
- platform: uptime
name: "a_master_c3_oled uptime"
update_interval: 5s
# Définition des Sensors text
text_sensor:
- platform: version
name: "a_master_c3_oled Version 1150"
- platform: wifi_info
ip_address:
name: a_master_c3_oled IP Address
id: wifi_ip
ssid:
name: a_master_c3_oled Connected SSID
id: wifi_ssid
# Définition des inputs numbers
number:
- platform: template
name: "a_master_c3_oled consigne alarme low"
restore_value: true
optimistic: true
min_value: 0.0
max_value: 0.8
step: 0.01
initial_value: 0.4
unit_of_measurement: "V"
id: a_master_c3_oled_consigne_alarme_low
light:
- platform: neopixelbus
type: GRB
variant: WS2812
pin: GPIO2
num_leds: 1
name: "a_master_c3_oled RGB"
id: a_master_c3_oled_rgb
font:
#https://github.com/JotJunior/PHP-Boleto-ZF2/blob/master/public/assets/fonts/arial.ttf
- file: 'arialn.ttf'
id: font1
size: 10
- file: 'arialn.ttf'
id: font2
size: 13
i2c:
sda: GPIO05
scl: GPIO06
scan: true
frequency: 200kHz
display:
# https://github.com/01Space/ESP32-C3-0.42LCD
# http://www.esp8266learning.com/wemos-oled-shield-example.php
# https://esphome.io/api/namespaceesphome_1_1display.html
- platform: ssd1306_i2c
#model: "SSD1306 64x48"
model: "SSD1306 72x40"
address: 0x3C
invert: true
update_interval: 3s
lambda: |-
// Turn the whole display on.
//it.fill(COLOR_ON);
// Turn the whole display off.
//it.fill(COLOR_OFF);
// For example, draw a line from [x=0,y=0] to [x=50,y=50]
it.line(0, 0, 72, 40);
// Print "Hello Zuzu" for fonts tests in top center.
it.print(36, 5, id(font2), TextAlign::TOP_CENTER, "Hello Zuzu");
it.print(36, 20, id(font2), TextAlign::TOP_CENTER, "Ca marche !");
#
# // Print inside temperature (from homeassistant sensor)
# it.printf(0, 7, id(font1), TextAlign::BASELINE_LEFT, "In side");
# if (id(inside_temperature).has_state()) {
# it.printf(64, 7, id(font1), TextAlign::BASELINE_RIGHT , "%.1f°C", id(inside_temperature).state);
# }
# // Print outside temperature (from homeassistant sensor)
# it.printf(0, 16, id(font1), TextAlign::BASELINE_LEFT, "Out side");
# if (id(outside_temperature).has_state()) {
# it.printf(64, 16, id(font1), TextAlign::BASELINE_RIGHT , "%.1f°C", id(outside_temperature).state);
# }
# // Print TVOC (from homeassistant sensor)
# it.printf(0, 25, id(font1), TextAlign::BASELINE_LEFT, "TVOC");
# if (id(outside_temperature).has_state()) {
# it.printf(64, 25, id(font1), TextAlign::BASELINE_RIGHT , "%.0f", id(tvoc).state);
# }
# // Print "L'état du input text de HA: <state>" in midle center
# it.printf(32, 36, id(font2), TextAlign::BASELINE_CENTER, "%s", id(alarm_state).state.c_str());
# // Print time in HH:MM format
# it.strftime(32, 48, id(font1), TextAlign::BOTTOM_CENTER, "%d-%m %H:%M:%S", id(esptime).now());
# # Gestion des timers
# interval:
# # Timer pour calculer le temps passé à avancer !
# - interval: 2s
# then:
# - light.turn_on:
# id: a_master_c3_oled_rgb
# brightness: 30%
# red: 100%
# green: 0%
# blue: 0%
# - delay: 1s
# - light.turn_on:
# id: a_master_c3_oled_rgb
# brightness: 0%
# red: 100%
# green: 0%
# blue: 0%