From fd60737282b84dbf0d385b71c8c5e2ba7eca0e1b Mon Sep 17 00:00:00 2001 From: brianhanifin Date: Fri, 13 Dec 2019 13:30:35 -0800 Subject: [PATCH] refactoring shelly1 code --- common/binary_sensors/power_button.yaml | 1 - common/binary_sensors/power_button_inverted.yaml | 12 ++++++++++++ common/logger.yaml | 2 +- shelly1_01.yaml | 7 ++----- shelly1_02.yaml | 5 +---- 5 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 common/binary_sensors/power_button_inverted.yaml diff --git a/common/binary_sensors/power_button.yaml b/common/binary_sensors/power_button.yaml index 981e17f..459412a 100644 --- a/common/binary_sensors/power_button.yaml +++ b/common/binary_sensors/power_button.yaml @@ -3,7 +3,6 @@ platform: gpio pin: number: $button_gpio mode: INPUT_PULLUP - inverted: True id: ${id}_button internal: true on_press: diff --git a/common/binary_sensors/power_button_inverted.yaml b/common/binary_sensors/power_button_inverted.yaml new file mode 100644 index 0000000..981e17f --- /dev/null +++ b/common/binary_sensors/power_button_inverted.yaml @@ -0,0 +1,12 @@ +--- +platform: gpio +pin: + number: $button_gpio + mode: INPUT_PULLUP + inverted: True +id: ${id}_button +internal: true +on_press: + - switch.toggle: relay +filters: + - delayed_on: 10ms diff --git a/common/logger.yaml b/common/logger.yaml index a8bfad4..0311c08 100644 --- a/common/logger.yaml +++ b/common/logger.yaml @@ -1,3 +1,3 @@ --- logger: - level: INFO + #level: INFO diff --git a/shelly1_01.yaml b/shelly1_01.yaml index 18f6af5..46583cb 100644 --- a/shelly1_01.yaml +++ b/shelly1_01.yaml @@ -45,15 +45,12 @@ binary_sensor: - platform: gpio pin: number: $button_gpio - inverted: True - name: $project Button + name: $project Wall Switch id: button filters: - delayed_on: 10ms - delayed_off: 10ms - on_press: - - script.execute: hass_light_toggle - on_release: + on_state: - script.execute: hass_light_toggle switch: diff --git a/shelly1_02.yaml b/shelly1_02.yaml index 3d11f8d..92229ae 100644 --- a/shelly1_02.yaml +++ b/shelly1_02.yaml @@ -56,15 +56,12 @@ binary_sensor: - platform: gpio pin: number: $button_gpio - inverted: True #name: $project Button id: button filters: - delayed_on: 10ms - delayed_off: 10ms - on_press: - - script.execute: relay_toggle - on_release: + on_state: - script.execute: relay_toggle sensor: