diff --git a/components/ratgdo/protocol.h b/components/ratgdo/protocol.h index 325c6ea..ca49aeb 100644 --- a/components/ratgdo/protocol.h +++ b/components/ratgdo/protocol.h @@ -102,9 +102,10 @@ namespace ratgdo { virtual void dump_config(); virtual void sync(); + + // dry contact methods virtual void set_open_limit(bool); virtual void set_close_limit(bool); - virtual void set_discrete_open_pin(InternalGPIOPin* pin); virtual void set_discrete_close_pin(InternalGPIOPin* pin); diff --git a/components/ratgdo/ratgdo.cpp b/components/ratgdo/ratgdo.cpp index eb26bf1..199a685 100644 --- a/components/ratgdo/ratgdo.cpp +++ b/components/ratgdo/ratgdo.cpp @@ -418,16 +418,13 @@ namespace ratgdo { void RATGDOComponent::sync() { this->protocol_->sync(); - } - void RATGDOComponent::set_open_limit(bool state) - { - this->protocol_->set_open_limit(state); - } - - void RATGDOComponent::set_close_limit(bool state) - { - this->protocol_->set_close_limit(state); + // dry contact protocol: + // needed to trigger the intial state of the limit switch sensors + // ideally this would be in drycontact::sync + // this->dry_contact_open_sensor_->state; + this->protocol_->set_open_limit(this->dry_contact_open_sensor_->state); + this->protocol_->set_close_limit(this->dry_contact_close_sensor_->state); } void RATGDOComponent::door_open() @@ -683,21 +680,23 @@ namespace ratgdo { this->learn_state.subscribe([=](LearnState state) { defer("learn_state", [=] { f(state); }); }); } + // dry contact methods void RATGDOComponent::set_dry_contact_open_sensor(esphome::gpio::GPIOBinarySensor* dry_contact_open_sensor) { dry_contact_open_sensor_ = dry_contact_open_sensor; dry_contact_open_sensor_->add_on_state_callback([this](bool sensor_value) { - this->set_open_limit(sensor_value); + this->protocol_->set_open_limit(sensor_value); } ); } + void RATGDOComponent::set_dry_contact_close_sensor(esphome::gpio::GPIOBinarySensor* dry_contact_close_sensor) { dry_contact_close_sensor_ = dry_contact_close_sensor; dry_contact_close_sensor_->add_on_state_callback([this](bool sensor_value) { - this->set_close_limit(sensor_value); + this->protocol_->set_close_limit(sensor_value); } ); } diff --git a/components/ratgdo/ratgdo.h b/components/ratgdo/ratgdo.h index 2c9ac61..fbb92b1 100644 --- a/components/ratgdo/ratgdo.h +++ b/components/ratgdo/ratgdo.h @@ -92,9 +92,9 @@ namespace ratgdo { void set_input_gdo_pin(InternalGPIOPin* pin) { this->input_gdo_pin_ = pin; } void set_input_obst_pin(InternalGPIOPin* pin) { this->input_obst_pin_ = pin; } + // dry contact methods void set_dry_contact_open_sensor(esphome::gpio::GPIOBinarySensor* dry_contact_open_sensor_); void set_dry_contact_close_sensor(esphome::gpio::GPIOBinarySensor* dry_contact_close_sensor_); - void set_discrete_open_pin(InternalGPIOPin* pin){ this->protocol_->set_discrete_open_pin(pin); } void set_discrete_close_pin(InternalGPIOPin* pin){ this->protocol_->set_discrete_close_pin(pin); } @@ -152,8 +152,6 @@ namespace ratgdo { void query_status(); void query_openings(); void sync(); - void set_open_limit(bool); - void set_close_limit(bool); // children subscriptions void subscribe_rolling_code_counter(std::function&& f); diff --git a/components/ratgdo/secplus1.h b/components/ratgdo/secplus1.h index 42d83fd..c2cd5d9 100644 --- a/components/ratgdo/secplus1.h +++ b/components/ratgdo/secplus1.h @@ -96,6 +96,13 @@ namespace ratgdo { const Traits& traits() const { return this->traits_; } + // methods not used by secplus1 + void set_open_limit(bool state){} + void set_close_limit(bool state){} + void set_discrete_open_pin(InternalGPIOPin* pin){} + void set_discrete_close_pin(InternalGPIOPin* pin){} + + protected: void wall_panel_emulation(size_t index = 0); diff --git a/components/ratgdo/secplus2.h b/components/ratgdo/secplus2.h index a30747d..6ea02b9 100644 --- a/components/ratgdo/secplus2.h +++ b/components/ratgdo/secplus2.h @@ -101,6 +101,12 @@ namespace ratgdo { const Traits& traits() const { return this->traits_; } + // methods not used by secplus2 + void set_open_limit(bool state){} + void set_close_limit(bool state){} + void set_discrete_open_pin(InternalGPIOPin* pin){} + void set_discrete_close_pin(InternalGPIOPin* pin){} + protected: void increment_rolling_code_counter(int delta = 1); void set_rolling_code_counter(uint32_t counter);