Compare commits
5 Commits
d969618d79
...
32190f5ba8
Author | SHA1 | Date |
---|---|---|
Paul Wieland | 32190f5ba8 | |
Paul Wieland | 5c8c69c9fc | |
Paul Wieland | cea8820d4f | |
Paul Wieland | 6f5b825ca7 | |
Paul Wieland | 587845820a |
|
@ -2,136 +2,58 @@
|
|||
|
||||
external_components:
|
||||
- source:
|
||||
type: local
|
||||
path: components
|
||||
# type: git
|
||||
# url: https://github.com/ratgdo/esphome-ratgdo
|
||||
# refresh: 1s
|
||||
# type: local
|
||||
# path: components
|
||||
type: git
|
||||
url: https://github.com/ratgdo/esphome-ratgdo
|
||||
refresh: 1s
|
||||
|
||||
preferences:
|
||||
flash_write_interval: 1min
|
||||
|
||||
ratgdo:
|
||||
id: ${id_prefix}
|
||||
input_gdo_pin: ${uart_rx_pin}
|
||||
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
|
||||
on_sync_failed:
|
||||
then:
|
||||
- homeassistant.service:
|
||||
service: persistent_notification.create
|
||||
data:
|
||||
title: "${friendly_name} sync failed"
|
||||
message: "Failed to communicate with garage opener on startup."
|
||||
notification_id: "esphome_ratgdo_${id_prefix}_sync_failed"
|
||||
|
||||
lock:
|
||||
- platform: ratgdo
|
||||
id: ${id_prefix}_lock_remotes
|
||||
ratgdo_id: ${id_prefix}
|
||||
name: "Lock remotes"
|
||||
|
||||
switch:
|
||||
- platform: gpio
|
||||
id: "${id_prefix}_status_door"
|
||||
internal: true
|
||||
pin:
|
||||
number: ${status_door_pin} # D0 output door status, HIGH for open, LOW for closed
|
||||
mode:
|
||||
output: true
|
||||
name: "Status door"
|
||||
entity_category: diagnostic
|
||||
- platform: gpio
|
||||
id: "${id_prefix}_status_obstruction"
|
||||
internal: true
|
||||
pin:
|
||||
number: ${status_obstruction_pin} # D8 output for obstruction status, HIGH for obstructed, LOW for clear
|
||||
mode:
|
||||
output: true
|
||||
name: "Status obstruction"
|
||||
entity_category: diagnostic
|
||||
|
||||
binary_sensor:
|
||||
- platform: ratgdo
|
||||
type: motion
|
||||
id: ${id_prefix}_motion
|
||||
ratgdo_id: ${id_prefix}
|
||||
name: "Motion"
|
||||
device_class: motion
|
||||
- platform: ratgdo
|
||||
type: obstruction
|
||||
id: ${id_prefix}_obstruction
|
||||
ratgdo_id: ${id_prefix}
|
||||
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: button
|
||||
id: ${id_prefix}_button
|
||||
ratgdo_id: ${id_prefix}
|
||||
name: "Button"
|
||||
entity_category: diagnostic
|
||||
- platform: gpio
|
||||
id: "${id_prefix}_dry_contact_open"
|
||||
pin:
|
||||
number: ${dry_contact_open_pin} # D5 dry contact for opening door
|
||||
number: ${dry_contact_open_pin}
|
||||
inverted: true
|
||||
mode:
|
||||
input: true
|
||||
pullup: true
|
||||
name: "Dry contact open"
|
||||
name: "Open limit switch"
|
||||
entity_category: diagnostic
|
||||
filters:
|
||||
- delayed_on_off: 500ms
|
||||
on_state:
|
||||
then:
|
||||
lambda: |-
|
||||
id($id_prefix)->set_open_limit(x);
|
||||
- platform: gpio
|
||||
id: "${id_prefix}_dry_contact_close"
|
||||
pin:
|
||||
number: ${dry_contact_close_pin} # D6 dry contact for closing door
|
||||
number: ${dry_contact_close_pin}
|
||||
inverted: true
|
||||
mode:
|
||||
input: true
|
||||
pullup: true
|
||||
name: "Dry contact close"
|
||||
name: "Close limit switch"
|
||||
entity_category: diagnostic
|
||||
filters:
|
||||
- delayed_on_off: 500ms
|
||||
on_state:
|
||||
then:
|
||||
lambda: |-
|
||||
id($id_prefix)->set_close_limit(x);
|
||||
- platform: gpio
|
||||
id: "${id_prefix}_dry_contact_light"
|
||||
pin:
|
||||
number: ${dry_contact_light_pin} # D3 dry contact for triggering light (no discrete light commands, so toggle only)
|
||||
inverted: true
|
||||
mode:
|
||||
input: true
|
||||
pullup: true
|
||||
name: "Dry contact light"
|
||||
entity_category: diagnostic
|
||||
filters:
|
||||
- delayed_on_off: 500ms
|
||||
on_press:
|
||||
- light.toggle: ${id_prefix}_light
|
||||
|
||||
number:
|
||||
- platform: ratgdo
|
||||
id: ${id_prefix}_rolling_code_counter
|
||||
type: rolling_code_counter
|
||||
entity_category: config
|
||||
ratgdo_id: ${id_prefix}
|
||||
name: "Rolling code counter"
|
||||
mode: box
|
||||
unit_of_measurement: "codes"
|
||||
|
||||
- platform: ratgdo
|
||||
id: ${id_prefix}_opening_duration
|
||||
type: opening_duration
|
||||
|
@ -148,30 +70,12 @@ number:
|
|||
name: "Closing duration"
|
||||
unit_of_measurement: "s"
|
||||
|
||||
- platform: ratgdo
|
||||
id: ${id_prefix}_client_id
|
||||
type: client_id
|
||||
entity_category: config
|
||||
ratgdo_id: ${id_prefix}
|
||||
name: "Client ID"
|
||||
mode: box
|
||||
|
||||
cover:
|
||||
- platform: ratgdo
|
||||
id: ${id_prefix}_garage_door
|
||||
device_class: garage
|
||||
name: "Door"
|
||||
ratgdo_id: ${id_prefix}
|
||||
on_closed:
|
||||
- switch.turn_off: ${id_prefix}_status_door
|
||||
on_open:
|
||||
- switch.turn_on: ${id_prefix}_status_door
|
||||
|
||||
light:
|
||||
- platform: ratgdo
|
||||
id: ${id_prefix}_light
|
||||
name: "Light"
|
||||
ratgdo_id: ${id_prefix}
|
||||
|
||||
button:
|
||||
- platform: restart
|
||||
|
@ -182,24 +86,6 @@ button:
|
|||
name: "Safe mode boot"
|
||||
entity_category: diagnostic
|
||||
|
||||
- platform: template
|
||||
id: ${id_prefix}_query_status
|
||||
entity_category: diagnostic
|
||||
name: "Query status"
|
||||
on_press:
|
||||
then:
|
||||
lambda: !lambda |-
|
||||
id($id_prefix).query_status();
|
||||
|
||||
- platform: template
|
||||
id: ${id_prefix}_sync
|
||||
name: "Sync"
|
||||
entity_category: diagnostic
|
||||
on_press:
|
||||
then:
|
||||
lambda: !lambda |-
|
||||
id($id_prefix).sync();
|
||||
|
||||
- platform: template
|
||||
id: ${id_prefix}_toggle_door
|
||||
name: "Toggle door"
|
||||
|
|
|
@ -26,6 +26,9 @@ DEFAULT_INPUT_GDO = (
|
|||
CONF_INPUT_OBST = "input_obst_pin"
|
||||
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_ON_SYNC_FAILED = "on_sync_failed"
|
||||
|
@ -64,6 +67,8 @@ CONFIG_SCHEMA = cv.All(
|
|||
cv.Optional(CONF_INPUT_OBST, default=DEFAULT_INPUT_OBST): cv.Any(
|
||||
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.GenerateID(CONF_TRIGGER_ID): cv.declare_id(SyncFailed),
|
||||
|
@ -134,3 +139,10 @@ async def to_code(config):
|
|||
elif config[CONF_PROTOCOL] == PROTOCOL_DRYCONTACT:
|
||||
cg.add_define("PROTOCOL_DRYCONTACT")
|
||||
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))
|
|
@ -102,7 +102,21 @@ namespace ratgdo {
|
|||
|
||||
ESP_LOG1(TAG, "Door action: %s", DoorAction_to_string(action));
|
||||
|
||||
this->tx_pin_->digital_write(1);
|
||||
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){
|
||||
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);
|
||||
});
|
||||
|
|
|
@ -36,6 +36,18 @@ namespace ratgdo {
|
|||
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);
|
||||
|
||||
const Traits& traits() const { return this->traits_; }
|
||||
|
@ -45,6 +57,8 @@ namespace ratgdo {
|
|||
|
||||
InternalGPIOPin* tx_pin_;
|
||||
InternalGPIOPin* rx_pin_;
|
||||
InternalGPIOPin* discrete_open_pin_;
|
||||
InternalGPIOPin* discrete_close_pin_;
|
||||
|
||||
RATGDOComponent* ratgdo_;
|
||||
Scheduler* scheduler_;
|
||||
|
|
|
@ -105,6 +105,9 @@ namespace ratgdo {
|
|||
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 void light_action(LightAction action);
|
||||
|
|
|
@ -688,10 +688,7 @@ namespace ratgdo {
|
|||
dry_contact_open_sensor_ = dry_contact_open_sensor;
|
||||
dry_contact_open_sensor_->add_on_state_callback([this](bool sensor_value)
|
||||
{
|
||||
if (sensor_value) {
|
||||
ESP_LOGD(TAG,"Dry Contact Open Sensor Triggered");
|
||||
this->set_open_limit(true);
|
||||
}
|
||||
this->set_open_limit(sensor_value);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -700,10 +697,7 @@ namespace ratgdo {
|
|||
dry_contact_close_sensor_ = dry_contact_close_sensor;
|
||||
dry_contact_close_sensor_->add_on_state_callback([this](bool sensor_value)
|
||||
{
|
||||
if (sensor_value) {
|
||||
ESP_LOGD(TAG,"Dry Contact Close Sensor Triggered");
|
||||
set_close_limit(true);
|
||||
}
|
||||
this->set_close_limit(sensor_value);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -92,6 +92,12 @@ 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_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);
|
||||
|
||||
void received(const DoorState door_state);
|
||||
|
@ -169,9 +175,6 @@ namespace ratgdo {
|
|||
void subscribe_sync_failed(std::function<void(bool)>&& f);
|
||||
void subscribe_learn_state(std::function<void(LearnState)>&& f);
|
||||
|
||||
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_);
|
||||
|
||||
protected:
|
||||
RATGDOStore isr_store_ {};
|
||||
protocol::Protocol* protocol_;
|
||||
|
|
|
@ -202,8 +202,8 @@
|
|||
|
||||
<label>
|
||||
<img src="./dry_contact.jpg" alt="Dry contact control." />
|
||||
<input type="radio" name="protocol" value="dry_contact" />
|
||||
Dry Contact control<br/> (coming soon)
|
||||
<input type="radio" name="protocol" value="drycontact" />
|
||||
Dry Contact control<br/>Requires open & close limit switches
|
||||
</label>
|
||||
</div>
|
||||
|
||||
|
@ -290,10 +290,7 @@
|
|||
var protocol = document.querySelector('input[name="protocol"]:checked').value;
|
||||
var hardware = document.querySelector('input[name="hardware"]:checked').value;
|
||||
|
||||
if(protocol === "dry_contact"){
|
||||
alert("Dry contact support is coming soon.");
|
||||
document.querySelector('input[name="protocol"][value="secplusv2"]').checked = true;
|
||||
return;
|
||||
if(protocol === "drycontact"){
|
||||
document.querySelector("#wiring_diagram").src = "wiring_diagrams/dry_contact_diagram.png";
|
||||
}else{
|
||||
document.querySelector("#wiring_diagram").src = "wiring_diagrams/secplus_diagram.png";
|
||||
|
|
|
@ -5,11 +5,10 @@ substitutions:
|
|||
uart_tx_pin: D1
|
||||
uart_rx_pin: D2
|
||||
input_obst_pin: D7
|
||||
status_door_pin: D0
|
||||
status_obstruction_pin: D8
|
||||
dry_contact_open_pin: D5
|
||||
dry_contact_close_pin: D6
|
||||
dry_contact_light_pin: D3
|
||||
discrete_open_pin: D0
|
||||
discrete_close_pin: D8
|
||||
|
||||
web_server:
|
||||
|
||||
|
@ -29,12 +28,12 @@ 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
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue