Trigger different actions on a single, double or double click on a binary sensor

Thanks, slashback, But I don’t understand that.

Anyone know how I can use this with a Shelly dimmer 2 connected to 2 momentary switches using mqtt. I can make a binary sensor that detects the relay state but not the switch state so if I press the switch it sends an mqtt message to on but doesn’t trigger back to off when I let go of the button. Thanks

I would create a binary sensor entity that changes on each mqtt message (on or off) on your topic (or on each transition of your binary_sensor), and configure your automation on that switch.

Well, you are talking about a group of light so either you have an entity group.your_group referencing your lights, or you have a light group (Light Group - Home Assistant) referencing your lights.
Just set this group entity in the parameter of the service light.toggle that you will use in the long_click_action, short_click_action or double_click_action of the automation based on this blueprint

I’m attempting to make an existing Zigbee switch do double duty by adding an automation to perform an action on a double click, using this blueprint.

Sadly, the Device dropdown only shows a VERY short list of devices, 8 to be precise, while I have about 100 devices.

I don’t know if this is a blueprint problem or an HA problem.

Troubleshooting this is beyond my abilities and picking the wrong device and then manually editing the resulting YAML doesn’t seem to work either.

So I simply did some rewiring; cut a new rectangular hole in the wall, installed a box, brought power to the box, and installed another Zigbee switch. A conventional “on press” automation works fine.

This is what I was hoping to avoid with a smart house, a proliferation of switches, but working is the most important thing, and this works.

Nice blueprint.
is there a way to repeat an action?
e.g. when doing longpress it should keep increasing the brightness level on a light, until button is released.

Yes. Here is what I have for one of my light:

            long_click_action:
              - choose: #if light not 100% -> increase intensity 
                  - conditions: "{{ state_attr('light.l_cinema_lampe', 'brightness') | float < 255 }}"
                    sequence:
                      - repeat:
                            sequence:
                              - service: light.turn_on
                                data:
                                  entity_id: light.l_cinema_lampe
                                  brightness_step_pct: 5
                              - delay: 0.2
                            until: # until the button is pushed and the light intensity not at 100%
                              - condition: template
                                value_template: "{{ is_state('binary_sensor.cinema', 'off') or state_attr('light.l_cinema_lampe', 'brightness') | float == 255 }}"
                default: #otherwise, decrease intensity
                  - repeat:
                        sequence:
                          - service: light.turn_on
                            data:
                              entity_id: light.l_cinema_lampe
                              brightness_step_pct: -5
                          - delay: 0.2
                        until: #as long as the button is pushed and the light intensity not at 0%
                          - condition: template
                            value_template: "{{ is_state('binary_sensor.cinema', 'off') or state_attr('light.l_cinema_lampe', 'brightness') == None or state_attr('light.l_cinema_lampe', 'brightness') | float == 0 }}"
                  - choose:
                      - conditions: "{{ state_attr('light.l_cinema_lampe', 'brightness') == 0 or state_attr('light.l_cinema_lampe', 'brightness') == None }}"
                        sequence:
                          - service: light.turn_off
                            data:
                              entity_id: light.l_cinema_lampe

Awesome. Thanks. a nice feature request if it could be build into the blueprint.

Seems to me more logical to put it in a script and call the script in the automation

dim_light:
    fields:
        button:
            description: The binary sensor entity
        light:
            description: The light entity

    sequence:
      - choose: #if light not 100% -> increase intensity 
          - conditions: "{{ state_attr(light, 'brightness') | float < 255 }}"
            sequence:
              - repeat:
                    sequence:
                      - service: light.turn_on
                        data:
                          entity_id: '{{ light }}'
                          brightness_step_pct: 5
                      - delay: 0.2
                    until: # until the button is pushed and the light intensity not at 100%
                      - condition: template
                        value_template: "{{ is_state(button, 'off') or state_attr(light, 'brightness') | float == 255 }}"
        default: #otherwise, decrease intensity
          - repeat:
                sequence:
                  - service: light.turn_on
                    data:
                      entity_id: '{{ light }}'
                      brightness_step_pct: -5
                  - delay: 0.2
                until: #as long as the button is pushed and the light intensity not at 0%
                  - condition: template
                    value_template: "{{ is_state(button, 'off') or state_attr(light, 'brightness') == None or state_attr(light, 'brightness') | float == 0 }}"
          - choose:
              - conditions: "{{ state_attr(light, 'brightness') == 0 or state_attr(light, 'brightness') == None }}"
                sequence:
                  - service: light.turn_off
                    data:
                      entity_id: '{{ light }}'