From 587845820a6fd90cd249800c52887fcaeb17d0a6 Mon Sep 17 00:00:00 2001 From: Paul Wieland
Date: Sat, 13 Apr 2024 15:07:34 -0400 Subject: [PATCH] send both sensor values --- base_drycontact.yaml | 20 +++++++------------- components/ratgdo/ratgdo.cpp | 10 ++-------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/base_drycontact.yaml b/base_drycontact.yaml index 3f651cb..0974636 100644 --- a/base_drycontact.yaml +++ b/base_drycontact.yaml @@ -16,6 +16,8 @@ ratgdo: 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 protocol: drycontact on_sync_failed: then: @@ -37,7 +39,7 @@ switch: id: "${id_prefix}_status_door" internal: true pin: - number: ${status_door_pin} # D0 output door status, HIGH for open, LOW for closed + number: ${status_door_pin} mode: output: true name: "Status door" @@ -46,7 +48,7 @@ switch: id: "${id_prefix}_status_obstruction" internal: true pin: - number: ${status_obstruction_pin} # D8 output for obstruction status, HIGH for obstructed, LOW for clear + number: ${status_obstruction_pin} mode: output: true name: "Status obstruction" @@ -78,7 +80,7 @@ binary_sensor: - 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 @@ -87,14 +89,10 @@ binary_sensor: 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 @@ -103,14 +101,10 @@ binary_sensor: 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) + number: ${dry_contact_light_pin} inverted: true mode: input: true diff --git a/components/ratgdo/ratgdo.cpp b/components/ratgdo/ratgdo.cpp index 0dd97c5..eb26bf1 100644 --- a/components/ratgdo/ratgdo.cpp +++ b/components/ratgdo/ratgdo.cpp @@ -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); } ); }