Skip to content

Commit

Permalink
Add synced state binary sensor.
Browse files Browse the repository at this point in the history
  • Loading branch information
GelidusResearch committed Sep 10, 2024
1 parent 4217635 commit c3ef753
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions components/secplus_gdo/binary_sensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"obstruction": "register_obstruction",
"motor": "register_motor",
"button": "register_button",
"sync": "register_sync",
}


Expand Down
4 changes: 4 additions & 0 deletions components/secplus_gdo/secplus_gdo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 4 additions & 0 deletions components/secplus_gdo/secplus_gdo.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ class GDOComponent : public Component {
}
}


void register_sync(std::function<void(bool)> f) { f_sync = f; }

void register_openings(std::function<void(uint16_t)> f) { f_openings = f; }
void set_openings(uint16_t openings) {
if (f_openings) {
Expand Down Expand Up @@ -153,6 +156,7 @@ class GDOComponent : public Component {
std::function<void(bool)> f_obstruction{nullptr};
std::function<void(bool)> f_button{nullptr};
std::function<void(bool)> f_motor{nullptr};
std::function<void(bool)> f_sync{nullptr};
GDODoor *door_{nullptr};
GDOLight *light_{nullptr};
GDOLock *lock_{nullptr};
Expand Down

0 comments on commit c3ef753

Please sign in to comment.