Updates the lounge switch so double and hold work

master
Jonathan Hodgson 3 years ago
parent c4ebe67d35
commit 57ff150712
  1. 164
      lounge-switch.yaml

@ -15,36 +15,132 @@ api:
ota: ota:
binary_sensor: binary_sensor:
- platform: gpio - platform: gpio
pin: pin:
number: GPIO0 number: GPIO0
mode: INPUT_PULLUP mode: INPUT_PULLUP
inverted: True inverted: True
name: "Lounge Touchpad 1" filters:
- delayed_on: 30ms
- delayed_off: 30ms
internal: True
on_multi_click:
# Single
- timing:
- ON for at most 1s
- OFF for at least 0.5s
then:
- text_sensor.template.publish:
id: louge_button_1
state: !lambda 'return "single";'
# Double
- timing:
- ON for at most 1s
- OFF for at most 1s
- ON for at most 1s
- OFF for at least 0.2s
then:
- text_sensor.template.publish:
id: louge_button_1
state: !lambda 'return "double";'
# Hold
- timing:
- ON for 1s to 3s
- OFF for at least 0.5s
then:
- text_sensor.template.publish:
id: louge_button_1
state: !lambda 'return "hold";'
name: "Lounge Raw Touchpad 1"
on_press: on_press:
then: then:
- output.turn_on: blue_led - output.turn_on: blue_led
on_release: on_release:
then: then:
- output.turn_off: blue_led - output.turn_off: blue_led
- platform: gpio - platform: gpio
pin: pin:
number: GPIO9 number: GPIO9
mode: INPUT_PULLUP mode: INPUT_PULLUP
inverted: True inverted: True
name: "Lounge Touchpad 2" filters:
- delayed_on: 30ms
- delayed_off: 30ms
internal: True
on_multi_click:
# Single
- timing:
- ON for at most 1s
- OFF for at least 0.5s
then:
- text_sensor.template.publish:
id: louge_button_2
state: !lambda 'return "single";'
# Double
- timing:
- ON for at most 1s
- OFF for at most 1s
- ON for at most 1s
- OFF for at least 0.2s
then:
- text_sensor.template.publish:
id: louge_button_2
state: !lambda 'return "double";'
# Hold
- timing:
- ON for 1s to 3s
- OFF for at least 0.5s
then:
- text_sensor.template.publish:
id: louge_button_2
state: !lambda 'return "hold";'
name: "Lounge Raw Touchpad 2"
on_press: on_press:
then: then:
- output.turn_on: blue_led - output.turn_on: blue_led
on_release: on_release:
then: then:
- output.turn_off: blue_led - output.turn_off: blue_led
- platform: gpio - platform: gpio
pin: pin:
number: GPIO10 number: GPIO10
mode: INPUT_PULLUP mode: INPUT_PULLUP
inverted: True inverted: True
name: "Lounge Touchpad 3" name: "Lounge Raw Touchpad 3"
filters:
- delayed_on: 30ms
- delayed_off: 30ms
internal: True
on_multi_click:
# Single
- timing:
- ON for at most 1s
- OFF for at least 0.5s
then:
- text_sensor.template.publish:
id: louge_button_3
state: !lambda 'return "single";'
# Double
- timing:
- ON for at most 1s
- OFF for at most 1s
- ON for at most 1s
- OFF for at least 0.2s
then:
- text_sensor.template.publish:
id: louge_button_3
state: !lambda 'return "double";'
# Hold
- timing:
- ON for 1s to 3s
- OFF for at least 0.5s
then:
- text_sensor.template.publish:
id: louge_button_3
state: !lambda 'return "hold";'
on_press: on_press:
then: then:
- output.turn_on: blue_led - output.turn_on: blue_led
@ -58,12 +154,15 @@ switch:
- platform: gpio - platform: gpio
name: "Lounge Relay 1" name: "Lounge Relay 1"
pin: GPIO12 pin: GPIO12
restore_mode: ALWAYS_OFF
- platform: gpio - platform: gpio
name: "Lounge Relay 2" name: "Lounge Relay 2"
pin: GPIO5 pin: GPIO5
restore_mode: ALWAYS_ON
- platform: gpio - platform: gpio
name: "Lounge Relay 3" name: "Lounge Relay 3"
pin: GPIO4 pin: GPIO4
restore_mode: ALWAYS_OFF
output: output:
# Register the blue LED as a dimmable output .... # Register the blue LED as a dimmable output ....
@ -72,8 +171,57 @@ output:
pin: GPIO13 pin: GPIO13
inverted: True inverted: True
#light: # This sensor is published to homeassistant with the value:
# # ... and then make a light out of it. # * single
# - platform: monochromatic # * double
# name: "Bedroom switch light" # * hold
# output: blue_led # This can be used to trigger automations by type "state"
text_sensor:
- platform: template
name: "Lounge Touchpad 1"
id: louge_button_1
icon: "mdi:toggle-switch"
on_value:
then:
- if:
condition:
text_sensor.state:
id: louge_button_1
state: ""
else:
- delay: 20ms
- text_sensor.template.publish:
id: louge_button_1
state: !lambda 'return "";'
- platform: template
name: "Lounge Touchpad 2"
id: louge_button_2
icon: "mdi:toggle-switch"
on_value:
then:
- if:
condition:
text_sensor.state:
id: louge_button_2
state: ""
else:
- delay: 20ms
- text_sensor.template.publish:
id: louge_button_2
state: !lambda 'return "";'
- platform: template
name: "Lounge Touchpad 3"
id: louge_button_3
icon: "mdi:toggle-switch"
on_value:
then:
- if:
condition:
text_sensor.state:
id: louge_button_3
state: ""
else:
- delay: 20ms
- text_sensor.template.publish:
id: louge_button_3
state: !lambda 'return "";'

Loading…
Cancel
Save