Do not clear problem state of sync on resync
This commit is contained in:
@@ -11,8 +11,8 @@ class SyncFailed : public Trigger<> {
|
||||
public:
|
||||
explicit SyncFailed(RATGDOComponent* parent)
|
||||
{
|
||||
parent->subscribe_sync_failed([this](bool state) {
|
||||
if (state)
|
||||
parent->subscribe_sync_failed([this](optional<bool> state) {
|
||||
if (state.value_or(false))
|
||||
this->trigger();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ void RATGDOCover::setup()
|
||||
|
||||
void RATGDOCover::on_door_state(DoorState state, float position)
|
||||
{
|
||||
if (state == DoorState::UNKNOWN) {
|
||||
if (!*this->parent_->synced || state == DoorState::UNKNOWN) {
|
||||
return;
|
||||
}
|
||||
// ESP_LOGD("ON_DOOR_STATE", "%s %f", LOG_STR_ARG(DoorState_to_string(state)), position);
|
||||
|
||||
@@ -54,6 +54,15 @@ void RATGDOComponent::setup()
|
||||
|
||||
// many things happening at startup, use some delay for 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, "| -| | | | | | | | | | |");
|
||||
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
OnceCallbacks<void(DoorState)> on_door_state_;
|
||||
|
||||
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_input_gdo_pin(InternalGPIOPin* pin) { this->input_gdo_pin_ = pin; }
|
||||
|
||||
@@ -163,7 +163,6 @@ namespace secplus2 {
|
||||
{
|
||||
ESP_LOGD(TAG, "Starting sync...");
|
||||
this->ratgdo_->synced = false;
|
||||
this->ratgdo_->sync_failed = false;
|
||||
this->scheduler_->cancel_timeout(this->ratgdo_, TIMEOUT_SYNC);
|
||||
this->sync_helper(millis(), 500, 0);
|
||||
}
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ time:
|
||||
binary_sensor:
|
||||
- platform: template
|
||||
name: "Sync failed"
|
||||
lambda: 'return !*id(garage_gate).synced;'
|
||||
lambda: 'return *id(garage_gate).sync_failed;'
|
||||
device_class: problem
|
||||
entity_category: diagnostic
|
||||
|
||||
|
||||
Reference in New Issue
Block a user