Update czytnik-brama.yaml
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
esphome:
|
||||
name: terminal-brama
|
||||
# Punkt 1: Obniżenie taktowania procesora dla oszczędności energii i niższej temperatury
|
||||
platformio_options:
|
||||
board_build.f_cpu: 80000000L
|
||||
|
||||
@@ -12,7 +11,7 @@ esp32:
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
power_save_mode: LIGHT # Punkt 3: Energooszczędny tryb WiFi
|
||||
power_save_mode: LIGHT
|
||||
fast_connect: true
|
||||
|
||||
api:
|
||||
@@ -30,10 +29,8 @@ logger:
|
||||
globals:
|
||||
- id: g_imie
|
||||
type: std::string
|
||||
restore_value: no
|
||||
- id: g_nazwisko
|
||||
type: std::string
|
||||
restore_value: no
|
||||
- id: status_karty
|
||||
type: std::string
|
||||
initial_value: '"Przyłóż kartę"'
|
||||
@@ -52,28 +49,26 @@ font:
|
||||
glyphs: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyząćęłńóśźżĄĆĘŁŃÓŚŹŻ!?:-., "
|
||||
|
||||
i2c:
|
||||
sda: GPIO21
|
||||
scl: GPIO22
|
||||
sda: 21
|
||||
scl: 22
|
||||
|
||||
spi:
|
||||
id: bus_spi
|
||||
clk_pin: GPIO18
|
||||
mosi_pin: GPIO23
|
||||
miso_pin: GPIO19
|
||||
clk_pin: 18
|
||||
mosi_pin: 23
|
||||
miso_pin: 19
|
||||
|
||||
rc522_spi:
|
||||
spi_id: bus_spi
|
||||
cs_pin: GPIO5
|
||||
reset_pin: GPIO4
|
||||
update_interval: 500ms
|
||||
cs_pin: 5
|
||||
reset_pin: 4
|
||||
update_interval: 500ms
|
||||
on_tag:
|
||||
then:
|
||||
- display.page.show: strona_glowna # Wybudź ekran przy skanowaniu
|
||||
- display.page.show: strona_glowna
|
||||
- homeassistant.tag_scanned: !lambda 'return x;'
|
||||
|
||||
switch:
|
||||
- platform: gpio
|
||||
pin: GPIO13
|
||||
pin: 13
|
||||
id: przekaznik_bramy
|
||||
name: "Przekaźnik Bramy"
|
||||
restore_mode: ALWAYS_OFF
|
||||
@@ -86,10 +81,12 @@ script:
|
||||
mode: restart
|
||||
then:
|
||||
- delay: 3s
|
||||
- globals.set: { id: pokazuj_pracownika, value: 'false' }
|
||||
- globals.set:
|
||||
id: pokazuj_pracownika
|
||||
value: 'false'
|
||||
- lambda: 'id(status_karty) = "Przyłóż kartę";'
|
||||
- component.update: moj_ekran
|
||||
- delay: 60s # Punkt 2: Czekaj minutę i wygaś ekran
|
||||
- delay: 60s
|
||||
- display.page.show: strona_pusta
|
||||
|
||||
display:
|
||||
@@ -108,7 +105,7 @@ display:
|
||||
it.print(64, 28, id(font_duza), TextAlign::TOP_CENTER, id(g_imie).c_str());
|
||||
it.print(64, 48, id(font_duza), TextAlign::TOP_CENTER, id(g_nazwisko).c_str());
|
||||
}
|
||||
- id: strona_pusta # Punkt 2: Pusta strona dla oszczędności OLED
|
||||
- id: strona_pusta
|
||||
lambda: |-
|
||||
;
|
||||
|
||||
@@ -124,23 +121,23 @@ light:
|
||||
|
||||
output:
|
||||
- platform: gpio
|
||||
pin: GPIO12
|
||||
pin: 12
|
||||
id: out_zielona
|
||||
- platform: gpio
|
||||
pin: GPIO14
|
||||
pin: 14
|
||||
id: out_czerwona
|
||||
|
||||
text_sensor:
|
||||
- platform: homeassistant
|
||||
id: pracownik_text
|
||||
entity_id: input_text.ostatni_pracownik_przy_bramie
|
||||
entity_id: input_text.terminal_status
|
||||
on_value:
|
||||
then:
|
||||
- lambda: |-
|
||||
std::string s = x;
|
||||
if (s.empty() || s == "Przyłóż kartę") return;
|
||||
if (s.empty() || s == "Przyłóż kartę") return;
|
||||
|
||||
id(moj_ekran)->show_page(id(strona_glowna)); // Wybudź ekran przy nowej wiadomości
|
||||
id(moj_ekran)->show_page(id(strona_glowna));
|
||||
|
||||
if (s == "Brak Uprawnień") {
|
||||
id(pokazuj_pracownika) = false;
|
||||
@@ -149,13 +146,27 @@ text_sensor:
|
||||
std::vector<std::string> v;
|
||||
std::string temp = "";
|
||||
for (char c : s) {
|
||||
if (c == ' ') { if (!temp.empty()) { v.push_back(temp); temp = ""; } }
|
||||
else { temp += c; }
|
||||
if (c == ' ') {
|
||||
if (!temp.empty()) {
|
||||
v.push_back(temp);
|
||||
temp = "";
|
||||
}
|
||||
} else {
|
||||
temp += c;
|
||||
}
|
||||
}
|
||||
if (!temp.empty()) v.push_back(temp);
|
||||
if(v.size() >= 2) { id(g_imie) = v[0]; id(g_nazwisko) = v[1]; }
|
||||
else { id(g_imie) = s; id(g_nazwisko) = ""; }
|
||||
|
||||
if (v.size() >= 2) {
|
||||
id(g_imie) = v[0];
|
||||
id(g_nazwisko) = v[1];
|
||||
} else {
|
||||
id(g_imie) = s;
|
||||
id(g_nazwisko) = "";
|
||||
}
|
||||
|
||||
id(pokazuj_pracownika) = true;
|
||||
}
|
||||
|
||||
id(timer_ekranu)->execute();
|
||||
- component.update: moj_ekran
|
||||
- component.update: moj_ekran
|
||||
Reference in New Issue
Block a user