I have made an MQTT blueprint for the Shelly Button1. For some reason the Shelly integration for me did not work with the Shelly Button1, so I had to resort to MQTT. It’s annoying to set up MQTT automations for these buttons (especially if you have more), so hopefully this blueprint will ease the process quite a lot.
The blueprint requires an ID, which can be read from the Button’s web interface under Settings → Device Info → Device ID (eg.: E8DB48B6CADB). This is necessary to subscribe to the correct MQTT topic (Shelly Button1 API documentation).
The Button1 supports single, double and triple presses, and long presses, all of which can be automated with this blueprint.
Remember: You’ll need to have your own MQTT broker set up, and both Home Assistant (MQTT Integration) and the Shelly Button1 needs to use it (Shelly Button1 can be set up to use MQTT from its web interface).
To access the Shelly Button1’s web interface, it needs to be on USB charging.
blueprint:
name: MQTT - Shelly Button1
description: Trigger actions with a Shelly Button1 from MQTT. Remember to set your Shelly Button1 to MQTT mode, and point it (and Home Assistant) to your MQTT broker.
domain: automation
input:
shelly_button_id:
name: "Shelly Button1 Device ID"
description: "The Device ID of the Shelly Button1. Can be found on the web interface of the Shelly button under 'Settings -> Device Info'. (Eg.: XXXXXXXXXXXX)"
selector:
text:
single_press:
name: Single Press
description: The button is pressed 1 time.
default: []
selector:
action:
double_press:
name: Double Press
description: The button is pressed 2 times.
default: []
selector:
action:
triple_press:
name: Triple Press
description: The button is pressed 3 times.
default: []
selector:
action:
long_press:
name: Long Press
description: The button is long pressed (held down).
default: []
selector:
action:
trigger_variables:
button_id: !input shelly_button_id
## Example MQTT topic full path: shellies/shellybutton1-E8DB84A9BDBB/input_event/0
## Topic subscription using MQTT trigger limited templates: https://www.home-assistant.io/docs/automation/trigger/#mqtt-trigger
trigger:
- platform: mqtt
topic: "{{'shellies/shellybutton1-' ~ button_id ~ '/input_event/0'}}"
## Alternatively, you can just ask for the full topic in the input, but then you'll need to input the MQTT topic path, instead of just the device ID:
# trigger:
# - platform: mqtt
# topic: !input shelly_button_id
# # topic: !input input_mqtt_topic
condition: []
action:
choose:
- conditions:
- condition: template
value_template: '{{ trigger.payload_json.event == "S" }}'
sequence: !input single_press
- conditions:
- condition: template
value_template: '{{ trigger.payload_json.event == "SS" }}'
sequence: !input double_press
- conditions:
- condition: template
value_template: '{{ trigger.payload_json.event == "SSS" }}'
sequence: !input triple_press
- conditions:
- condition: template
value_template: '{{ trigger.payload_json.event == "L" }}'
sequence: !input long_press