Dry contact support (#255)
* Setting up dry contact protocol * limit switch implementation * setup door controls * Initial commit to make the component aware of the dry_contact sensors… (#249) Initial commit to make the component aware of the dry_contact sensors and eliminate the need for lamda calls Co-authored-by: bradmck <bradmck@gmail.com> * send both sensor values * removing irrelevant dry contact config * Add triple button (discrete) control for commercial openers & gates * point to git * Add dry contact to installer * rm whitespace * updated wiring diagram --------- Co-authored-by: bradmck <bradmck@gmail.com>
This commit is contained in:
parent
e3eacef44d
commit
7362f46aca
10
base.yaml
10
base.yaml
|
@ -73,7 +73,7 @@ switch:
|
||||||
id: "${id_prefix}_status_door"
|
id: "${id_prefix}_status_door"
|
||||||
internal: true
|
internal: true
|
||||||
pin:
|
pin:
|
||||||
number: ${status_door_pin} # D0 output door status, HIGH for open, LOW for closed
|
number: ${status_door_pin} # output door status, HIGH for open, LOW for closed
|
||||||
mode:
|
mode:
|
||||||
output: true
|
output: true
|
||||||
name: "Status door"
|
name: "Status door"
|
||||||
|
@ -82,7 +82,7 @@ switch:
|
||||||
id: "${id_prefix}_status_obstruction"
|
id: "${id_prefix}_status_obstruction"
|
||||||
internal: true
|
internal: true
|
||||||
pin:
|
pin:
|
||||||
number: ${status_obstruction_pin} # D8 output for obstruction status, HIGH for obstructed, LOW for clear
|
number: ${status_obstruction_pin} # output for obstruction status, HIGH for obstructed, LOW for clear
|
||||||
mode:
|
mode:
|
||||||
output: true
|
output: true
|
||||||
name: "Status obstruction"
|
name: "Status obstruction"
|
||||||
|
@ -128,7 +128,7 @@ binary_sensor:
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
id: "${id_prefix}_dry_contact_open"
|
id: "${id_prefix}_dry_contact_open"
|
||||||
pin:
|
pin:
|
||||||
number: ${dry_contact_open_pin} # D5 dry contact for opening door
|
number: ${dry_contact_open_pin} # dry contact for opening door
|
||||||
inverted: true
|
inverted: true
|
||||||
mode:
|
mode:
|
||||||
input: true
|
input: true
|
||||||
|
@ -146,7 +146,7 @@ binary_sensor:
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
id: "${id_prefix}_dry_contact_close"
|
id: "${id_prefix}_dry_contact_close"
|
||||||
pin:
|
pin:
|
||||||
number: ${dry_contact_close_pin} # D6 dry contact for closing door
|
number: ${dry_contact_close_pin} # dry contact for closing door
|
||||||
inverted: true
|
inverted: true
|
||||||
mode:
|
mode:
|
||||||
input: true
|
input: true
|
||||||
|
@ -164,7 +164,7 @@ binary_sensor:
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
id: "${id_prefix}_dry_contact_light"
|
id: "${id_prefix}_dry_contact_light"
|
||||||
pin:
|
pin:
|
||||||
number: ${dry_contact_light_pin} # D3 dry contact for triggering light (no discrete light commands, so toggle only)
|
number: ${dry_contact_light_pin} # dry contact for triggering light (no discrete light commands, so toggle only)
|
||||||
inverted: true
|
inverted: true
|
||||||
mode:
|
mode:
|
||||||
input: true
|
input: true
|
||||||
|
|
|
@ -0,0 +1,95 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
external_components:
|
||||||
|
- source:
|
||||||
|
# type: local
|
||||||
|
# path: components
|
||||||
|
type: git
|
||||||
|
url: https://github.com/ratgdo/esphome-ratgdo
|
||||||
|
refresh: 1s
|
||||||
|
|
||||||
|
preferences:
|
||||||
|
flash_write_interval: 1min
|
||||||
|
|
||||||
|
ratgdo:
|
||||||
|
id: ${id_prefix}
|
||||||
|
output_gdo_pin: ${uart_tx_pin}
|
||||||
|
input_obst_pin: ${input_obst_pin}
|
||||||
|
dry_contact_open_sensor: ${id_prefix}_dry_contact_open
|
||||||
|
dry_contact_close_sensor: ${id_prefix}_dry_contact_close
|
||||||
|
discrete_open_pin: ${discrete_open_pin}
|
||||||
|
discrete_close_pin: ${discrete_close_pin}
|
||||||
|
protocol: drycontact
|
||||||
|
|
||||||
|
binary_sensor:
|
||||||
|
- platform: ratgdo
|
||||||
|
type: obstruction
|
||||||
|
id: ${id_prefix}_obstruction
|
||||||
|
ratgdo_id: ${id_prefix}
|
||||||
|
name: "Obstruction"
|
||||||
|
device_class: problem
|
||||||
|
- platform: gpio
|
||||||
|
id: "${id_prefix}_dry_contact_open"
|
||||||
|
pin:
|
||||||
|
number: ${dry_contact_open_pin}
|
||||||
|
inverted: true
|
||||||
|
mode:
|
||||||
|
input: true
|
||||||
|
pullup: true
|
||||||
|
name: "Open limit switch"
|
||||||
|
entity_category: diagnostic
|
||||||
|
filters:
|
||||||
|
- delayed_on_off: 500ms
|
||||||
|
- platform: gpio
|
||||||
|
id: "${id_prefix}_dry_contact_close"
|
||||||
|
pin:
|
||||||
|
number: ${dry_contact_close_pin}
|
||||||
|
inverted: true
|
||||||
|
mode:
|
||||||
|
input: true
|
||||||
|
pullup: true
|
||||||
|
name: "Close limit switch"
|
||||||
|
entity_category: diagnostic
|
||||||
|
filters:
|
||||||
|
- delayed_on_off: 500ms
|
||||||
|
|
||||||
|
number:
|
||||||
|
- platform: ratgdo
|
||||||
|
id: ${id_prefix}_opening_duration
|
||||||
|
type: opening_duration
|
||||||
|
entity_category: config
|
||||||
|
ratgdo_id: ${id_prefix}
|
||||||
|
name: "Opening duration"
|
||||||
|
unit_of_measurement: "s"
|
||||||
|
|
||||||
|
- platform: ratgdo
|
||||||
|
id: ${id_prefix}_closing_duration
|
||||||
|
type: closing_duration
|
||||||
|
entity_category: config
|
||||||
|
ratgdo_id: ${id_prefix}
|
||||||
|
name: "Closing duration"
|
||||||
|
unit_of_measurement: "s"
|
||||||
|
|
||||||
|
cover:
|
||||||
|
- platform: ratgdo
|
||||||
|
id: ${id_prefix}_garage_door
|
||||||
|
device_class: garage
|
||||||
|
name: "Door"
|
||||||
|
ratgdo_id: ${id_prefix}
|
||||||
|
|
||||||
|
button:
|
||||||
|
- platform: restart
|
||||||
|
id: ${id_prefix}_restart
|
||||||
|
name: "Restart"
|
||||||
|
- platform: safe_mode
|
||||||
|
id: ${id_prefix}_safe_mode
|
||||||
|
name: "Safe mode boot"
|
||||||
|
entity_category: diagnostic
|
||||||
|
|
||||||
|
- platform: template
|
||||||
|
id: ${id_prefix}_toggle_door
|
||||||
|
name: "Toggle door"
|
||||||
|
on_press:
|
||||||
|
then:
|
||||||
|
lambda: !lambda |-
|
||||||
|
id($id_prefix).door_toggle();
|
|
@ -3,6 +3,7 @@ import esphome.config_validation as cv
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
from esphome import automation, pins
|
from esphome import automation, pins
|
||||||
from esphome.const import CONF_ID, CONF_TRIGGER_ID
|
from esphome.const import CONF_ID, CONF_TRIGGER_ID
|
||||||
|
from esphome.components import binary_sensor
|
||||||
|
|
||||||
DEPENDENCIES = ["preferences"]
|
DEPENDENCIES = ["preferences"]
|
||||||
MULTI_CONF = True
|
MULTI_CONF = True
|
||||||
|
@ -25,6 +26,9 @@ DEFAULT_INPUT_GDO = (
|
||||||
CONF_INPUT_OBST = "input_obst_pin"
|
CONF_INPUT_OBST = "input_obst_pin"
|
||||||
DEFAULT_INPUT_OBST = "D7" # D7 black obstruction sensor terminal
|
DEFAULT_INPUT_OBST = "D7" # D7 black obstruction sensor terminal
|
||||||
|
|
||||||
|
CONF_DISCRETE_OPEN_PIN = "discrete_open_pin"
|
||||||
|
CONF_DISCRETE_CLOSE_PIN = "discrete_close_pin"
|
||||||
|
|
||||||
CONF_RATGDO_ID = "ratgdo_id"
|
CONF_RATGDO_ID = "ratgdo_id"
|
||||||
|
|
||||||
CONF_ON_SYNC_FAILED = "on_sync_failed"
|
CONF_ON_SYNC_FAILED = "on_sync_failed"
|
||||||
|
@ -36,7 +40,22 @@ PROTOCOL_SECPLUSV2 = "secplusv2"
|
||||||
PROTOCOL_DRYCONTACT = "drycontact"
|
PROTOCOL_DRYCONTACT = "drycontact"
|
||||||
SUPPORTED_PROTOCOLS = [PROTOCOL_SECPLUSV1, PROTOCOL_SECPLUSV2, PROTOCOL_DRYCONTACT]
|
SUPPORTED_PROTOCOLS = [PROTOCOL_SECPLUSV1, PROTOCOL_SECPLUSV2, PROTOCOL_DRYCONTACT]
|
||||||
|
|
||||||
CONFIG_SCHEMA = cv.Schema(
|
CONF_DRY_CONTACT_OPEN_SENSOR = "dry_contact_open_sensor"
|
||||||
|
CONF_DRY_CONTACT_CLOSE_SENSOR = "dry_contact_close_sensor"
|
||||||
|
CONF_DRY_CONTACT_SENSOR_GROUP = "dry_contact_sensor_group"
|
||||||
|
|
||||||
|
def validate_protocol(config):
|
||||||
|
print("Validation")
|
||||||
|
if config.get(CONF_PROTOCOL, None) == PROTOCOL_DRYCONTACT and (CONF_DRY_CONTACT_CLOSE_SENSOR not in config or CONF_DRY_CONTACT_OPEN_SENSOR not in config):
|
||||||
|
raise cv.Invalid("dry_contact_close_sensor and dry_contact_open_sensor are required when using protocol drycontact")
|
||||||
|
if config.get(CONF_PROTOCOL, None) != PROTOCOL_DRYCONTACT and (CONF_DRY_CONTACT_CLOSE_SENSOR in config or CONF_DRY_CONTACT_OPEN_SENSOR in config):
|
||||||
|
raise cv.Invalid("dry_contact_close_sensor and dry_contact_open_sensor are only valid when using protocol drycontact")
|
||||||
|
# if config.get(CONF_PROTOCOL, None) == PROTOCOL_DRYCONTACT and CONF_DRY_CONTACT_OPEN_SENSOR not in config:
|
||||||
|
# raise cv.Invalid("dry_contact_open_sensor is required when using protocol drycontact")
|
||||||
|
return config
|
||||||
|
|
||||||
|
CONFIG_SCHEMA = cv.All(
|
||||||
|
cv.Schema(
|
||||||
{
|
{
|
||||||
cv.GenerateID(): cv.declare_id(RATGDO),
|
cv.GenerateID(): cv.declare_id(RATGDO),
|
||||||
cv.Optional(
|
cv.Optional(
|
||||||
|
@ -48,16 +67,24 @@ CONFIG_SCHEMA = cv.Schema(
|
||||||
cv.Optional(CONF_INPUT_OBST, default=DEFAULT_INPUT_OBST): cv.Any(
|
cv.Optional(CONF_INPUT_OBST, default=DEFAULT_INPUT_OBST): cv.Any(
|
||||||
cv.none, pins.gpio_input_pin_schema
|
cv.none, pins.gpio_input_pin_schema
|
||||||
),
|
),
|
||||||
|
cv.Optional(CONF_DISCRETE_OPEN_PIN): pins.gpio_output_pin_schema,
|
||||||
|
cv.Optional(CONF_DISCRETE_CLOSE_PIN): pins.gpio_output_pin_schema,
|
||||||
cv.Optional(CONF_ON_SYNC_FAILED): automation.validate_automation(
|
cv.Optional(CONF_ON_SYNC_FAILED): automation.validate_automation(
|
||||||
{
|
{
|
||||||
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(SyncFailed),
|
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(SyncFailed),
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
cv.Optional(CONF_PROTOCOL, default=PROTOCOL_SECPLUSV2): vol.In(
|
cv.Optional(CONF_PROTOCOL, default=PROTOCOL_SECPLUSV2): cv.All(vol.In(
|
||||||
SUPPORTED_PROTOCOLS
|
SUPPORTED_PROTOCOLS
|
||||||
),
|
)),
|
||||||
|
# cv.Inclusive(CONF_DRY_CONTACT_OPEN_SENSOR,CONF_DRY_CONTACT_SENSOR_GROUP): cv.use_id(binary_sensor.BinarySensor),
|
||||||
|
# cv.Inclusive(CONF_DRY_CONTACT_CLOSE_SENSOR,CONF_DRY_CONTACT_SENSOR_GROUP): cv.use_id(binary_sensor.BinarySensor),
|
||||||
|
cv.Optional(CONF_DRY_CONTACT_OPEN_SENSOR): cv.use_id(binary_sensor.BinarySensor),
|
||||||
|
cv.Optional(CONF_DRY_CONTACT_CLOSE_SENSOR): cv.use_id(binary_sensor.BinarySensor),
|
||||||
}
|
}
|
||||||
).extend(cv.COMPONENT_SCHEMA)
|
).extend(cv.COMPONENT_SCHEMA),
|
||||||
|
validate_protocol,
|
||||||
|
)
|
||||||
|
|
||||||
RATGDO_CLIENT_SCHMEA = cv.Schema(
|
RATGDO_CLIENT_SCHMEA = cv.Schema(
|
||||||
{
|
{
|
||||||
|
@ -82,6 +109,14 @@ async def to_code(config):
|
||||||
pin = await cg.gpio_pin_expression(config[CONF_INPUT_OBST])
|
pin = await cg.gpio_pin_expression(config[CONF_INPUT_OBST])
|
||||||
cg.add(var.set_input_obst_pin(pin))
|
cg.add(var.set_input_obst_pin(pin))
|
||||||
|
|
||||||
|
if CONF_DRY_CONTACT_OPEN_SENSOR in config and config[CONF_DRY_CONTACT_OPEN_SENSOR]:
|
||||||
|
dry_contact_open_sensor = await cg.get_variable(config[CONF_DRY_CONTACT_OPEN_SENSOR])
|
||||||
|
cg.add(var.set_dry_contact_open_sensor(dry_contact_open_sensor))
|
||||||
|
|
||||||
|
if CONF_DRY_CONTACT_CLOSE_SENSOR in config and config[CONF_DRY_CONTACT_CLOSE_SENSOR]:
|
||||||
|
dry_contact_close_sensor = await cg.get_variable(config[CONF_DRY_CONTACT_CLOSE_SENSOR])
|
||||||
|
cg.add(var.set_dry_contact_close_sensor(dry_contact_close_sensor))
|
||||||
|
|
||||||
for conf in config.get(CONF_ON_SYNC_FAILED, []):
|
for conf in config.get(CONF_ON_SYNC_FAILED, []):
|
||||||
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
|
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
|
||||||
await automation.build_automation(trigger, [], conf)
|
await automation.build_automation(trigger, [], conf)
|
||||||
|
@ -104,3 +139,10 @@ async def to_code(config):
|
||||||
elif config[CONF_PROTOCOL] == PROTOCOL_DRYCONTACT:
|
elif config[CONF_PROTOCOL] == PROTOCOL_DRYCONTACT:
|
||||||
cg.add_define("PROTOCOL_DRYCONTACT")
|
cg.add_define("PROTOCOL_DRYCONTACT")
|
||||||
cg.add(var.init_protocol())
|
cg.add(var.init_protocol())
|
||||||
|
|
||||||
|
if CONF_DISCRETE_OPEN_PIN in config and config[CONF_DISCRETE_OPEN_PIN]:
|
||||||
|
pin = await cg.gpio_pin_expression(config[CONF_DISCRETE_OPEN_PIN])
|
||||||
|
cg.add(var.set_discrete_open_pin(pin))
|
||||||
|
if CONF_DISCRETE_CLOSE_PIN in config and config[CONF_DISCRETE_CLOSE_PIN]:
|
||||||
|
pin = await cg.gpio_pin_expression(config[CONF_DISCRETE_CLOSE_PIN])
|
||||||
|
cg.add(var.set_discrete_close_pin(pin))
|
|
@ -5,6 +5,7 @@
|
||||||
#include "esphome/core/gpio.h"
|
#include "esphome/core/gpio.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
#include "esphome/core/scheduler.h"
|
#include "esphome/core/scheduler.h"
|
||||||
|
#include "esphome/components/gpio/binary_sensor/gpio_binary_sensor.h"
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace ratgdo {
|
namespace ratgdo {
|
||||||
|
@ -18,6 +19,12 @@ namespace ratgdo {
|
||||||
this->scheduler_ = scheduler;
|
this->scheduler_ = scheduler;
|
||||||
this->tx_pin_ = tx_pin;
|
this->tx_pin_ = tx_pin;
|
||||||
this->rx_pin_ = rx_pin;
|
this->rx_pin_ = rx_pin;
|
||||||
|
|
||||||
|
this->open_limit_reached_ = 0;
|
||||||
|
this->last_open_limit_ = 0;
|
||||||
|
this->close_limit_reached_ = 0;
|
||||||
|
this->last_close_limit_ = 0;
|
||||||
|
this->door_state_ = DoorState::UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DryContact::loop()
|
void DryContact::loop()
|
||||||
|
@ -31,6 +38,43 @@ namespace ratgdo {
|
||||||
|
|
||||||
void DryContact::sync()
|
void DryContact::sync()
|
||||||
{
|
{
|
||||||
|
ESP_LOG1(TAG, "Ignoring sync action");
|
||||||
|
}
|
||||||
|
|
||||||
|
void DryContact::set_open_limit(bool state)
|
||||||
|
{
|
||||||
|
ESP_LOGD(TAG, "Set open_limit_reached to %d", state);
|
||||||
|
this->last_open_limit_ = this->open_limit_reached_;
|
||||||
|
this->last_close_limit_ = false;
|
||||||
|
this->open_limit_reached_ = state;
|
||||||
|
this->send_door_state();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DryContact::set_close_limit(bool state)
|
||||||
|
{
|
||||||
|
ESP_LOGD(TAG, "Set close_limit_reached to %d", state);
|
||||||
|
this->last_close_limit_ = this->close_limit_reached_;
|
||||||
|
this->last_open_limit_ = false;
|
||||||
|
this->close_limit_reached_ = state;
|
||||||
|
this->send_door_state();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DryContact::send_door_state(){
|
||||||
|
if(this->open_limit_reached_){
|
||||||
|
this->door_state_ = DoorState::OPEN;
|
||||||
|
}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_){
|
||||||
|
this->door_state_ = DoorState::OPENING;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this->last_open_limit_){
|
||||||
|
this->door_state_ = DoorState::CLOSING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this->ratgdo_->received(this->door_state_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DryContact::light_action(LightAction action)
|
void DryContact::light_action(LightAction action)
|
||||||
|
@ -47,14 +91,33 @@ namespace ratgdo {
|
||||||
|
|
||||||
void DryContact::door_action(DoorAction action)
|
void DryContact::door_action(DoorAction action)
|
||||||
{
|
{
|
||||||
if (action != DoorAction::TOGGLE) {
|
if (action == DoorAction::OPEN && this->door_state_ != DoorState::CLOSED) {
|
||||||
ESP_LOG1(TAG, "Ignoring door action: %s", DoorAction_to_string(action));
|
ESP_LOGW(TAG, "The door is not closed. Ignoring door action: %s", DoorAction_to_string(action));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (action == DoorAction::CLOSE && this->door_state_ != DoorState::OPEN) {
|
||||||
|
ESP_LOGW(TAG, "The door is not open. Ignoring door action: %s", DoorAction_to_string(action));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ESP_LOG1(TAG, "Door action: %s", DoorAction_to_string(action));
|
ESP_LOG1(TAG, "Door action: %s", DoorAction_to_string(action));
|
||||||
|
|
||||||
this->tx_pin_->digital_write(1);
|
if (action == DoorAction::OPEN){
|
||||||
this->scheduler_->set_timeout(this->ratgdo_, "", 200, [=] {
|
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){
|
||||||
|
this->discrete_close_pin_->digital_write(1);
|
||||||
|
this->scheduler_->set_timeout(this->ratgdo_, "", 500, [=] {
|
||||||
|
this->discrete_close_pin_->digital_write(0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this->tx_pin_->digital_write(1); // Single button control
|
||||||
|
this->scheduler_->set_timeout(this->ratgdo_, "", 500, [=] {
|
||||||
this->tx_pin_->digital_write(0);
|
this->tx_pin_->digital_write(0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
#include "SoftwareSerial.h" // Using espsoftwareserial https://github.com/plerup/espsoftwareserial
|
#include "SoftwareSerial.h" // Using espsoftwareserial https://github.com/plerup/espsoftwareserial
|
||||||
#include "esphome/core/optional.h"
|
#include "esphome/core/optional.h"
|
||||||
|
#include "esphome/core/gpio.h"
|
||||||
|
#include "esphome/components/gpio/binary_sensor/gpio_binary_sensor.h"
|
||||||
|
|
||||||
#include "callbacks.h"
|
#include "callbacks.h"
|
||||||
#include "observable.h"
|
#include "observable.h"
|
||||||
|
@ -17,6 +19,7 @@ namespace ratgdo {
|
||||||
namespace dry_contact {
|
namespace dry_contact {
|
||||||
|
|
||||||
using namespace esphome::ratgdo::protocol;
|
using namespace esphome::ratgdo::protocol;
|
||||||
|
using namespace esphome::gpio;
|
||||||
|
|
||||||
class DryContact : public Protocol {
|
class DryContact : public Protocol {
|
||||||
public:
|
public:
|
||||||
|
@ -29,6 +32,21 @@ namespace ratgdo {
|
||||||
void light_action(LightAction action);
|
void light_action(LightAction action);
|
||||||
void lock_action(LockAction action);
|
void lock_action(LockAction action);
|
||||||
void door_action(DoorAction action);
|
void door_action(DoorAction action);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
Result call(Args args);
|
Result call(Args args);
|
||||||
|
|
||||||
|
@ -39,9 +57,18 @@ namespace ratgdo {
|
||||||
|
|
||||||
InternalGPIOPin* tx_pin_;
|
InternalGPIOPin* tx_pin_;
|
||||||
InternalGPIOPin* rx_pin_;
|
InternalGPIOPin* rx_pin_;
|
||||||
|
InternalGPIOPin* discrete_open_pin_;
|
||||||
|
InternalGPIOPin* discrete_close_pin_;
|
||||||
|
|
||||||
RATGDOComponent* ratgdo_;
|
RATGDOComponent* ratgdo_;
|
||||||
Scheduler* scheduler_;
|
Scheduler* scheduler_;
|
||||||
|
|
||||||
|
DoorState door_state_;
|
||||||
|
bool open_limit_reached_;
|
||||||
|
bool last_open_limit_;
|
||||||
|
bool close_limit_reached_;
|
||||||
|
bool last_close_limit_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace secplus1
|
} // namespace secplus1
|
||||||
|
|
|
@ -102,6 +102,11 @@ namespace ratgdo {
|
||||||
virtual void dump_config();
|
virtual void dump_config();
|
||||||
|
|
||||||
virtual void sync();
|
virtual void sync();
|
||||||
|
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);
|
||||||
|
|
||||||
virtual const Traits& traits() const;
|
virtual const Traits& traits() const;
|
||||||
|
|
||||||
|
|
|
@ -420,6 +420,16 @@ namespace ratgdo {
|
||||||
this->protocol_->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);
|
||||||
|
}
|
||||||
|
|
||||||
void RATGDOComponent::door_open()
|
void RATGDOComponent::door_open()
|
||||||
{
|
{
|
||||||
if (*this->door_state == DoorState::OPENING) {
|
if (*this->door_state == DoorState::OPENING) {
|
||||||
|
@ -673,5 +683,24 @@ namespace ratgdo {
|
||||||
this->learn_state.subscribe([=](LearnState state) { defer("learn_state", [=] { f(state); }); });
|
this->learn_state.subscribe([=](LearnState state) { defer("learn_state", [=] { f(state); }); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ratgdo
|
} // namespace ratgdo
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "esphome/core/component.h"
|
#include "esphome/core/component.h"
|
||||||
#include "esphome/core/hal.h"
|
#include "esphome/core/hal.h"
|
||||||
#include "esphome/core/preferences.h"
|
#include "esphome/core/preferences.h"
|
||||||
|
#include "esphome/components/gpio/binary_sensor/gpio_binary_sensor.h"
|
||||||
|
|
||||||
#include "callbacks.h"
|
#include "callbacks.h"
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
|
@ -91,6 +92,12 @@ namespace ratgdo {
|
||||||
void set_input_gdo_pin(InternalGPIOPin* pin) { this->input_gdo_pin_ = pin; }
|
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_input_obst_pin(InternalGPIOPin* pin) { this->input_obst_pin_ = pin; }
|
||||||
|
|
||||||
|
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); }
|
||||||
|
|
||||||
Result call_protocol(Args args);
|
Result call_protocol(Args args);
|
||||||
|
|
||||||
void received(const DoorState door_state);
|
void received(const DoorState door_state);
|
||||||
|
@ -145,6 +152,8 @@ namespace ratgdo {
|
||||||
void query_status();
|
void query_status();
|
||||||
void query_openings();
|
void query_openings();
|
||||||
void sync();
|
void sync();
|
||||||
|
void set_open_limit(bool);
|
||||||
|
void set_close_limit(bool);
|
||||||
|
|
||||||
// children subscriptions
|
// children subscriptions
|
||||||
void subscribe_rolling_code_counter(std::function<void(uint32_t)>&& f);
|
void subscribe_rolling_code_counter(std::function<void(uint32_t)>&& f);
|
||||||
|
@ -174,6 +183,8 @@ namespace ratgdo {
|
||||||
InternalGPIOPin* output_gdo_pin_;
|
InternalGPIOPin* output_gdo_pin_;
|
||||||
InternalGPIOPin* input_gdo_pin_;
|
InternalGPIOPin* input_gdo_pin_;
|
||||||
InternalGPIOPin* input_obst_pin_;
|
InternalGPIOPin* input_obst_pin_;
|
||||||
|
esphome::gpio::GPIOBinarySensor* dry_contact_open_sensor_;
|
||||||
|
esphome::gpio::GPIOBinarySensor* dry_contact_close_sensor_;
|
||||||
}; // RATGDOComponent
|
}; // RATGDOComponent
|
||||||
|
|
||||||
} // namespace ratgdo
|
} // namespace ratgdo
|
||||||
|
|
|
@ -202,8 +202,8 @@
|
||||||
|
|
||||||
<label>
|
<label>
|
||||||
<img src="./dry_contact.jpg" alt="Dry contact control." />
|
<img src="./dry_contact.jpg" alt="Dry contact control." />
|
||||||
<input type="radio" name="protocol" value="dry_contact" />
|
<input type="radio" name="protocol" value="drycontact" />
|
||||||
Dry Contact control<br/> (coming soon)
|
Dry Contact control<br/>Requires open & close limit switches
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -290,10 +290,7 @@
|
||||||
var protocol = document.querySelector('input[name="protocol"]:checked').value;
|
var protocol = document.querySelector('input[name="protocol"]:checked').value;
|
||||||
var hardware = document.querySelector('input[name="hardware"]:checked').value;
|
var hardware = document.querySelector('input[name="hardware"]:checked').value;
|
||||||
|
|
||||||
if(protocol === "dry_contact"){
|
if(protocol === "drycontact"){
|
||||||
alert("Dry contact support is coming soon.");
|
|
||||||
document.querySelector('input[name="protocol"][value="secplusv2"]').checked = true;
|
|
||||||
return;
|
|
||||||
document.querySelector("#wiring_diagram").src = "wiring_diagrams/dry_contact_diagram.png";
|
document.querySelector("#wiring_diagram").src = "wiring_diagrams/dry_contact_diagram.png";
|
||||||
}else{
|
}else{
|
||||||
document.querySelector("#wiring_diagram").src = "wiring_diagrams/secplus_diagram.png";
|
document.querySelector("#wiring_diagram").src = "wiring_diagrams/secplus_diagram.png";
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 500 KiB After Width: | Height: | Size: 1.1 MiB |
|
@ -0,0 +1,53 @@
|
||||||
|
---
|
||||||
|
substitutions:
|
||||||
|
id_prefix: ratgdov25i
|
||||||
|
friendly_name: "ratgdov2.5i"
|
||||||
|
uart_tx_pin: D1
|
||||||
|
uart_rx_pin: D2
|
||||||
|
input_obst_pin: D7
|
||||||
|
dry_contact_open_pin: D5
|
||||||
|
dry_contact_close_pin: D6
|
||||||
|
discrete_open_pin: D0
|
||||||
|
discrete_close_pin: D8
|
||||||
|
|
||||||
|
web_server:
|
||||||
|
|
||||||
|
esphome:
|
||||||
|
name: ${id_prefix}
|
||||||
|
friendly_name: ${friendly_name}
|
||||||
|
name_add_mac_suffix: true
|
||||||
|
project:
|
||||||
|
name: ratgdo.esphome
|
||||||
|
version: "2.5i"
|
||||||
|
|
||||||
|
esp8266:
|
||||||
|
board: d1_mini
|
||||||
|
restore_from_flash: true
|
||||||
|
|
||||||
|
dashboard_import:
|
||||||
|
package_import_url: github://ratgdo/esphome-ratgdo/v25iboard_secplusv1.yaml@main
|
||||||
|
|
||||||
|
packages:
|
||||||
|
remote_package:
|
||||||
|
url: https://github.com/ratgdo/esphome-ratgdo
|
||||||
|
files: [base_secplusv1.yaml]
|
||||||
|
refresh: 1s
|
||||||
|
# remote_package: !include
|
||||||
|
# file: base_drycontact.yaml
|
||||||
|
# Sync time with Home Assistant.
|
||||||
|
time:
|
||||||
|
- platform: homeassistant
|
||||||
|
id: homeassistant_time
|
||||||
|
|
||||||
|
api:
|
||||||
|
id: api_server
|
||||||
|
|
||||||
|
ota:
|
||||||
|
|
||||||
|
improv_serial:
|
||||||
|
|
||||||
|
wifi:
|
||||||
|
ap:
|
||||||
|
|
||||||
|
logger:
|
||||||
|
level: DEBUG
|
Loading…
Reference in New Issue