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:
@@ -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)
|
||||
)
|
||||
|
9
esphome/components/nfc/automation.cpp
Normal file
9
esphome/components/nfc/automation.cpp
Normal 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
|
17
esphome/components/nfc/automation.h
Normal file
17
esphome/components/nfc/automation.h
Normal 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
|
Reference in New Issue
Block a user