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
  
5 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.

1 Like

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

1 Like

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

2 Likes

Hello,
thank you very much for this blueprint. I love it!

There is one thing, I need your help:

I created an automation, which switches lights (3 buttons of the i4). This works perfectly.
With button number 4, I want to switch all lights of.
For buton nu,mber 4, I can create a device action for every single light, home assistant switches them of with a short delay, what means that the lights are not switched off simultaneously, but one after the other.

In /config/configuration.yaml, I have created a group “all lights” with several entities. This entitiy works in the lovelace cards, but I dont find a solution to select this entitiy in the blueprint.

Can you please show me a way for this?

Thank you.

I have tried the blueprint and it works flawlessly, thank you for that. I wanted to make a button to increase the brightness of a smart bulb however I can’t find a way to keep increasing the light while holding the button, is there any way I can do that using the i4 ?

I am looking for the exact same, please led me know if you found a solution.

Atm i have an automation which just dims 5% every time i do a long push.
But i want to have it keep dimming untill release.

hi,

thanks for this blueprint. my shelly i4 is integrated in HA but this blueprint cannot find my shelly i4!?
why? has anybody an idea???

with fileeditor i deleted already a few commands and now the shelly is available but the following issue ----->
Message malformed: Integration ‘shelly’ does not support device automation triggers

I got the same message as well. In the end I got rid of the blueprint, went into the shelly itself via IP. Changed the button type to button for all four buttons. The buttons then showed up in home assistant as buttons. Now all triggers (single/double/tripple press, long press) available through regular automations.

Did you copy the automation, or did you somehow copy parts of the blueprint? I am having this issues a lot when I make use of copyiing or duplicating. Start from scratch.

Hi there, quick question, I see there is a function that lets you configure something on the ‘short press button up’, I would like to have something happen on ‘long press up’. Is that possible, does anyone know if/how this can be achieved?

Many thanks and happy holidays!

-d

I got the same message as well. Unfortunately I don’t know what to do. I can’t save the BluePrint (rename) because I always get the message “Message malformed: Invalid (type,subtype): (‘btn_down’, ‘button1’)”

HI,
I had the same problem with the
“Message malformed: Invalid (type,subtype): (‘btn_down’, ‘button1’)"
I manually use a browser and opened the shelly via IP, and than I changed al buttons from “switch” to button.
I than had to delete the Shelly-I4 from HomeAssistant. I re-startet HA (just to be save) and than I integrated the Shelly-i4 again. Than it worked.

thanks
Juergen

Hi,
Just wondering: what integration are you using? Is it the ShellyForHass (shelly integration), or the newer Shelly Smart Home Custom integration?
I’m using the newer, and get the message “Message malformed: Integration ‘shelly’ does not support device automation triggers” when trying to save/rename the Blueprint. Also I had to remove both ‘manufactorer’ and ‘model’ from the Blueprint to be able to choose the i4.

Would be nice to know before just trying…!
Thanks, Konrad