feat: aufzeichnen der letzten entsperrung

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

View File

@ -83,7 +83,6 @@ rc522_spi:
# store the tag id into global variable # store the tag id into global variable
- lambda: |- - lambda: |-
id(my_tag) = x; id(my_tag) = x;
- homeassistant.tag_scanned: !lambda 'return x;'
# login to vault with role_id to fetch short lived token # login to vault with role_id to fetch short lived token
- http_request.post: - http_request.post:
url: https://vault.ctdo.de/v1/auth/approle/login url: https://vault.ctdo.de/v1/auth/approle/login
@ -121,7 +120,26 @@ rc522_spi:
condition: condition:
lambda: 'return id(may_switch_output);' lambda: 'return id(may_switch_output);'
then: 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: else:
- repeat: - repeat:
count: 3 count: 3
@ -193,3 +211,9 @@ light:
num_leds: 1 num_leds: 1
internal: true internal: true
text:
- platform: template
name: "$name_of_board Letzte Entsperung"
id: ${name_of_board}_letzte_entsperrung
optimistic: true
mode: text