From 56b48a33eba6fe9356b6397615c17293b0a45e31 Mon Sep 17 00:00:00 2001 From: neri Date: Tue, 28 May 2024 22:36:16 +0200 Subject: [PATCH] feat: aufzeichnen der letzten entsperrung --- mlock-common.yaml | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/mlock-common.yaml b/mlock-common.yaml index fd297fa..1179040 100644 --- a/mlock-common.yaml +++ b/mlock-common.yaml @@ -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