From c3ef753fe69b51990d1619a388dad72a5d24b092 Mon Sep 17 00:00:00 2001 From: descipher Date: Tue, 10 Sep 2024 01:08:13 -0500 Subject: [PATCH] Add synced state binary sensor. --- components/secplus_gdo/binary_sensor/__init__.py | 1 + components/secplus_gdo/secplus_gdo.cpp | 4 ++++ components/secplus_gdo/secplus_gdo.h | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/components/secplus_gdo/binary_sensor/__init__.py b/components/secplus_gdo/binary_sensor/__init__.py index 600f8d0..12aed6c 100644 --- a/components/secplus_gdo/binary_sensor/__init__.py +++ b/components/secplus_gdo/binary_sensor/__init__.py @@ -36,6 +36,7 @@ "obstruction": "register_obstruction", "motor": "register_motor", "button": "register_button", + "sync": "register_sync", } diff --git a/components/secplus_gdo/secplus_gdo.cpp b/components/secplus_gdo/secplus_gdo.cpp index f036325..4553f34 100644 --- a/components/secplus_gdo/secplus_gdo.cpp +++ b/components/secplus_gdo/secplus_gdo.cpp @@ -173,6 +173,10 @@ void GDOComponent::set_sync_state(bool synced) { if (this->lock_) { this->lock_->set_sync_state(synced); } + + if (this->f_sync) { + this->f_sync(synced); + } } void GDOComponent::dump_config() { diff --git a/components/secplus_gdo/secplus_gdo.h b/components/secplus_gdo/secplus_gdo.h index 35eaeda..3e6652e 100644 --- a/components/secplus_gdo/secplus_gdo.h +++ b/components/secplus_gdo/secplus_gdo.h @@ -77,6 +77,9 @@ class GDOComponent : public Component { } } + + void register_sync(std::function f) { f_sync = f; } + void register_openings(std::function f) { f_openings = f; } void set_openings(uint16_t openings) { if (f_openings) { @@ -153,6 +156,7 @@ class GDOComponent : public Component { std::function f_obstruction{nullptr}; std::function f_button{nullptr}; std::function f_motor{nullptr}; + std::function f_sync{nullptr}; GDODoor *door_{nullptr}; GDOLight *light_{nullptr}; GDOLock *lock_{nullptr};