Shelly Device switch template for each click type

Yes, please. That would be awesome. :+1:t2:

Has somebody testet this with Shelly 1 Plus, or something other devices, from the PLUS-Series?

I tested with shelly 4pm.

seems like 4pm does send single_push instead of single
changed the code like this

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
          multiple: false
    channel:
      name: Channel
      description: Which shelly channel should trigger this automation
      default: 1
      selector:
        number:
          min: 0.0
          max: 20.0
          mode: box
          step: 1.0
    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/10
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:
     or:
        - '{{ event == "single" }}'
        - '{{ event == "single_push" }}'
    sequence: !input button_single
  - conditions:
      or:
          - '{{ event == "double" }}'
          - '{{ event == "double_push" }}' 
    sequence: !input button_double
  - conditions:
    - '{{ event == "triple" }}'
    sequence: !input button_triple
  - conditions:
      or:
          - '{{ event == "long" }}'
          - '{{ event == "long_push" }}' 
    sequence: !input button_long
  - conditions:
    - '{{ event == "single_long" }}'
    sequence: !input button_single_long
  - conditions:
    - '{{ event == "long_single" }}'
    sequence: !input button_long_single

I’ve tested it with Shelly 1 Plus and changed the blueprint to this:

blueprint:
  name: Shelly Push 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_push" }}'
    sequence: !input 'button_single'
  - conditions:
    - '{{ event == "double_push" }}'
    sequence: !input 'button_double'
  - conditions:
    - '{{ event == "triple" }}'
    sequence: !input 'button_triple'
  - conditions:
    - '{{ event == "long_push" }}'
    sequence: !input 'button_long'
  - conditions:
    - '{{ event == "single_long" }}'
    sequence: !input 'button_single_long'
  - conditions:
    - '{{ event == "long_single" }}'
    sequence: !input 'button_long_single'

I have only change “click” to “push” and it works for single, double and long. Tripple and singe_long and long_single doesn´t work in my test. For tests, i have connect a switch, but not found a solution for the other 3 states.
What are the differents between long_push, single_long and long single?
How I can test it, if this is working?
Can I change the transition time between the triggers of the button?
Do you have additional tips for me?

Greetings from Germany

Generation 2 devices (The Shelly Plus ones) use the values btn_down, btn_up, single_push, double_push, triple_push and long_push as click_type according to Shelly - Home Assistant
That would be why those others doesn’t work.

I got the button to toggle my zigbee led panels on and off. Now how do I make so that holding the button in will dim my zigbee panel up and down in an infinite loop? So as long as I hold the button in it will dim up and down until released?

Hi,
thanks for the blueprint, however I dont get it working.
After I switched on the entity “input” I was able to see changes when switching my switch:
Screenshot 2023-10-04 221233
This is one cycle of switching on and off once.
only switching on seems to have the “long press” input switching off just gives a “Energy Erkannt”.
Mapping the “long press” to a szene works but none of the others do, I think its because switching off is not recognized the same way if this makes sence.
Some more Info:


Can somebody help me understand wha I am doing wrong?

I have found a workaroud in just using the entity states which I can see anyways and turn them in an automation, one for switch on and one for off, probably this helps others: