Update czytnik-brama.yaml
This commit is contained in:
@@ -1,157 +1,161 @@
|
|||||||
esphome:
|
esphome:
|
||||||
name: terminal-brama
|
name: terminal-brama
|
||||||
platformio_options:
|
# Punkt 1: Obniżenie taktowania procesora dla oszczędności energii i niższej temperatury
|
||||||
board_build.f_cpu: 80000000L # Oszczędność energii i niższa temperatura
|
platformio_options:
|
||||||
|
board_build.f_cpu: 80000000L
|
||||||
|
|
||||||
esp32:
|
esp32:
|
||||||
board: esp32dev
|
board: esp32dev
|
||||||
framework:
|
framework:
|
||||||
type: arduino
|
type: arduino
|
||||||
|
|
||||||
wifi:
|
wifi:
|
||||||
ssid: !secret wifi_ssid
|
ssid: !secret wifi_ssid
|
||||||
password: !secret wifi_password
|
password: !secret wifi_password
|
||||||
power_save_mode: LIGHT
|
power_save_mode: LIGHT # Punkt 3: Energooszczędny tryb WiFi
|
||||||
fast_connect: true
|
fast_connect: true
|
||||||
|
|
||||||
api:
|
api:
|
||||||
reboot_timeout: 0s
|
reboot_timeout: 0s
|
||||||
encryption:
|
encryption:
|
||||||
key: !secret api_encryption_key
|
key: !secret api_encryption_key
|
||||||
|
|
||||||
ota:
|
ota:
|
||||||
- platform: esphome
|
- platform: esphome
|
||||||
password: !secret ota_password
|
password: !secret ota_password
|
||||||
|
|
||||||
logger:
|
logger:
|
||||||
level: INFO
|
level: INFO
|
||||||
|
|
||||||
globals:
|
globals:
|
||||||
- id: g_imie
|
- id: g_imie
|
||||||
type: std::string
|
type: std::string
|
||||||
- id: g_nazwisko
|
restore_value: no
|
||||||
type: std::string
|
- id: g_nazwisko
|
||||||
- id: status_karty
|
type: std::string
|
||||||
type: std::string
|
restore_value: no
|
||||||
initial_value: '"Przyłóż kartę"'
|
- id: status_karty
|
||||||
- id: pokazuj_pracownika
|
type: std::string
|
||||||
type: bool
|
initial_value: '"Przyłóż kartę"'
|
||||||
initial_value: 'false'
|
- id: pokazuj_pracownika
|
||||||
|
type: bool
|
||||||
|
initial_value: 'false'
|
||||||
|
|
||||||
font:
|
font:
|
||||||
- file: "gfonts://Roboto"
|
- file: "gfonts://Roboto"
|
||||||
id: font_mala
|
id: font_mala
|
||||||
size: 11
|
size: 11
|
||||||
glyphs: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyząćęłńóśźżĄĆĘŁŃÓŚŹŻ!?:-., "
|
glyphs: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyząćęłńóśźżĄĆĘŁŃÓŚŹŻ!?:-., "
|
||||||
- file: "gfonts://Roboto"
|
- file: "gfonts://Roboto"
|
||||||
id: font_duza
|
id: font_duza
|
||||||
size: 18
|
size: 18
|
||||||
glyphs: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyząćęłńóśźżĄĆĘŁŃÓŚŹŻ!?:-., "
|
glyphs: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyząćęłńóśźżĄĆĘŁŃÓŚŹŻ!?:-., "
|
||||||
|
|
||||||
i2c:
|
i2c:
|
||||||
sda: GPIO21
|
sda: GPIO21
|
||||||
scl: GPIO22
|
scl: GPIO22
|
||||||
|
|
||||||
spi:
|
spi:
|
||||||
id: bus_spi
|
id: bus_spi
|
||||||
clk_pin: GPIO18
|
clk_pin: GPIO18
|
||||||
mosi_pin: GPIO23
|
mosi_pin: GPIO23
|
||||||
miso_pin: GPIO19
|
miso_pin: GPIO19
|
||||||
|
|
||||||
rc522_spi:
|
rc522_spi:
|
||||||
spi_id: bus_spi
|
spi_id: bus_spi
|
||||||
cs_pin: GPIO5
|
cs_pin: GPIO5
|
||||||
reset_pin: GPIO4
|
reset_pin: GPIO4
|
||||||
update_interval: 500ms
|
update_interval: 500ms
|
||||||
on_tag:
|
on_tag:
|
||||||
then:
|
then:
|
||||||
- display.page.show: strona_glowna
|
- display.page.show: strona_glowna # Wybudź ekran przy skanowaniu
|
||||||
- homeassistant.tag_scanned: !lambda 'return x;'
|
- homeassistant.tag_scanned: !lambda 'return x;'
|
||||||
|
|
||||||
switch:
|
switch:
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
pin: GPIO13
|
pin: GPIO13
|
||||||
id: przekaznik_bramy
|
id: przekaznik_bramy
|
||||||
name: "Przekaźnik Bramy"
|
name: "Przekaźnik Bramy"
|
||||||
restore_mode: ALWAYS_OFF
|
restore_mode: ALWAYS_OFF
|
||||||
on_turn_on:
|
on_turn_on:
|
||||||
- delay: 3s
|
- delay: 3s
|
||||||
- switch.turn_off: przekaznik_bramy
|
- switch.turn_off: przekaznik_bramy
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- id: timer_ekranu
|
- id: timer_ekranu
|
||||||
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
|
- delay: 60s # Punkt 2: Czekaj minutę i wygaś ekran
|
||||||
- display.page.show: strona_pusta
|
- display.page.show: strona_pusta
|
||||||
|
|
||||||
display:
|
display:
|
||||||
- platform: ssd1306_i2c
|
- platform: ssd1306_i2c
|
||||||
model: "SSD1306 128x64"
|
model: "SSD1306 128x64"
|
||||||
address: 0x3C
|
address: 0x3C
|
||||||
id: moj_ekran
|
id: moj_ekran
|
||||||
update_interval: 1s
|
update_interval: 1s
|
||||||
pages:
|
pages:
|
||||||
- id: strona_glowna
|
- id: strona_glowna
|
||||||
lambda: |-
|
lambda: |-
|
||||||
if (!id(pokazuj_pracownika)) {
|
if (!id(pokazuj_pracownika)) {
|
||||||
it.print(64, 32, id(font_duza), TextAlign::CENTER, id(status_karty).c_str());
|
it.print(64, 32, id(font_duza), TextAlign::CENTER, id(status_karty).c_str());
|
||||||
} else {
|
} else {
|
||||||
it.print(64, 0, id(font_mala), TextAlign::TOP_CENTER, "Karta przyjęta");
|
it.print(64, 0, id(font_mala), TextAlign::TOP_CENTER, "Karta przyjęta");
|
||||||
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
|
- id: strona_pusta # Punkt 2: Pusta strona dla oszczędności OLED
|
||||||
lambda: |-
|
lambda: |-
|
||||||
;
|
;
|
||||||
|
|
||||||
light:
|
light:
|
||||||
- platform: binary
|
- platform: binary
|
||||||
name: "Terminal LED Zielona"
|
name: "Terminal LED Zielona"
|
||||||
output: out_zielona
|
output: out_zielona
|
||||||
id: led_zielona
|
id: led_zielona
|
||||||
- platform: binary
|
- platform: binary
|
||||||
name: "Terminal LED Czerwona"
|
name: "Terminal LED Czerwona"
|
||||||
output: out_czerwona
|
output: out_czerwona
|
||||||
id: led_czerwona
|
id: led_czerwona
|
||||||
|
|
||||||
output:
|
output:
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
pin: GPIO12
|
pin: GPIO12
|
||||||
id: out_zielona
|
id: out_zielona
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
pin: GPIO14
|
pin: GPIO14
|
||||||
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.ostatni_pracownik_przy_bramie
|
||||||
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));
|
|
||||||
if (s == "Brak Uprawnień") {
|
|
||||||
id(pokazuj_pracownika) = false;
|
|
||||||
id(status_karty) = "Brak Uprawnień";
|
|
||||||
} else {
|
|
||||||
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 (!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) = ""; }
|
|
||||||
id(pokazuj_pracownika) = true;
|
|
||||||
}
|
|
||||||
id(timer_ekranu)->execute();
|
|
||||||
- component.update: moj_ekran
|
|
||||||
|
|
||||||
|
id(moj_ekran)->show_page(id(strona_glowna)); // Wybudź ekran przy nowej wiadomości
|
||||||
|
|
||||||
|
if (s == "Brak Uprawnień") {
|
||||||
|
id(pokazuj_pracownika) = false;
|
||||||
|
id(status_karty) = "Brak Uprawnień";
|
||||||
|
} else {
|
||||||
|
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 (!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) = ""; }
|
||||||
|
id(pokazuj_pracownika) = true;
|
||||||
|
}
|
||||||
|
id(timer_ekranu)->execute();
|
||||||
|
- component.update: moj_ekran
|
||||||
|
|||||||
Reference in New Issue
Block a user