--- /dev/null
+######################################################################
+# 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