Shelly i4 4 Buttons actions

This is a blueprint for the Shelly i4 4 Buttons.
You have access to each of the 4 Buttons and each the event down, up, single short press, double short press and long press.
You must have set up the switch with the shelly app, that all the inputs are buttons and not switches.

If your model is not shown in the dropdownlist, remove the line under input → model: SNSN-0024X.

Blueprint Code

Click the badge to import this Blueprint: (needs Home Assistant Core that supports the Shelly i4)

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Or import this Blueprint by using the forum topic URL:

blueprint:
  name: Shelly i4 4 Buttons actions
  description: This blueprint is for the Shelly i4 setup as button. It is for general use.
  domain: automation
  input:
    button:
      name: button
      description: Choose Shelly i4
      selector:
        device:
          manufacturer: Shelly
          model: SNSN-0024X
          multiple: false
    downb1:
      name: Down Button 1
      description: Action to run when SHORT press
      default: []
      selector:
        action: {}
    upb1:
      name: up Button 1
      description: Action to run when SHORT press
      default: []
      selector:
        action: {}
    singleb1:
      name: single short press Button 1
      description: Action to run when SHORT press
      default: []
      selector:
        action: {}
    doubleb1:
      name: double short press Button 1
      description: Action to run when DOUBLE SHORT press
      default: []
      selector:
        action: {}
    longb1:
      name: long press Button 1
      description: Action to run when LONG press
      default: []
      selector:
        action: {}
        
    downb2:
      name: Down Button 2
      description: Action to run when SHORT press
      default: []
      selector:
        action: {}
    upb2:
      name: up Button 2
      description: Action to run when SHORT press
      default: []
      selector:
        action: {}
    singleb2:
      name: single short press Button 2
      description: Action to run when SHORT press
      default: []
      selector:
        action: {}
    doubleb2:
      name: double short press Button 2
      description: Action to run when DOUBLE SHORT press
      default: []
      selector:
        action: {}
    longb2:
      name: long press Button 2
      description: Action to run when LONG press
      default: []
      selector:
        action: {}
        
    downb3:
      name: Down Button 3
      description: Action to run when SHORT press
      default: []
      selector:
        action: {}
    upb3:
      name: up Button 3
      description: Action to run when SHORT press
      default: []
      selector:
        action: {}
    singleb3:
      name: single short press Button 3
      description: Action to run when SHORT press
      default: []
      selector:
        action: {}
    doubleb3:
      name: double short press Button 3
      description: Action to run when DOUBLE SHORT press
      default: []
      selector:
        action: {}
    longb3:
      name: long press Button 3
      description: Action to run when LONG press
      default: []
      selector:
        action: {}
        
    downb4:
      name: Down Button 4
      description: Action to run when SHORT press
      default: []
      selector:
        action: {}
    upb4:
      name: up Button 4
      description: Action to run when SHORT press
      default: []
      selector:
        action: {}
    singleb4:
      name: single short press Button 4
      description: Action to run when SHORT press
      default: []
      selector:
        action: {}
    doubleb4:
      name: double short press Button 4
      description: Action to run when DOUBLE SHORT press
      default: []
      selector:
        action: {}
    longb4:
      name: long press Button 4
      description: Action to run when LONG press
      default: []
      selector:
        action: {}
  source_url: https://community.home-assistant.io/t/shelly-i4-4-buttons-actions/514527
mode: restart
max_exceeded: silent
trigger:
- platform: device
  device_id: !input  button
  domain: shelly
  type: btn_down
  subtype: button1
  id: btn1_down
- platform: device
  device_id: !input  button
  domain: shelly
  type: btn_up
  subtype: button1
  id: btn1_up
- platform: device
  device_id: !input  button
  domain: shelly
  type: single_push
  subtype: button1
  id: btn1_single
- platform: device
  device_id: !input  button
  domain: shelly
  type: double_push
  subtype: button1
  id: btn1_double
- platform: device
  device_id: !input  button
  domain: shelly
  type: long_push
  subtype: button1
  id: btn1_long
  
- platform: device
  device_id: !input  button
  domain: shelly
  type: btn_down
  subtype: button2
  id: btn2_down
- platform: device
  device_id: !input  button
  domain: shelly
  type: btn_up
  subtype: button2
  id: btn2_up
- platform: device
  device_id: !input  button
  domain: shelly
  type: single_push
  subtype: button2
  id: btn2_single
- platform: device
  device_id: !input  button
  domain: shelly
  type: double_push
  subtype: button2
  id: btn2_double
- platform: device
  device_id: !input  button
  domain: shelly
  type: long_push
  subtype: button2
  id: btn2_long
  
- platform: device
  device_id: !input  button
  domain: shelly
  type: btn_down
  subtype: button3
  id: btn3_down
- platform: device
  device_id: !input  button
  domain: shelly
  type: btn_up
  subtype: button3
  id: btn3_up
- platform: device
  device_id: !input  button
  domain: shelly
  type: single_push
  subtype: button3
  id: btn3_single
