Updates, fixes, improvements

This commit is contained in:
Marius Muja 2024-01-11 14:25:51 -08:00
parent 0f64dc92d1
commit 65dfae4d0a
5 changed files with 31 additions and 19 deletions

View File

@ -21,7 +21,7 @@ ratgdo:
service: persistent_notification.create
data:
title: "${friendly_name} sync failed"
message: "Failed to communicate with garage opener on startup; Check the ${friendly_name} Rolling code counter number entity history and set the entity to one number larger than the largest value in history. [ESPHome devices](/config/devices/dashboard?domain=esphome)"
message: "Failed to communicate with garage opener on startup."
notification_id: "esphome_ratgdo_${id_prefix}_sync_failed"
api:
services:

View File

@ -22,7 +22,7 @@ ratgdo:
service: persistent_notification.create
data:
title: "${friendly_name} sync failed"
message: "Failed to communicate with garage opener on startup; Check the ${friendly_name} Rolling code counter number entity history and set the entity to one number larger than the largest value in history. [ESPHome devices](/config/devices/dashboard?domain=esphome)"
message: "Failed to communicate with garage opener on startup."
notification_id: "esphome_ratgdo_${id_prefix}_sync_failed"
sensor:

View File

@ -45,6 +45,13 @@ namespace secplus1 {
wall_panel_emulation_start_ = millis();
this->scheduler_->cancel_timeout(this->ratgdo_, "wall_panel_emulation");
this->wall_panel_emulation();
this->scheduler_->set_timeout(this->ratgdo_, "", 40000, [=] {
if (this->door_state == DoorState::UNKNOWN) {
ESP_LOGW(TAG, "Triggering sync failed actions.");
this->ratgdo_->sync_failed = true;
}
});
}
void Secplus1::wall_panel_emulation(size_t index)
@ -79,11 +86,12 @@ namespace secplus1 {
void Secplus1::light_action(LightAction action)
{
ESP_LOG1(TAG, "Light action: %s", LightAction_to_string(action));
if (action == LightAction::UNKNOWN) {
return;
}
if (this->light_state == LightState::UNKNOWN) {
ESP_LOG1(TAG, "Unknown current light state, ignoring command: %s", LightAction_to_string(action));
ESP_LOGW(TAG, "Unknown current light state, ignoring command: %s", LightAction_to_string(action));
// TODO: request state?
}
if (action == LightAction::TOGGLE ||
@ -95,11 +103,12 @@ namespace secplus1 {
void Secplus1::lock_action(LockAction action)
{
ESP_LOG1(TAG, "Lock action: %s", LockAction_to_string(action));
if (action == LockAction::UNKNOWN) {
return;
}
if (this->lock_state == LockState::UNKNOWN) {
ESP_LOG1(TAG, "Unknown current lock state, ignoring command: %s", LockAction_to_string(action));
ESP_LOGW(TAG, "Unknown current lock state, ignoring command: %s", LockAction_to_string(action));
// TODO: request state?
}
if (action == LockAction::TOGGLE ||
@ -111,11 +120,14 @@ namespace secplus1 {
void Secplus1::door_action(DoorAction action)
{
ESP_LOG1(TAG, "Door action: %s, door state: %s", DoorAction_to_string(action), DoorState_to_string(this->door_state));
if (this->door_state == DoorState::UNKNOWN) {
ESP_LOG1(TAG, "Unknown current door state, ignoring command: %s", DoorAction_to_string(action));
ESP_LOGW(TAG, "Unknown current door state, ignoring command: %s", DoorAction_to_string(action));
// TODO: request state?
}
const uint32_t double_toggle_delay = 1000;
if (action == DoorAction::UNKNOWN) {
return;
} else if (action == DoorAction::TOGGLE) {
@ -123,26 +135,32 @@ namespace secplus1 {
} else if (action == DoorAction::OPEN) {
if (this->door_state == DoorState::CLOSED || this->door_state == DoorState::CLOSING) {
this->transmit_packet(toggle_door);
} else if (this->door_state == DoorState::STOPPED) {
this->transmit_packet(toggle_door); // this starts closing door
// this changes direction of door
this->scheduler_->set_timeout(this->ratgdo_, "", double_toggle_delay, [=] {
this->transmit_packet(toggle_door);
});
}
} else if (action == DoorAction::CLOSE) {
if (this->door_state == DoorState::OPEN) {
this->transmit_packet(toggle_door);
}
if (this->door_state == DoorState::OPENING) {
} else if (this->door_state == DoorState::OPENING) {
this->transmit_packet(toggle_door); // this switches to stopped
// another toggle needed to close
this->scheduler_->set_timeout(this->ratgdo_, "", 500, [=] {
this->scheduler_->set_timeout(this->ratgdo_, "", double_toggle_delay, [=] {
this->transmit_packet(toggle_door);
});
} else if (this->door_state == DoorState::STOPPED) {
this->transmit_packet(toggle_door);
}
} else if (action == DoorAction::STOP) {
if (this->door_state == DoorState::OPENING) {
this->transmit_packet(toggle_door);
}
if (this->door_state == DoorState::CLOSING) {
} else if (this->door_state == DoorState::CLOSING) {
this->transmit_packet(toggle_door); // this switches to opening
// another toggle needed to stop
this->scheduler_->set_timeout(this->ratgdo_, "", 500, [=] {
this->scheduler_->set_timeout(this->ratgdo_, "", double_toggle_delay, [=] {
this->transmit_packet(toggle_door);
});
}

View File

@ -106,7 +106,7 @@ namespace secplus2 {
}
if (r == 0) {
// this was last attempt, notify of sync failure
ESP_LOGD(TAG, "Triggering sync failed actions.");
ESP_LOGW(TAG, "Triggering sync failed actions.");
this->ratgdo_->sync_failed = true;
}
}
@ -515,11 +515,6 @@ namespace secplus2 {
this->rolling_code_counter_ = counter;
}
observable<uint32_t>& Secplus2::get_rolling_code_counter()
{
return this->rolling_code_counter_;
}
void Secplus2::set_client_id(uint64_t client_id)
{
this->client_id_ = client_id & 0xFFFFFFFF;

View File

@ -87,7 +87,6 @@ namespace secplus2 {
void increment_rolling_code_counter(int delta = 1);
void set_rolling_code_counter(uint32_t counter);
observable<uint32_t>& get_rolling_code_counter();
void set_client_id(uint64_t client_id);
protected: