From 0b5d6bc0cc403a3f292b4629d9309c103f7770a3 Mon Sep 17 00:00:00 2001 From: Andrej Friesen Date: Fri, 9 Feb 2024 22:35:46 +0100 Subject: [PATCH] Fix double pin usage The first attempt to just allow using the twin twice was not the right approach. Now we just define the pins once and use tempalte switches. --- pc-switch.yaml | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/pc-switch.yaml b/pc-switch.yaml index 52a6109..860ccc0 100644 --- a/pc-switch.yaml +++ b/pc-switch.yaml @@ -46,31 +46,41 @@ sensor: switch: - platform: gpio - pin: - number: D6 - allow_other_uses: true + pin: D6 + id: power_pin + internal: true + + - platform: template + name: "Power Switch" id: power_switch internal: true - on_turn_on: - - delay: 300ms - - switch.turn_off: power_switch + turn_on_action: + - switch.turn_on: power_pin + - delay: 300ms + - switch.turn_off: power_pin - - platform: gpio - pin: - number: D6 - allow_other_uses: true + - platform: template + name: "Power Switch Force" id: power_switch_force internal: true - on_turn_on: - - delay: 5000ms - - switch.turn_off: power_switch_force + turn_on_action: + - switch.turn_on: power_pin + - delay: 5000ms + - switch.turn_off: power_pin - platform: gpio pin: D7 + id: reset_pin + internal: true + + - platform: template + name: "Reset Switch" id: reset_switch - on_turn_on: - - delay: 300ms - - switch.turn_off: reset_switch + internal: true + turn_on_action: + - switch.turn_on: reset_pin + - delay: 300ms + - switch.turn_off: reset_pin binary_sensor: - platform: gpio