Hi Everyone,
This is my very first contribution to this amazing community so please be indulgent if I’m doing anything wrong
Shelly Switch controller :
I recently bought Shelly1 wifi relay & Shelly Dimmer 2, both allow to control anything you want from HA integration, and it works like a charm.
These component can be controlled from physical switches (such as Sonoff mini, and many others I guess).
I figured out Shelly Devices fire events when the physical switch is triggered and I wanted to take benefit from this feature in my HA configuration so I started to work on this blueprint in order to make this configuration easier.
So here we are, this blueprint allow you to select a Shelly Device (added via HA’s Shelly Integration) and configure any sequence of action that meet your need considering the click types declared in HA’s Shelly Integration doc
I’m pretty new into this stuff and as far as my test went, my Shelly1 only fire events for single click and long click. However I left all the defined click type in the blueprint so make sure your device fire an event for each click type you want to use (via dev tools → events → listen “shelly.click”)
If you are facing any issue, let me know, I’ll try to help out as best as I can.
Cheers !
TROUBLE SHOOTING
Please note that Shelly Devices fire events on switch trigger only if the BUTTON TYPE of the switch connected to the device is set to momentary
or detached switch
, according to shelly integration doc
How to make sure I can use a click type :
Once your device is configured and added to home assistant using Shelly Integration
Go to Developper Tools → Events, then enter “shelly.click” and start listening.
Now you just need to try the click type on your physical switch and see what event comes up.
Here is the blueprint :
blueprint:
name: Shelly switch events
description: Control anything from shelly SW
domain: automation
input:
remote:
name: Switch
description: Button to use
selector:
device:
integration: shelly
channel:
name: Channel
description: Which shelly channel should trigger this automation
default: 1
selector:
number:
min: 0
max: 20
mode: box
button_single:
name: Short click
default: []
selector:
action: {}
button_double:
name: Double click
default: []
selector:
action: {}
button_triple:
name: Triple click
default: []
selector:
action: {}
button_long:
name: Long click
default: []
selector:
action: {}
button_single_long:
name: Button single long
default: []
selector:
action: {}
button_long_single:
name: Button long single
default: []
selector:
action: {}
source_url: https://community.home-assistant.io/t/shelly-device-switch-template-for-each-click-type/296528
mode: restart
max_exceeded: silent
trigger:
- platform: event
event_type: shelly.click
event_data:
device_id: !input 'remote'
channel: !input 'channel'
action:
- variables:
event: '{{ trigger.event.data.click_type }}'
- choose:
- conditions:
- '{{ event == "single" }}'
sequence: !input 'button_single'
- conditions:
- '{{ event == "double" }}'
sequence: !input 'button_double'
- conditions:
- '{{ event == "triple" }}'
sequence: !input 'button_triple'
- conditions:
- '{{ event == "long" }}'
sequence: !input 'button_long'
- conditions:
- '{{ event == "single_long" }}'
sequence: !input 'button_single_long'
- conditions:
- '{{ event == "long_single" }}'
sequence: !input 'button_long_single'