diff --git a/base_drycontact.yaml b/base_drycontact.yaml index f3e4375..19f051b 100644 --- a/base_drycontact.yaml +++ b/base_drycontact.yaml @@ -87,11 +87,10 @@ binary_sensor: entity_category: diagnostic filters: - delayed_on_off: 500ms - # on_state: - # then: - # lambda: |- - # id($id_prefix)->call_protocol(set_open_limit { static_cast(true) }); - + on_state: + then: + lambda: |- + id($id_prefix)->set_open_limit(x); - platform: gpio id: "${id_prefix}_dry_contact_close" pin: @@ -104,12 +103,10 @@ binary_sensor: entity_category: diagnostic filters: - delayed_on_off: 500ms - # on_press: - # - if: - # condition: - # binary_sensor.is_off: ${id_prefix}_dry_contact_open - # then: - # - cover.close: ${id_prefix}_garage_door + on_state: + then: + lambda: |- + id($id_prefix)->set_close_limit(x); - platform: gpio id: "${id_prefix}_dry_contact_light" pin: diff --git a/components/ratgdo/dry_contact.cpp b/components/ratgdo/dry_contact.cpp index 776e063..e1fc4a9 100644 --- a/components/ratgdo/dry_contact.cpp +++ b/components/ratgdo/dry_contact.cpp @@ -36,21 +36,24 @@ namespace ratgdo { void DryContact::sync() { + ESP_LOG1(TAG, "Ignoring sync action"); } - void DryContact::set_open_limit(bool val) + void DryContact::set_open_limit(bool state) { - ESP_LOGD(TAG, "Set open_limit_reached to %d", val); + ESP_LOGD(TAG, "Set open_limit_reached to %d", state); this->last_open_limit_ = this->open_limit_reached_; - this->open_limit_reached_ = val; + this->last_close_limit_ = false; + this->open_limit_reached_ = state; this->send_door_state(); } - void DryContact::set_close_limit(bool val) + void DryContact::set_close_limit(bool state) { - ESP_LOGD(TAG, "Set close_limit_reached to %d", val); + ESP_LOGD(TAG, "Set close_limit_reached to %d", state); this->last_close_limit_ = this->close_limit_reached_; - this->close_limit_reached_ = val; + this->last_open_limit_ = false; + this->close_limit_reached_ = state; this->send_door_state(); } diff --git a/components/ratgdo/dry_contact.h b/components/ratgdo/dry_contact.h index 3f9643c..1a1f15d 100644 --- a/components/ratgdo/dry_contact.h +++ b/components/ratgdo/dry_contact.h @@ -29,8 +29,8 @@ namespace ratgdo { void light_action(LightAction action); void lock_action(LockAction action); void door_action(DoorAction action); - void set_open_limit(bool val); - void set_close_limit(bool val); + void set_open_limit(bool state); + void set_close_limit(bool state); void send_door_state(); Result call(Args args); diff --git a/components/ratgdo/protocol.h b/components/ratgdo/protocol.h index 8202079..f7a82e1 100644 --- a/components/ratgdo/protocol.h +++ b/components/ratgdo/protocol.h @@ -102,6 +102,8 @@ namespace ratgdo { virtual void dump_config(); virtual void sync(); + virtual void set_open_limit(bool); + virtual void set_close_limit(bool); virtual const Traits& traits() const; diff --git a/components/ratgdo/ratgdo.cpp b/components/ratgdo/ratgdo.cpp index f65ae25..32479e0 100644 --- a/components/ratgdo/ratgdo.cpp +++ b/components/ratgdo/ratgdo.cpp @@ -420,6 +420,16 @@ namespace ratgdo { 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); + } + void RATGDOComponent::door_open() { if (*this->door_state == DoorState::OPENING) { diff --git a/components/ratgdo/ratgdo.h b/components/ratgdo/ratgdo.h index 510f636..4e328a2 100644 --- a/components/ratgdo/ratgdo.h +++ b/components/ratgdo/ratgdo.h @@ -145,6 +145,8 @@ 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);