Do not clear problem state of sync on resync

This commit is contained in:
2026-05-29 17:26:24 +00:00
parent ecd6a42aee
commit 41507bb9d2
6 changed files with 14 additions and 6 deletions
+2 -2
View File
@@ -11,8 +11,8 @@ class SyncFailed : public Trigger<> {
public: public:
explicit SyncFailed(RATGDOComponent* parent) explicit SyncFailed(RATGDOComponent* parent)
{ {
parent->subscribe_sync_failed([this](bool state) { parent->subscribe_sync_failed([this](optional<bool> state) {
if (state) if (state.value_or(false))
this->trigger(); this->trigger();
}); });
} }
+1 -1
View File
@@ -26,7 +26,7 @@ void RATGDOCover::setup()
void RATGDOCover::on_door_state(DoorState state, float position) void RATGDOCover::on_door_state(DoorState state, float position)
{ {
if (state == DoorState::UNKNOWN) { if (!*this->parent_->synced || state == DoorState::UNKNOWN) {
return; return;
} }
// ESP_LOGD("ON_DOOR_STATE", "%s %f", LOG_STR_ARG(DoorState_to_string(state)), position); // ESP_LOGD("ON_DOOR_STATE", "%s %f", LOG_STR_ARG(DoorState_to_string(state)), position);
+9
View File
@@ -54,6 +54,15 @@ void RATGDOComponent::setup()
// many things happening at startup, use some delay for sync // many things happening at startup, use some delay for sync
this->set_timeout(SYNC_DELAY, [this] { this->sync(); }); this->set_timeout(SYNC_DELAY, [this] { this->sync(); });
this->synced.subscribe([this](bool is_synced) {
if (is_synced) {
this->door_state.notify();
this->light_state.notify();
this->lock_state.notify();
}
});
ESP_LOGD(TAG, " _____ _____ _____ _____ ____ _____ "); ESP_LOGD(TAG, " _____ _____ _____ _____ ____ _____ ");
ESP_LOGD(TAG, "| __ | _ |_ _| __| \\| |"); ESP_LOGD(TAG, "| __ | _ |_ _| __| \\| |");
ESP_LOGD(TAG, "| -| | | | | | | | | | |"); ESP_LOGD(TAG, "| -| | | | | | | | | | |");
+1 -1
View File
@@ -78,7 +78,7 @@ public:
OnceCallbacks<void(DoorState)> on_door_state_; OnceCallbacks<void(DoorState)> on_door_state_;
single_observable<bool> synced { false }; single_observable<bool> synced { false };
single_observable<bool> sync_failed { false }; single_observable<optional<bool>> sync_failed { nullopt };
void set_output_gdo_pin(InternalGPIOPin* pin) { this->output_gdo_pin_ = pin; } void set_output_gdo_pin(InternalGPIOPin* pin) { this->output_gdo_pin_ = pin; }
void set_input_gdo_pin(InternalGPIOPin* pin) { this->input_gdo_pin_ = pin; } void set_input_gdo_pin(InternalGPIOPin* pin) { this->input_gdo_pin_ = pin; }
-1
View File
@@ -163,7 +163,6 @@ namespace secplus2 {
{ {
ESP_LOGD(TAG, "Starting sync..."); ESP_LOGD(TAG, "Starting sync...");
this->ratgdo_->synced = false; this->ratgdo_->synced = false;
this->ratgdo_->sync_failed = false;
this->scheduler_->cancel_timeout(this->ratgdo_, TIMEOUT_SYNC); this->scheduler_->cancel_timeout(this->ratgdo_, TIMEOUT_SYNC);
this->sync_helper(millis(), 500, 0); this->sync_helper(millis(), 500, 0);
} }
+1 -1
View File
@@ -49,7 +49,7 @@ time:
binary_sensor: binary_sensor:
- platform: template - platform: template
name: "Sync failed" name: "Sync failed"
lambda: 'return !*id(garage_gate).synced;' lambda: 'return *id(garage_gate).sync_failed;'
device_class: problem device_class: problem
entity_category: diagnostic entity_category: diagnostic