2024-01-19 23:24:16 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "SoftwareSerial.h" // Using espsoftwareserial https://github.com/plerup/espsoftwareserial
|
|
|
|
#include "esphome/core/optional.h"
|
2024-04-17 20:17:29 +00:00
|
|
|
#include "esphome/core/gpio.h"
|
|
|
|
#include "esphome/components/gpio/binary_sensor/gpio_binary_sensor.h"
|
2024-01-19 23:24:16 +00:00
|
|
|
|
|
|
|
#include "callbacks.h"
|
|
|
|
#include "observable.h"
|
|
|
|
#include "protocol.h"
|
|
|
|
#include "ratgdo_state.h"
|
|
|
|
|
|
|
|
namespace esphome {
|
|
|
|
|
|
|
|
class Scheduler;
|
|
|
|
class InternalGPIOPin;
|
|
|
|
|
|
|
|
namespace ratgdo {
|
|
|
|
namespace dry_contact {
|
|
|
|
|
|
|
|
using namespace esphome::ratgdo::protocol;
|
2024-04-17 20:17:29 +00:00
|
|
|
using namespace esphome::gpio;
|
2024-01-19 23:24:16 +00:00
|
|
|
|
|
|
|
class DryContact : public Protocol {
|
|
|
|
public:
|
|
|
|
void setup(RATGDOComponent* ratgdo, Scheduler* scheduler, InternalGPIOPin* rx_pin, InternalGPIOPin* tx_pin);
|
|
|
|
void loop();
|
|
|
|
void dump_config();
|
|
|
|
|
|
|
|
void sync();
|
|
|
|
|
|
|
|
void light_action(LightAction action);
|
|
|
|
void lock_action(LockAction action);
|
|
|
|
void door_action(DoorAction action);
|
2024-04-17 20:17:29 +00:00
|
|
|
void set_open_limit(bool state);
|
|
|
|
void set_close_limit(bool state);
|
|
|
|
void send_door_state();
|
|
|
|
|
|
|
|
void set_discrete_open_pin(InternalGPIOPin* pin) {
|
|
|
|
this->discrete_open_pin_ = pin;
|
|
|
|
this->discrete_open_pin_->setup();
|
|
|
|
this->discrete_open_pin_->pin_mode(gpio::FLAG_OUTPUT);
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_discrete_close_pin(InternalGPIOPin* pin) {
|
|
|
|
this->discrete_close_pin_ = pin;
|
|
|
|
this->discrete_close_pin_->setup();
|
|
|
|
this->discrete_close_pin_->pin_mode(gpio::FLAG_OUTPUT);
|
|
|
|
}
|
2024-01-19 23:24:16 +00:00
|
|
|
|
|
|
|
Result call(Args args);
|
|
|
|
|
|
|
|
const Traits& traits() const { return this->traits_; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Traits traits_;
|
|
|
|
|
|
|
|
InternalGPIOPin* tx_pin_;
|
|
|
|
InternalGPIOPin* rx_pin_;
|
2024-04-17 20:17:29 +00:00
|
|
|
InternalGPIOPin* discrete_open_pin_;
|
|
|
|
InternalGPIOPin* discrete_close_pin_;
|
2024-01-19 23:24:16 +00:00
|
|
|
|
|
|
|
RATGDOComponent* ratgdo_;
|
|
|
|
Scheduler* scheduler_;
|
2024-04-17 20:17:29 +00:00
|
|
|
|
|
|
|
DoorState door_state_;
|
|
|
|
bool open_limit_reached_;
|
|
|
|
bool last_open_limit_;
|
|
|
|
bool close_limit_reached_;
|
|
|
|
bool last_close_limit_;
|
|
|
|
|
2024-01-19 23:24:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace secplus1
|
|
|
|
} // namespace ratgdo
|
|
|
|
} // namespace esphome
|