Hi everyone,
I’m hoping someone can shed some light on a baffling issue I’m having with MQTT triggers defined within a blueprint. I’m running Home Assistant Core 2025.3.4 but my challenge to get this working existed before that version as well. Below, my apologies as I’ve replaced some of my topics, etc. for generic purposes here.
The Goal: I’m trying to create a blueprint that listens to MQTT messages from a Tasmota device (specifically the stat/.../RESULT
topic containing button press actions like {"Button1":{"Action":"SINGLE"}}
) to basically select which light (recording this to a helper), then use buttons 3/2 to dim up/down respectively. The device I am working on is a MJ SD01 with Tasmota 14.4.1. Everything is fine when I manually specify the mqtt trigger, but the failure point, through dozens of trials to refine this, is the use of variables to define the mqtt trigger.
- MQTT Messages Received: Using the Home Assistant Developer Tools MQTT listener, I can clearly see the correct JSON payloads arriving on the correct
stat/YOUR_TASMOTA_BASE_TOPIC/RESULT
topic when I press the buttons. - Standalone Automation Works: If I create a simple, standalone automation (not using a blueprint) with the
platform: mqtt
,topic:
, andpayload:
hardcoded to match the exact message seen in the listener, it triggers perfectly every time.
This strongly suggests the issue lies specifically with how MQTT triggers are processed when defined within a blueprint, potentially related to how variables/inputs are templated in the 'topic
or payload
fields.
Troubleshooting Steps Taken:
- Confirmed MQTT messages are correct via Tasmota console and HA MQTT listener.
- Verified the automation created from the blueprint is enabled.
- Verified blueprint inputs (
mqtt_device_topic
,button_number
, helpers) are correct in the automation’s configuration. - Corrected an initial template syntax error (using
!input
inside{{}}
). - Tried using direct templating in the trigger (e.g.,
topic: "stat/{{ mqtt_device_topic }}/RESULT"
). → Failed - Tried pre-computing the full trigger topic/payload strings in a
variables:
block and referencing those variables in the trigger (e.g.,topic: "{{ trigger_topic_str }}"
). → Failed - Created a drastically simplified blueprint focusing only on a single button press trigger/action. → Failed
- Reloaded blueprints and restarted Home Assistant Core multiple times.
- Checked HA Core logs - no errors appear related to the automation or triggers when buttons are pressed.
Code Examples:
1. Non-Working Simplified Blueprint (your_simple_blueprint_filename.yaml
): (This version tries pre-computing variables)
blueprint:
name: Tasmota Simple Test - Button 1 Single Press
description: |-
Further simplified blueprint for testing Button 1 single press MQTT trigger.
Uses intermediate variables for trigger construction.
domain: automation
input:
mqtt_device_topic:
name: Tasmota Device Base Topic
description: The base topic of your Tasmota device (e.g., tasmota_XXXXXX).
default: ""
button_number:
name: Button Number for Single Press
description: The button number on your Tasmota device (usually 1).
default: 1
selector:
number:
min: 1
max: 8
mode: box
single_press_device:
name: Device for Single Press
description: The light entity to be toggled on single press.
selector:
entity:
domain: light
selected_light_helper:
name: Selected Light Helper (Input Text)
description: An input_text helper to store the entity_id of the toggled light.
selector:
entity:
domain: input_text
variables:
# Assign inputs to intermediate variables
var_topic_base: !input mqtt_device_topic
var_button_num: !input button_number
# Construct full trigger strings using intermediate variables
trigger_topic_str: "stat/{{ var_topic_base }}/RESULT"
trigger_payload_str: '{"Button{{ var_button_num }}":{"Action":"SINGLE"}}'
trigger:
# Reference the fully constructed variables
- platform: mqtt
topic: "{{ trigger_topic_str }}"
payload: "{{ trigger_payload_str }}"
id: primary_single
condition: [] # No conditions
action:
# Action remains the same
- choose:
- conditions:
- condition: trigger
id: primary_single
sequence:
- service: light.toggle
target:
entity_id: !input single_press_device
- service: input_text.set_value
target:
entity_id: !input selected_light_helper
data:
value: !input single_press_device
default: []
mode: restart
2. Working Standalone Automation (YAML):
alias: MQTT Trigger Test - Button 1 Single
description: "Temporary test for MQTT trigger"
trigger:
- platform: mqtt
topic: stat/YOUR_TASMOTA_BASE_TOPIC/RESULT # Hardcoded topic
payload: '{"Button1":{"Action":"SINGLE"}}' # Hardcoded payload
id: test_trigger
condition: []
action:
- service: persistent_notification.create # Simple action
data:
message: "MQTT Test Trigger Fired Successfully!"
notification_id: "{{ trigger.id }}"
mode: single
3. Example MQTT Message (from HA Listener): Topic: stat/YOUR_TASMOTA_BASE_TOPIC/RESULT
Payload: {"Button1":{"Action":"SINGLE"}}
4. Example Automation Config from Blueprint (Non-working):
alias: (Your Automation Name) # Example name
description: ""
use_blueprint:
path: your_simple_blueprint_filename.yaml # Or whatever the filename is
input:
mqtt_device_topic: YOUR_TASMOTA_BASE_TOPIC
button_number: 1
single_press_device: light.your_single_press_light # Example light
selected_light_helper: input_text.your_selection_helper # Example helper
Question: Has anyone else encountered issues with platform: mqtt
triggers defined inside blueprints failing like this? I searched for a while, so my apologies if I am duplicating another thread. Is there a known bug, a different required syntax for templating MQTT topics/payloads in blueprints, or any other debugging step I might be missing?
Thanks so much for any helpful insights you can offer!