Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rdeangel/45c18639f848158517b8618ed29fb9da to your computer and use it in GitHub Desktop.
Save rdeangel/45c18639f848158517b8618ed29fb9da to your computer and use it in GitHub Desktop.
Zigbee2MQTT - Sonoff 1-Button Switch (MQTT Subscribe Any - Filters Multiple Devices) - rdeangel
blueprint:
name: Zigbee2MQTT - Sonoff 1-Button Switch (MQTT Subscribe Any - Filters Multiple Devices) - rdeangel
description: "Blueprint Version: 12-01-25\n
Blueprint Name: Zigbee2MQTT - Sonoff 1-Button Switch (MQTT Subscribe Any - Filters Multiple Devices) - rdeangel\n\n
This blueprint subscribes to all Z2M Action topic `zigbee2mqtt/+/action`
and then filters the correct MQTT topic.\n
It takes multiple dropdown as the main filter condition to decide if the trigger should be considered for actions or ignored.\n
The fact that the automation triggers even when other mqtt devices actions are received it's not ideal, it does however
allow for multiple buttons to be driven by the same automation if that's what you are looking for.\n
Also If you want minor differences betweem multiple buttons and the buttons are mostly doing the same thing but you want to
introuduce minor variation you could do something like [this](http://community-assets.home-assistant.io.s3.dualstack.us-west-2.amazonaws.com/original/4X/b/0/c/b0c5341c606ddc1cc914e0f0f92b24c16dc20827.png)"
domain: automation
input:
mode:
name: Automation Modes
description: https://www.home-assistant.io/docs/automation/modes/
default: parallel
selector:
select:
mode: dropdown
options:
- single
- restart
- queued
- parallel
multiple: false
custom_value: false
sort: false
zigbee_device:
name: Zigbee Device - SNZB-01 (and alike)
description: Select the correct Zigbee device to use.
selector:
device:
integration: mqtt
multiple: true
single_press:
name: Single Press
description: Action to run on single press
default: []
selector:
action: {}
double_press:
name: Double Press
description: Action to run on double press
default: []
selector:
action: {}
long_press:
name: Long Press
description: Action to run on long press (4 seconds)
default: []
selector:
action: {}
source_url: https://gist.github.com/rdeangel/45c18639f848158517b8618ed29fb9da
mode: !input mode
max_exceeded: silent
trigger:
- platform: mqtt
topic: zigbee2mqtt/+/action
variables:
device_names: !input zigbee_device
expected_topics: "{% for device_name in device_names %}\n zigbee2mqtt/{{ device_attr(device_name,
'name') }}/action |\n{% endfor %}null\n"
condition:
- condition: template
value_template: '{{ trigger.topic in expected_topics }}'
action:
- variables:
command: "{{ trigger.payload }}"
- choose:
- conditions:
- "{{ command == 'single' }}"
sequence: !input single_press
- conditions:
- "{{ command == 'double' }}"
sequence: !input double_press
- conditions:
- "{{ command == 'long' or command == 'hold' }}"
sequence: !input long_press
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment