Skip to content

Commit

Permalink
Add synced state binary sensor.
Browse files Browse the repository at this point in the history
  • Loading branch information
h2zero committed Jul 7, 2024
1 parent 308fa95 commit 0970e88
Show file tree
Hide file tree
Showing 5 changed files with 15 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 @@ -164,6 +164,10 @@ namespace secplus_gdo {
if (this->lock_) {
this->lock_->set_sync_state(synced);
}

if (this->f_sync) {
this->f_sync(synced);
}
}

} // namespace secplus_gdo
Expand Down
3 changes: 3 additions & 0 deletions components/secplus_gdo/secplus_gdo.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ namespace secplus_gdo {
void register_motor(std::function<void(bool)> f) { f_motor = f; }
void set_motor_state(gdo_motor_state_t state) { if (f_motor) { f_motor(state == GDO_MOTOR_STATE_ON); } }

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) { f_openings(openings); } }

Expand Down Expand Up @@ -99,6 +101,7 @@ namespace secplus_gdo {
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
1 change: 1 addition & 0 deletions garage-door-GDOv2-Q.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ substitutions:
garage_obstruction_name: Obstruction
garage_motor_name: Motor
garage_button_name: Wall Button
garage_sync_name: Synced


####
Expand Down
6 changes: 6 additions & 0 deletions packages/secplus-gdo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ binary_sensor:
id: gdo_button
secplus_gdo_id: gdo_blaq
type: button
- platform: secplus_gdo
name: $garage_sync_name
id: gdo_synced
secplus_gdo_id: gdo_blaq
type: sync
device_class: connectivity

switch:
- platform: secplus_gdo
Expand Down

0 comments on commit 0970e88

Please sign in to comment.