feat: aufzeichnen der letzten entsperrung

This commit is contained in:
neri 2024-05-28 22:36:16 +02:00
parent 8508507954
commit 56b48a33eb
1 changed files with 26 additions and 2 deletions

View File

@ -83,7 +83,6 @@ rc522_spi:
# store the tag id into global variable
- lambda: |-
id(my_tag) = x;
- homeassistant.tag_scanned: !lambda 'return x;'
# login to vault with role_id to fetch short lived token
- http_request.post:
url: https://vault.ctdo.de/v1/auth/approle/login
@ -121,7 +120,26 @@ rc522_spi:
condition:
lambda: 'return id(may_switch_output);'
then:
- switch.toggle: mlock_${name_of_board}_switch
- if:
condition:
switch.is_on: mlock_${name_of_board}_switch
then:
- switch.turn_off: mlock_${name_of_board}_switch
- homeassistant.event:
event: esphome.mlock_locked
data:
tag: !lambda return id(my_tag);
machine: ${name_of_board}
else:
- switch.turn_on: mlock_${name_of_board}_switch
- homeassistant.event:
event: esphome.mlock_unlocked
data:
tag: !lambda return id(my_tag);
machine: ${name_of_board}
- text.set:
id: ${name_of_board}_letzte_entsperrung
value: !lambda return id(my_tag);
else:
- repeat:
count: 3
@ -193,3 +211,9 @@ light:
num_leds: 1
internal: true
text:
- platform: template
name: "$name_of_board Letzte Entsperung"
id: ${name_of_board}_letzte_entsperrung
optimistic: true
mode: text