From e9f43d81a3141bcf21847d22af793f62c04ec15c Mon Sep 17 00:00:00 2001 From: Paul Wieland Date: Thu, 1 Aug 2024 12:22:50 -0400 Subject: [PATCH] update --- components/ratgdo/number/ratgdo_number.cpp | 9 ++++++++- components/ratgdo/ratgdo.cpp | 4 ++-- components/ratgdo/ratgdo.h | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/components/ratgdo/number/ratgdo_number.cpp b/components/ratgdo/number/ratgdo_number.cpp index b326c6f..321dc6a 100644 --- a/components/ratgdo/number/ratgdo_number.cpp +++ b/components/ratgdo/number/ratgdo_number.cpp @@ -60,15 +60,22 @@ namespace ratgdo { this->update_state(value); }); + std::string mname = "rolling_code_counter2"; // A second subscription, which seem to overwrite the first subscription - this->parent_->subscribe_rolling_code_counter([=](uint32_t value) { + this->parent_->subscribe_rolling_code_counter([=](uint32_t value, std::string mname) { ESP_LOGD("XXX","A second rolling code counter subscription"); }); } else if (this->number_type_ == RATGDO_OPENING_DURATION) { this->parent_->subscribe_opening_duration([=](float value) { + ESP_LOGD("ZZZ","The first opening duration subscription"); this->update_state(value); }); + + this->parent_->subscribe_opening_duration([=](float value) { + ESP_LOGD("ZZZ","The second opening duration subscription"); + }); + } else if (this->number_type_ == RATGDO_CLOSING_DURATION) { this->parent_->subscribe_closing_duration([=](float value) { this->update_state(value); diff --git a/components/ratgdo/ratgdo.cpp b/components/ratgdo/ratgdo.cpp index 90cb713..5992327 100644 --- a/components/ratgdo/ratgdo.cpp +++ b/components/ratgdo/ratgdo.cpp @@ -597,13 +597,13 @@ namespace ratgdo { this->protocol_->call(InactivateLearn {}); } - void RATGDOComponent::subscribe_rolling_code_counter(std::function&& f) + void RATGDOComponent::subscribe_rolling_code_counter(std::function&& f, const std::string &name = "rolling_code_counter"); { // change update to children is defered until after component loop // if multiple changes occur during component loop, only the last one is notified auto counter = this->protocol_->call(GetRollingCodeCounter {}); if (counter.tag == Result::Tag::rolling_code_counter) { - counter.value.rolling_code_counter.value->subscribe([=](uint32_t state) { defer("rolling_code_counter", [=] { f(state); }); }); + counter.value.rolling_code_counter.value->subscribe([=](uint32_t state) { defer(name, [=] { f(state); }); }); } } void RATGDOComponent::subscribe_opening_duration(std::function&& f) diff --git a/components/ratgdo/ratgdo.h b/components/ratgdo/ratgdo.h index 228d5bc..5fcfff3 100644 --- a/components/ratgdo/ratgdo.h +++ b/components/ratgdo/ratgdo.h @@ -155,7 +155,7 @@ namespace ratgdo { void sync(); // children subscriptions - void subscribe_rolling_code_counter(std::function&& f); + void subscribe_rolling_code_counter(std::function&& f, const std::string &name = "rolling_code_counter"); void subscribe_opening_duration(std::function&& f); void subscribe_closing_duration(std::function&& f); void subscribe_openings(std::function&& f);