1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-16 02:02:21 +01:00

Add on_tag_removed trigger for RC522 (#4742)

This commit is contained in:
Keith Burzinski
2023-04-26 17:47:45 -05:00
committed by GitHub
parent 986dd2ddd2
commit f639f7c280
3 changed files with 27 additions and 5 deletions

View File

@@ -256,7 +256,7 @@ void RC522::loop() {
this->current_uid_ = rfid_uid;
for (auto *trigger : this->triggers_)
for (auto *trigger : this->triggers_ontag_)
trigger->process(rfid_uid);
if (report) {
@@ -265,6 +265,11 @@ void RC522::loop() {
break;
}
case STATE_DONE: {
if (!this->current_uid_.empty()) {
ESP_LOGV(TAG, "Tag '%s' removed", format_uid(this->current_uid_).c_str());
for (auto *trigger : this->triggers_ontagremoved_)
trigger->process(this->current_uid_);
}
this->current_uid_ = {};
state_ = STATE_INIT;
break;