Update czytnik-brama.yaml

This commit is contained in:
2026-02-20 05:08:09 +01:00
parent 15400e6ae9
commit 09a8a348eb

View File

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