From a50d6014f7eb997fc076d91ad3070ac77dd72521 Mon Sep 17 00:00:00 2001 From: Paul Wieland
Date: Sat, 28 Sep 2024 11:36:07 -0700 Subject: [PATCH] Move logic to script with short delay (#324) fixes dry contact input toggle problem --- base.yaml | 42 ++++++++++++++++++++++++++++++------------ base_secplusv1.yaml | 42 ++++++++++++++++++++++++++++++------------ 2 files changed, 60 insertions(+), 24 deletions(-) diff --git a/base.yaml b/base.yaml index 881eb97..7511fe3 100644 --- a/base.yaml +++ b/base.yaml @@ -144,13 +144,8 @@ binary_sensor: filters: - delayed_on_off: 500ms on_press: - - if: - condition: - binary_sensor.is_off: ${id_prefix}_dry_contact_close - then: - - cover.open: ${id_prefix}_garage_door - else: - - cover.toggle: ${id_prefix}_garage_door + then: + script.execute: "${id_prefix}_dry_contact_door_control" - platform: gpio id: "${id_prefix}_dry_contact_close" pin: @@ -164,11 +159,8 @@ binary_sensor: filters: - delayed_on_off: 500ms on_press: - - if: - condition: - binary_sensor.is_off: ${id_prefix}_dry_contact_open - then: - - cover.close: ${id_prefix}_garage_door + then: + script.execute: "${id_prefix}_dry_contact_door_control" - platform: gpio id: "${id_prefix}_dry_contact_light" pin: @@ -184,6 +176,32 @@ binary_sensor: on_press: - light.toggle: ${id_prefix}_light +script: + - id: "${id_prefix}_dry_contact_door_control" + then: + - delay: 0.1s + - if: + condition: + and: + - binary_sensor.is_on: ${id_prefix}_dry_contact_close + - binary_sensor.is_on: ${id_prefix}_dry_contact_open + then: + - cover.toggle: ${id_prefix}_garage_door + - if: + condition: + and: + - binary_sensor.is_off: ${id_prefix}_dry_contact_close + - binary_sensor.is_on: ${id_prefix}_dry_contact_open + then: + - cover.open: ${id_prefix}_garage_door + - if: + condition: + and: + - binary_sensor.is_on: ${id_prefix}_dry_contact_close + - binary_sensor.is_off: ${id_prefix}_dry_contact_open + then: + - cover.close: ${id_prefix}_garage_door + number: - platform: ratgdo id: ${id_prefix}_rolling_code_counter diff --git a/base_secplusv1.yaml b/base_secplusv1.yaml index 0f94435..4248cac 100644 --- a/base_secplusv1.yaml +++ b/base_secplusv1.yaml @@ -96,13 +96,8 @@ binary_sensor: filters: - delayed_on_off: 500ms on_press: - - if: - condition: - binary_sensor.is_off: ${id_prefix}_dry_contact_close - then: - - cover.open: ${id_prefix}_garage_door - else: - - cover.toggle: ${id_prefix}_garage_door + then: + script.execute: "${id_prefix}_dry_contact_door_control" - platform: gpio id: "${id_prefix}_dry_contact_close" pin: @@ -116,11 +111,8 @@ binary_sensor: filters: - delayed_on_off: 500ms on_press: - - if: - condition: - binary_sensor.is_off: ${id_prefix}_dry_contact_open - then: - - cover.close: ${id_prefix}_garage_door + then: + script.execute: "${id_prefix}_dry_contact_door_control" - platform: gpio id: "${id_prefix}_dry_contact_light" pin: @@ -136,6 +128,32 @@ binary_sensor: on_press: - light.toggle: ${id_prefix}_light +script: + - id: "${id_prefix}_dry_contact_door_control" + then: + - delay: 0.1s + - if: + condition: + and: + - binary_sensor.is_on: ${id_prefix}_dry_contact_close + - binary_sensor.is_on: ${id_prefix}_dry_contact_open + then: + - cover.toggle: ${id_prefix}_garage_door + - if: + condition: + and: + - binary_sensor.is_off: ${id_prefix}_dry_contact_close + - binary_sensor.is_on: ${id_prefix}_dry_contact_open + then: + - cover.open: ${id_prefix}_garage_door + - if: + condition: + and: + - binary_sensor.is_on: ${id_prefix}_dry_contact_close + - binary_sensor.is_off: ${id_prefix}_dry_contact_open + then: + - cover.close: ${id_prefix}_garage_door + number: - platform: ratgdo id: ${id_prefix}_rolling_code_counter