- platform: device
  device_id: !input  button
  domain: shelly
  type: double_push
  subtype: button3
  id: btn3_double
- platform: device
  device_id: !input  button
  domain: shelly
  type: long_push
  subtype: button3
  id: btn3_long
  
- platform: device
  device_id: !input  button
  domain: shelly
  type: btn_down
  subtype: button4
  id: btn4_down
- platform: device
  device_id: !input  button
  domain: shelly
  type: btn_up
  subtype: button4
  id: btn4_up
- platform: device
  device_id: !input  button
  domain: shelly
  type: single_push
  subtype: button4
  id: btn4_single
- platform: device
  device_id: !input  button
  domain: shelly
  type: double_push
  subtype: button4
  id: btn4_double
- platform: device
  device_id: !input  button
  domain: shelly
  type: long_push
  subtype: button4
  id: btn4_long
action:
- choose:
  - conditions:
    - condition: trigger
      id: btn1_down
    sequence: !input downb1
  - conditions:
    - condition: trigger
      id: btn1_up
    sequence: !input upb1
  - conditions:
    - condition: trigger
      id: btn1_single
    sequence: !input singleb1
  - conditions:
    - condition: trigger
      id: btn1_double
    sequence: !input doubleb1
  - conditions:
    - condition: trigger
      id: btn1_long
    sequence: !input longb1

  - conditions:
    - condition: trigger
      id: btn2_down
    sequence: !input downb2
  - conditions:
    - condition: trigger
      id: btn2_up
    sequence: !input upb2
  - conditions:
    - condition: trigger
      id: btn2_single
    sequence: !input singleb2
  - conditions:
    - condition: trigger
      id: btn2_double
    sequence: !input doubleb2
  - conditions:
    - condition: trigger
      id: btn2_long
    sequence: !input longb2

  - conditions:  
    - condition: trigger
      id: btn3_down
    sequence: !input downb3
  - conditions:
    - condition: trigger
      id: btn3_up
    sequence: !input upb3
  - conditions:
    - condition: trigger
      id: btn3_single
    sequence: !input singleb3
  - conditions:
    - condition: trigger
      id: btn3_double
    sequence: !input doubleb3
  - conditions:
    - condition: trigger
      id: btn3_long
    sequence: !input longb3

  - conditions:
    - condition: trigger
      id: btn4_down
    sequence: !input downb4
  - conditions:
    - condition: trigger
      id: btn4_up
    sequence: !input upb4
  - conditions:
    - condition: trigger
      id: btn4_single
    sequence: !input singleb4
  - conditions:
    - condition: trigger
      id: btn4_double
    sequence: !input doubleb4
  - conditions:
    - condition: trigger
      id: btn4_long
    sequence: !input longb4
  
3 Likes

@Danieldz Very nice!! I have been looking for this for a long time. I always wondered how the scenes I have defined in the Shelly environment could be re-used in Home Assistant. I will certainly use this!

1 Like

Thanks for the blueprint, I will put it to good use soon :smile:

I wasn’t able to have the i4 fire the triple_push event, according to the offcial Shelly docs it should be supported.

Any of you managed?

I was wondering the same thing, but with a Shelly 2PM. Looks like it has been added a few days ago.

Nice catch! I was I bit puzzled because in the product page the triple_push is not listed anymore as one of the possible actions, but it is in the API docs :thinking:

Thanks a lot for providing this great blueprint.

Can somebody tell me how I set a light color of a hue bulb when toggling it on?

Please forgive me as a Homeassistant novice for the following question.

Today I got a Shelly Button 1 (under the settings/properties it is called strangely in the Shelly Button 2?) and I want different versions depending on whether I press the button 1x, 2x or 3x.

Now it is of course very easy to configure this only in the Shelly Application via Cloud and it currently works in the test. (Press once -garage door opens, press again, garage door closes.).

Now to my beginner question. I would like to have the following target configuration:
1x press: control garage door open / close (as currently functional in test).
2x press: Set boolean value in HA (I always check in the evening at a door without electric lock whether it is locked and would like to map here this control step in HA. E.g. that I then get an alarm if I have not clicked this control step into the system by 23 o’clock).
Press 3x: An action not yet defined, could be e.g. “turn off all lights in the house via HA”.

How can I map these usecases? Is it possible to “mix” the settings from the Shelly cloud (scene) with actions from HA? Or is it better to map everything via HA (however?)? The configuration depending on the number of clicks ( = number of presses on button) I imagine relatively complex, if I look at the code above so.

I look forward to your feedback (gladly also by PN in German if you prefer) and would then dedicate the first closing round to you :slight_smile:

Thanks a lot, Franz

Hi there. Attempting to use this blueprint, I am unable to save any changes. Trying to save even the blank blueprint throws the following error:

Message malformed: Invalid (type,subtype): ('btn_down', 'button1')

Any ideas?

I’m a fool. My first Shelly device… I simply set the inputs to Button.

image

Hi @Danieldz, thanks for creating this.
@gfra I wanted the triple push as well, so modified this version to add triple push actions and here it is: shelly-i4-4-buttons-actions.yaml · GitHub