From: Giorgio Ravera Date: Fri, 6 May 2022 11:42:33 +0000 (+0200) Subject: Added NFC management (preliminary) X-Git-Url: http://git.giorgioravera.it/?a=commitdiff_plain;h=4d05c8511a81289c2830934c9c586d9a7bb1f792;p=homeassistant.git Added NFC management (preliminary) --- diff --git a/automations/nfc.yaml b/automations/nfc.yaml new file mode 100644 index 00000000..1c35e01e --- /dev/null +++ b/automations/nfc.yaml @@ -0,0 +1,64 @@ +###################################################################### +# NFC: Notification +###################################################################### + +- id: nfc_scan_notification + alias: "NFC Notifica Scansione" + mode: single + max_exceeded: silent + variables: + allowed_devices: + !secret giorgio_smartphone_nfc: + name: "Giorgio" + !secret laura_smartphone_nfc: + name: "Laura" + allowed_tags: + !secret nfc_1: + name: "NFC_1" + + trigger: + platform: event + event_type: tag_scanned + + action: + - variables: + detected_tag: "{{ trigger.event.data.tag_id }}" + detected_device: "{{ trigger.event.data.device_id }}" + + - choose: + - conditions: + - "{{ detected_tag in allowed_tags }}" + - "{{ detected_device in allowed_devices }}" + sequence: + - service: script.notify_text + data_template: + title: "Home Assistant - Lettura NFC" + message: "Letto tag NFC {{ allowed_tags[detected_tag].name }} dal dispositivo {{ allowed_devices[detected_device].name }}." + disable_telegram: true + + - conditions: + - "{{ detected_tag in allowed_tags }}" + - "{{ detected_device not in allowed_devices }}" + sequence: + - service: script.notify_text + data_template: + title: "Home Assistant - Lettura NFC" + message: "Letto tag NFC {{ allowed_tags[detected_tag].name }} da dispositivo non valido ({{ detected_device }})." + disable_telegram: true + + - conditions: + - "{{ detected_tag not in allowed_tags }}" + - "{{ detected_device in allowed_devices }}" + sequence: + - service: script.notify_text + data_template: + title: "Home Assistant - Lettura NFC" + message: "Letto tag NFC non riconosciuto ({{ detected_tag }}) dal dispositivo {{ allowed_devices[detected_device].name }}." + disable_telegram: true + + default: + - service: script.notify_text + data_template: + title: "Home Assistant - Lettura NFC" + message: "Letto tag NFC non valido ({{ detected_tag }}) da dispositivo non valido ({{ detected_device }})." + disable_telegram: true