Skip to content

Commit e5ec9a2

Browse files
breakingspellGelidusResearch
authored andcommitted
Dry Contact Limit sensor improvements (ratgdo#398)
Use the limit sensors to determine if door action should be ignored Set door position when limit sensors are triggered
1 parent 50a5786 commit e5ec9a2

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

components/ratgdo/dry_contact.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ namespace ratgdo {
9090

9191
void DryContact::door_action(DoorAction action)
9292
{
93-
if (action == DoorAction::OPEN && this->door_state_ != DoorState::CLOSED) {
94-
ESP_LOGW(TAG, "The door is not closed. Ignoring door action: %s", DoorAction_to_string(action));
93+
if (action == DoorAction::OPEN && this->open_limit_reached_) {
94+
ESP_LOGW(TAG, "The door is already fully open. Ignoring door action: %s", LOG_STR_ARG(DoorAction_to_string(action)));
9595
return;
9696
}
97-
if (action == DoorAction::CLOSE && this->door_state_ != DoorState::OPEN) {
98-
ESP_LOGW(TAG, "The door is not open. Ignoring door action: %s", DoorAction_to_string(action));
97+
if (action == DoorAction::CLOSE && this->close_limit_reached_) {
98+
ESP_LOGW(TAG, "The door is already fully closed. Ignoring door action: %s", LOG_STR_ARG(DoorAction_to_string(action)));
9999
return;
100100
}
101101

components/ratgdo/ratgdo.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,7 @@ namespace ratgdo {
923923
dry_contact_open_sensor_ = dry_contact_open_sensor;
924924
dry_contact_open_sensor_->add_on_state_callback([this](bool sensor_value) {
925925
this->protocol_->set_open_limit(sensor_value);
926+
this->door_position = 1.0;
926927
});
927928
}
928929

@@ -931,6 +932,7 @@ namespace ratgdo {
931932
dry_contact_close_sensor_ = dry_contact_close_sensor;
932933
dry_contact_close_sensor_->add_on_state_callback([this](bool sensor_value) {
933934
this->protocol_->set_close_limit(sensor_value);
935+
this->door_position = 0.0;
934936
});
935937
}
936938

0 commit comments

Comments
 (0)