Updates, fixes, improvements
This commit is contained in:
parent
0f64dc92d1
commit
65dfae4d0a
|
@ -21,7 +21,7 @@ ratgdo:
|
||||||
service: persistent_notification.create
|
service: persistent_notification.create
|
||||||
data:
|
data:
|
||||||
title: "${friendly_name} sync failed"
|
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"
|
notification_id: "esphome_ratgdo_${id_prefix}_sync_failed"
|
||||||
api:
|
api:
|
||||||
services:
|
services:
|
||||||
|
|
|
@ -22,7 +22,7 @@ ratgdo:
|
||||||
service: persistent_notification.create
|
service: persistent_notification.create
|
||||||
data:
|
data:
|
||||||
title: "${friendly_name} sync failed"
|
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"
|
notification_id: "esphome_ratgdo_${id_prefix}_sync_failed"
|
||||||
|
|
||||||
sensor:
|
sensor:
|
||||||
|
|
|
@ -45,6 +45,13 @@ namespace secplus1 {
|
||||||
wall_panel_emulation_start_ = millis();
|
wall_panel_emulation_start_ = millis();
|
||||||
this->scheduler_->cancel_timeout(this->ratgdo_, "wall_panel_emulation");
|
this->scheduler_->cancel_timeout(this->ratgdo_, "wall_panel_emulation");
|
||||||
this->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)
|
void Secplus1::wall_panel_emulation(size_t index)
|
||||||
|
@ -79,11 +86,12 @@ namespace secplus1 {
|
||||||
|
|
||||||
void Secplus1::light_action(LightAction action)
|
void Secplus1::light_action(LightAction action)
|
||||||
{
|
{
|
||||||
|
ESP_LOG1(TAG, "Light action: %s", LightAction_to_string(action));
|
||||||
if (action == LightAction::UNKNOWN) {
|
if (action == LightAction::UNKNOWN) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this->light_state == LightState::UNKNOWN) {
|
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?
|
// TODO: request state?
|
||||||
}
|
}
|
||||||
if (action == LightAction::TOGGLE ||
|
if (action == LightAction::TOGGLE ||
|
||||||
|
@ -95,11 +103,12 @@ namespace secplus1 {
|
||||||
|
|
||||||
void Secplus1::lock_action(LockAction action)
|
void Secplus1::lock_action(LockAction action)
|
||||||
{
|
{
|
||||||
|
ESP_LOG1(TAG, "Lock action: %s", LockAction_to_string(action));
|
||||||
if (action == LockAction::UNKNOWN) {
|
if (action == LockAction::UNKNOWN) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this->lock_state == LockState::UNKNOWN) {
|
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?
|
// TODO: request state?
|
||||||
}
|
}
|
||||||
if (action == LockAction::TOGGLE ||
|
if (action == LockAction::TOGGLE ||
|
||||||
|
@ -111,11 +120,14 @@ namespace secplus1 {
|
||||||
|
|
||||||
void Secplus1::door_action(DoorAction action)
|
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) {
|
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?
|
// TODO: request state?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const uint32_t double_toggle_delay = 1000;
|
||||||
|
|
||||||
if (action == DoorAction::UNKNOWN) {
|
if (action == DoorAction::UNKNOWN) {
|
||||||
return;
|
return;
|
||||||
} else if (action == DoorAction::TOGGLE) {
|
} else if (action == DoorAction::TOGGLE) {
|
||||||
|
@ -123,26 +135,32 @@ namespace secplus1 {
|
||||||
} else if (action == DoorAction::OPEN) {
|
} else if (action == DoorAction::OPEN) {
|
||||||
if (this->door_state == DoorState::CLOSED || this->door_state == DoorState::CLOSING) {
|
if (this->door_state == DoorState::CLOSED || this->door_state == DoorState::CLOSING) {
|
||||||
this->transmit_packet(toggle_door);
|
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) {
|
} else if (action == DoorAction::CLOSE) {
|
||||||
if (this->door_state == DoorState::OPEN) {
|
if (this->door_state == DoorState::OPEN) {
|
||||||
this->transmit_packet(toggle_door);
|
this->transmit_packet(toggle_door);
|
||||||
}
|
} else if (this->door_state == DoorState::OPENING) {
|
||||||
if (this->door_state == DoorState::OPENING) {
|
|
||||||
this->transmit_packet(toggle_door); // this switches to stopped
|
this->transmit_packet(toggle_door); // this switches to stopped
|
||||||
// another toggle needed to close
|
// 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);
|
this->transmit_packet(toggle_door);
|
||||||
});
|
});
|
||||||
|
} else if (this->door_state == DoorState::STOPPED) {
|
||||||
|
this->transmit_packet(toggle_door);
|
||||||
}
|
}
|
||||||
} else if (action == DoorAction::STOP) {
|
} else if (action == DoorAction::STOP) {
|
||||||
if (this->door_state == DoorState::OPENING) {
|
if (this->door_state == DoorState::OPENING) {
|
||||||
this->transmit_packet(toggle_door);
|
this->transmit_packet(toggle_door);
|
||||||
}
|
} else if (this->door_state == DoorState::CLOSING) {
|
||||||
if (this->door_state == DoorState::CLOSING) {
|
|
||||||
this->transmit_packet(toggle_door); // this switches to opening
|
this->transmit_packet(toggle_door); // this switches to opening
|
||||||
// another toggle needed to stop
|
// 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);
|
this->transmit_packet(toggle_door);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,7 +106,7 @@ namespace secplus2 {
|
||||||
}
|
}
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
// this was last attempt, notify of sync failure
|
// 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;
|
this->ratgdo_->sync_failed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -515,11 +515,6 @@ namespace secplus2 {
|
||||||
this->rolling_code_counter_ = counter;
|
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)
|
void Secplus2::set_client_id(uint64_t client_id)
|
||||||
{
|
{
|
||||||
this->client_id_ = client_id & 0xFFFFFFFF;
|
this->client_id_ = client_id & 0xFFFFFFFF;
|
||||||
|
|
|
@ -87,7 +87,6 @@ namespace secplus2 {
|
||||||
|
|
||||||
void increment_rolling_code_counter(int delta = 1);
|
void increment_rolling_code_counter(int delta = 1);
|
||||||
void set_rolling_code_counter(uint32_t counter);
|
void set_rolling_code_counter(uint32_t counter);
|
||||||
observable<uint32_t>& get_rolling_code_counter();
|
|
||||||
void set_client_id(uint64_t client_id);
|
void set_client_id(uint64_t client_id);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
Loading…
Reference in New Issue