1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-04 04:12:23 +01:00

Move PN532OnTagTrigger to nfc::NfcOnTagTrigger (#3379)

This commit is contained in:
Jesse Hills
2022-04-13 12:26:55 +12:00
committed by GitHub
parent a519e5c475
commit b622a8fa58
6 changed files with 40 additions and 20 deletions

View File

@@ -1,3 +1,4 @@
from esphome import automation
import esphome.codegen as cg
CODEOWNERS = ["@jesserockz"]
@@ -5,3 +6,7 @@ CODEOWNERS = ["@jesserockz"]
nfc_ns = cg.esphome_ns.namespace("nfc")
NfcTag = nfc_ns.class_("NfcTag")
NfcOnTagTrigger = nfc_ns.class_(
"NfcOnTagTrigger", automation.Trigger.template(cg.std_string, NfcTag)
)

View File

@@ -0,0 +1,9 @@
#include "automation.h"
namespace esphome {
namespace nfc {
void NfcOnTagTrigger::process(const std::unique_ptr<NfcTag> &tag) { this->trigger(format_uid(tag->get_uid()), *tag); }
} // namespace nfc
} // namespace esphome

View File

@@ -0,0 +1,17 @@
#pragma once
#include <string>
#include "esphome/core/automation.h"
#include "nfc.h"
namespace esphome {
namespace nfc {
class NfcOnTagTrigger : public Trigger<std::string, NfcTag> {
public:
void process(const std::unique_ptr<NfcTag> &tag);
};
} // namespace nfc
} // namespace esphome