Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions components/secplus_gdo/secplus_gdo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,30 @@ namespace secplus_gdo {
ESP_LOGCONFIG(TAG, "Setting up secplus GDO ...");
}

// Motion is a Security+2.0-only feature; the Security+1.0 protocol has no motion
// command. gdolib's protocol probe can transiently run the Security+2.0 decoder
// against a Security+1.0 bus (konnected-io/gdolib#30), where a corrupt frame can
// decode as GDO_CMD_MOTION. A single publish here is unrecoverable downstream: the
// cloud infers a motion sensor exists the moment this entity leaves its "unknown"
// state, so leaving it unpublished is strictly safer than publishing a guess.
void GDOComponent::set_motion_state(gdo_motion_state_t state) {
if (!this->f_motion) {
return;
}

if (!this->synced_ || this->protocol_ != GDO_PROTOCOL_SEC_PLUS_V2) {
ESP_LOGW(TAG, "Ignoring motion state %s; not synced on Security+2.0 (synced: %s, protocol: %s)",
gdo_motion_state_to_string(state), this->synced_ ? "true" : "false",
gdo_protocol_type_to_string(this->protocol_));
return;
}

this->f_motion(state == GDO_MOTION_STATE_DETECTED);
}

void GDOComponent::set_sync_state(bool synced) {
this->synced_ = synced;

if (this->door_) {
this->door_->set_sync_state(synced);
}
Expand Down
11 changes: 8 additions & 3 deletions components/secplus_gdo/secplus_gdo.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,15 @@ namespace secplus_gdo {
float get_setup_priority() const override { return setup_priority::BEFORE_CONNECTION; }

void register_protocol_select(GDOSelect *select) { this->protocol_select_ = select; }
void set_protocol_state(gdo_protocol_type_t protocol) { if (this->protocol_select_) {
this->protocol_select_->update_state(protocol); }
void set_protocol_state(gdo_protocol_type_t protocol) {
this->protocol_ = protocol;
if (this->protocol_select_) {
this->protocol_select_->update_state(protocol);
}
}

void register_motion(std::function<void(bool)> f) { f_motion = f; }
void set_motion_state(gdo_motion_state_t state) { if (f_motion) { f_motion(state == GDO_MOTION_STATE_DETECTED); } }
void set_motion_state(gdo_motion_state_t state);

void register_obstruction(std::function<void(bool)> f) { f_obstruction = f; }
void set_obstruction(gdo_obstruction_state_t state) {
Expand Down Expand Up @@ -118,6 +121,8 @@ namespace secplus_gdo {
GDOSwitch* learn_switch_{nullptr};
GDOSwitch* toggle_only_switch_{nullptr};
bool start_gdo_{false};
bool synced_{false};
gdo_protocol_type_t protocol_{GDO_PROTOCOL_MAX};

}; // GDOComponent
} // namespace secplus_gdo
Expand Down
Loading