Merge branch 'main' into uptime

This commit is contained in:
J. Nick Koston 2024-07-02 17:59:48 -07:00 committed by GitHub
commit 3d414309ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
26 changed files with 68 additions and 70 deletions

View File

@ -7,3 +7,12 @@ repos:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.8
hooks:
- id: clang-format
types_or:
- "c++"
- "c"
- "cuda"
args: [-style=Webkit, -i]

View File

@ -6,6 +6,8 @@ external_components:
url: https://github.com/ratgdo/esphome-ratgdo
refresh: 1s
safe_mode:
preferences:
flash_write_interval: 1min
@ -45,6 +47,10 @@ api:
id($id_prefix).clear_paired_devices(ratgdo::PairedDevice::ACCESSORY);
}
ota:
- platform: esphome
id: ratgdo_ota
sensor:
- platform: uptime
name: Uptime Sensor

View File

@ -8,6 +8,8 @@ external_components:
url: https://github.com/ratgdo/esphome-ratgdo
refresh: 1s
safe_mode:
preferences:
flash_write_interval: 1min
@ -25,6 +27,10 @@ ratgdo:
discrete_close_pin: ${discrete_close_pin}
protocol: drycontact
ota:
- platform: esphome
id: ratgdo_ota
binary_sensor:
- platform: ratgdo
type: obstruction

View File

@ -6,6 +6,8 @@ external_components:
url: https://github.com/ratgdo/esphome-ratgdo
refresh: 1s
safe_mode:
preferences:
flash_write_interval: 1min
@ -28,6 +30,10 @@ ratgdo:
message: "Failed to communicate with garage opener on startup."
notification_id: "esphome_ratgdo_${id_prefix}_sync_failed"
ota:
- platform: esphome
id: ratgdo_ota
lock:
- platform: ratgdo
id: ${id_prefix}_lock_remotes

View File

@ -2,10 +2,10 @@
#include "dry_contact.h"
#include "ratgdo.h"
#include "esphome/components/gpio/binary_sensor/gpio_binary_sensor.h"
#include "esphome/core/gpio.h"
#include "esphome/core/log.h"
#include "esphome/core/scheduler.h"
#include "esphome/components/gpio/binary_sensor/gpio_binary_sensor.h"
namespace esphome {
namespace ratgdo {
@ -59,17 +59,18 @@ namespace ratgdo {
this->send_door_state();
}
void DryContact::send_door_state(){
if(this->open_limit_reached_){
void DryContact::send_door_state()
{
if (this->open_limit_reached_) {
this->door_state_ = DoorState::OPEN;
}else if(this->close_limit_reached_){
} else if (this->close_limit_reached_) {
this->door_state_ = DoorState::CLOSED;
}else if(!this->close_limit_reached_ && !this->open_limit_reached_){
if(this->last_close_limit_){
} else if (!this->close_limit_reached_ && !this->open_limit_reached_) {
if (this->last_close_limit_) {
this->door_state_ = DoorState::OPENING;
}
if(this->last_open_limit_){
if (this->last_open_limit_) {
this->door_state_ = DoorState::CLOSING;
}
}
@ -102,14 +103,14 @@ namespace ratgdo {
ESP_LOG1(TAG, "Door action: %s", DoorAction_to_string(action));
if (action == DoorAction::OPEN){
if (action == DoorAction::OPEN) {
this->discrete_open_pin_->digital_write(1);
this->scheduler_->set_timeout(this->ratgdo_, "", 500, [=] {
this->discrete_open_pin_->digital_write(0);
});
}
if (action == DoorAction::CLOSE){
if (action == DoorAction::CLOSE) {
this->discrete_close_pin_->digital_write(1);
this->scheduler_->set_timeout(this->ratgdo_, "", 500, [=] {
this->discrete_close_pin_->digital_write(0);

View File

@ -1,9 +1,9 @@
#pragma once
#include "SoftwareSerial.h" // Using espsoftwareserial https://github.com/plerup/espsoftwareserial
#include "esphome/core/optional.h"
#include "esphome/core/gpio.h"
#include "esphome/components/gpio/binary_sensor/gpio_binary_sensor.h"
#include "esphome/core/gpio.h"
#include "esphome/core/optional.h"
#include "callbacks.h"
#include "observable.h"
@ -36,13 +36,15 @@ namespace ratgdo {
void set_close_limit(bool state);
void send_door_state();
void set_discrete_open_pin(InternalGPIOPin* pin) {
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) {
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);
@ -68,7 +70,6 @@ namespace ratgdo {
bool last_open_limit_;
bool close_limit_reached_;
bool last_close_limit_;
};
} // namespace secplus1

View File

@ -690,21 +690,17 @@ namespace ratgdo {
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)
{
dry_contact_open_sensor_->add_on_state_callback([this](bool 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)
{
dry_contact_close_sensor_->add_on_state_callback([this](bool sensor_value) {
this->protocol_->set_close_limit(sensor_value);
}
);
});
}
} // namespace ratgdo

View File

@ -13,10 +13,10 @@
#pragma once
#include "esphome/components/gpio/binary_sensor/gpio_binary_sensor.h"
#include "esphome/core/component.h"
#include "esphome/core/hal.h"
#include "esphome/core/preferences.h"
#include "esphome/components/gpio/binary_sensor/gpio_binary_sensor.h"
#include "callbacks.h"
#include "macros.h"
@ -95,8 +95,8 @@ namespace ratgdo {
// 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); }
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); }
Result call_protocol(Args args);

View File

@ -97,11 +97,10 @@ 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){}
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);

View File

@ -102,10 +102,10 @@ 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){}
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);

View File

@ -41,8 +41,6 @@ time:
api:
id: api_server
ota:
improv_serial:
wifi:

View File

@ -41,8 +41,6 @@ time:
api:
id: api_server
ota:
improv_serial:
wifi:

View File

@ -42,8 +42,6 @@ time:
api:
id: api_server
ota:
improv_serial:
wifi:

View File

@ -42,8 +42,6 @@ time:
api:
id: api_server
ota:
improv_serial:
wifi:

View File

@ -42,8 +42,6 @@ time:
api:
id: api_server
ota:
improv_serial:
wifi:

View File

@ -42,8 +42,6 @@ time:
api:
id: api_server
ota:
improv_serial:
wifi:

View File

@ -42,8 +42,6 @@ time:
api:
id: api_server
ota:
improv_serial:
wifi:

View File

@ -42,8 +42,6 @@ time:
api:
id: api_server
ota:
improv_serial:
wifi:

View File

@ -42,8 +42,6 @@ time:
api:
id: api_server
ota:
improv_serial:
wifi:

View File

@ -41,8 +41,6 @@ time:
api:
id: api_server
ota:
improv_serial:
wifi:

View File

@ -41,8 +41,6 @@ time:
api:
id: api_server
ota:
improv_serial:
wifi:

View File

@ -42,8 +42,6 @@ time:
api:
id: api_server
ota:
improv_serial:
wifi:

View File

@ -42,8 +42,6 @@ time:
api:
id: api_server
ota:
improv_serial:
wifi: