diff --git a/base.yml b/base.yml index a5c31f0..575f26a 100644 --- a/base.yml +++ b/base.yml @@ -21,6 +21,26 @@ external_components: ratgdo: id: ${id_prefix} + + +switch: + - platform: gpio + id: "${id_prefix}_status_door" + pin: + number: D0 # D0 output door status, HIGH for open, LOW for closed + mode: + output: true + name: "${friendly_name} Status Door" + entity_category: diagnostic + - platform: gpio + id: "${id_prefix}_status_obstruction" + pin: + number: D8 # D8 output for obstruction status, HIGH for obstructed, LOW for clear + mode: + output: true + name: "${friendly_name} Status Obstruction" + entity_category: diagnostic + binary_sensor: - platform: ratgdo type: motion @@ -34,6 +54,10 @@ binary_sensor: ratgdo_id: ${id_prefix} name: "${friendly_name} Obstruction" device_class: problem + on_press: + - switch.turn_on: ${id_prefix}_status_obstruction + on_release: + - switch.turn_off: ${id_prefix}_status_obstruction - platform: ratgdo type: motor id: ${id_prefix}_motor @@ -102,6 +126,10 @@ cover: device_class: garage name: ${friendly_name} ratgdo_id: ${id_prefix} + on_closed: + - switch.turn_off: ${id_prefix}_status_door + on_opened: + - switch.turn_on: ${id_prefix}_status_door light: diff --git a/components/ratgdo/ratgdo.cpp b/components/ratgdo/ratgdo.cpp index efe0bd0..70e97f9 100644 --- a/components/ratgdo/ratgdo.cpp +++ b/components/ratgdo/ratgdo.cpp @@ -44,14 +44,8 @@ namespace ratgdo { this->input_gdo_pin_->setup(); this->input_obst_pin_->setup(); - this->status_door_pin_->setup(); - this->status_obst_pin_->setup(); - this->store_.input_obst = this->input_obst_pin_->to_isr(); - this->status_door_pin_->pin_mode(gpio::FLAG_OUTPUT); - this->status_obst_pin_->pin_mode(gpio::FLAG_OUTPUT); - this->output_gdo_pin_->pin_mode(gpio::FLAG_OUTPUT); this->input_gdo_pin_->pin_mode(gpio::FLAG_INPUT | gpio::FLAG_PULLUP); this->input_obst_pin_->pin_mode(gpio::FLAG_INPUT); @@ -316,7 +310,6 @@ namespace ratgdo { for (auto* child : this->children_) { child->on_door_state(val); } - this->status_door_pin_->digital_write(this->doorState == 1); } void RATGDOComponent::sendLightStatus() @@ -362,7 +355,6 @@ namespace ratgdo { for (auto* child : this->children_) { child->on_obstruction_state(val); } - this->status_obst_pin_->digital_write(this->obstructionState == 0); } /************************* DOOR COMMUNICATION *************************/ diff --git a/components/ratgdo/ratgdo.h b/components/ratgdo/ratgdo.h index 4183802..78fb5e8 100644 --- a/components/ratgdo/ratgdo.h +++ b/components/ratgdo/ratgdo.h @@ -73,9 +73,6 @@ namespace ratgdo { int obstructionLowCount = 0; // count obstruction low pulses long lastObstructionHigh = 0; // count time between high pulses from the obst ISR - static void IRAM_ATTR isrDoorOpen(RATGDOStore* arg); - static void IRAM_ATTR isrDoorClose(RATGDOStore* arg); - static void IRAM_ATTR isrLight(RATGDOStore* arg); static void IRAM_ATTR isrObstruction(RATGDOStore* arg); }; @@ -107,9 +104,6 @@ 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; }; - void set_status_door_pin(InternalGPIOPin* pin) { this->status_door_pin_ = pin; }; - void set_status_obst_pin(InternalGPIOPin* pin) { this->status_obst_pin_ = pin; }; - /********************************** FUNCTION DECLARATION * *****************************************/ void transmit(cmd command); @@ -158,13 +152,9 @@ namespace ratgdo { RATGDOStore store_ {}; InternalGPIOPin* output_gdo_pin_; - InternalGPIOPin* input_gdo_pin_; InternalGPIOPin* input_obst_pin_; - InternalGPIOPin* status_door_pin_; - InternalGPIOPin* status_obst_pin_; - }; // RATGDOComponent } // namespace ratgdo