157 lines
36 KiB
YAML
157 lines
36 KiB
YAML
esphome:
|
|
name: terminal-brama
|
|
platformio_options:
|
|
board_build.f_cpu: 80000000L # Oszczędność energii i niższa temperatura
|
|
|
|
esp32:
|
|
board: esp32dev
|
|
framework:
|
|
type: arduino
|
|
|
|
wifi:
|
|
ssid: !secret wifi_ssid
|
|
password: !secret wifi_password
|
|
power_save_mode: LIGHT
|
|
fast_connect: true
|
|
|
|
api:
|
|
reboot_timeout: 0s
|
|
encryption:
|
|
key: !secret api_encryption_key
|
|
|
|
ota:
|
|
- platform: esphome
|
|
password: !secret ota_password
|
|
|
|
logger:
|
|
level: INFO
|
|
|
|
globals:
|
|
- id: g_imie
|
|
type: std::string
|
|
- id: g_nazwisko
|
|
type: std::string
|
|
- id: status_karty
|
|
type: std::string
|
|
initial_value: '"Przyłóż kartę"'
|
|
- id: pokazuj_pracownika
|
|
type: bool
|
|
initial_value: 'false'
|
|
|
|
font:
|
|
- file: "gfonts://Roboto"
|
|
id: font_mala
|
|
size: 11
|
|
glyphs: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyząćęłńóśźżĄĆĘŁŃÓŚŹŻ!?:-., "
|
|
- file: "gfonts://Roboto"
|
|
id: font_duza
|
|
size: 18
|
|
glyphs: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyząćęłńóśźżĄĆĘŁŃÓŚŹŻ!?:-., "
|
|
|
|
i2c:
|
|
sda: GPIO21
|
|
scl: GPIO22
|
|
|
|
spi:
|
|
id: bus_spi
|
|
clk_pin: GPIO18
|
|
mosi_pin: GPIO23
|
|
miso_pin: GPIO19
|
|
|
|
rc522_spi:
|
|
spi_id: bus_spi
|
|
cs_pin: GPIO5
|
|
reset_pin: GPIO4
|
|
update_interval: 500ms
|
|
on_tag:
|
|
then:
|
|
- display.page.show: strona_glowna
|
|
- homeassistant.tag_scanned: !lambda 'return x;'
|
|
|
|
switch:
|
|
- platform: gpio
|
|
pin: GPIO13
|
|
id: przekaznik_bramy
|
|
name: "Przekaźnik Bramy"
|
|
restore_mode: ALWAYS_OFF
|
|
on_turn_on:
|
|
- delay: 3s
|
|
- switch.turn_off: przekaznik_bramy
|
|
|
|
script:
|
|
- id: timer_ekranu
|
|
mode: restart
|
|
then:
|
|
- delay: 3s
|
|
- globals.set: { id: pokazuj_pracownika, value: 'false' }
|
|
- lambda: 'id(status_karty) = "Przyłóż kartę";'
|
|
- component.update: moj_ekran
|
|
- delay: 60s
|
|
- display.page.show: strona_pusta
|
|
|
|
display:
|
|
- platform: ssd1306_i2c
|
|
model: "SSD1306 128x64"
|
|
address: 0x3C
|
|
id: moj_ekran
|
|
update_interval: 1s
|
|
pages:
|
|
- id: strona_glowna
|
|
lambda: |-
|
|
if (!id(pokazuj_pracownika)) {
|
|
it.print(64, 32, id(font_duza), TextAlign::CENTER, id(status_karty).c_str());
|
|
} else {
|
|
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, 48, id(font_duza), TextAlign::TOP_CENTER, id(g_nazwisko).c_str());
|
|
}
|
|
- id: strona_pusta
|
|
lambda: |-
|
|
;
|
|
|
|
light:
|
|
- platform: binary
|
|
name: "Terminal LED Zielona"
|
|
output: out_zielona
|
|
id: led_zielona
|
|
- platform: binary
|
|
name: "Terminal LED Czerwona"
|
|
output: out_czerwona
|
|
id: led_czerwona
|
|
|
|
output:
|
|
- platform: gpio
|
|
pin: GPIO12
|
|
id: out_zielona
|
|
- platform: gpio
|
|
pin: GPIO14
|
|
id: out_czerwona
|
|
|
|
text_sensor:
|
|
- platform: homeassistant
|
|
id: pracownik_text
|
|
entity_id: input_text.ostatni_pracownik_przy_bramie
|
|
on_value:
|
|
then:
|
|
- lambda: |-
|
|
std::string s = x;
|
|
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
|
|
|