I want to pass the trigger payload from MQTT to the action, a rhasspy_speak event. The yaml looks like this:
- id: '1653688305070'
alias: MQTT test
description: ''
trigger:
- platform: mqtt
topic: test
condition: []
action:
- service: rest_command.rhasspy_speak
data:
payload: trigger.payload
mode: single
The trigger is from a terminal: mosquitto_pub -h 127.0.0.1 -t “test” -m “hello world”
On being triggered by MQTT, rhasspy says “trigger.payload” instead of “hello world.” How can I pass the MQTT payload to the action? Thanks.
When this is set, rhasspy reads it verbatim (“left curly bracket”, etc.) then HA set the yaml to read:
‘’’
payload:
‘[object Object]’: null
‘’’
then reads that verbatim on next trigger. I’m thinking I have to declare the variable before using it?
This will not work the way you expect it to, sorry. And it is not the way Rhasspy recommends doing such a thing.
There is an extra endpoint in the API from Rhasspy to get text to speech. Especially important is the use of sessions, as these are opened when you speak, and are normally closed when HA gets back to Rhasspy.
The next thing is, payload isn’t something Rhasspy usually sends. If you stayed with the “official” install instructions, it will likely be trigger.event.data.xxx where “xxx” is the substitution from Rhasspy.
I’d recommend to use the Rhasspy defaults, as there are is a lot more help available, if you just Rhasspys “events” or “intents”, both of which are especially tailored for the use of Rhasspy in combination with HA.
Rhasspy is used here in the action, not the trigger. MQTT is the trigger. I want to send the message received by MQTT to the service RESTful Command :rhasspy_speak as the payload to be spoken. that command is in configuration.yaml and appears in the dropdown for call service under actions:
The Visual Editor has several limitations and when it can’t handle something it often reports it as a warning and then suggests to switch to YAML mode. What I suggested is correct; the Visual Editor’s warning isn’t the problem.
According to the documentation for MQTT Trigger, trigger.payload is a valid way to reference the received payload. However, to get the value of trigger.payload you have to employ it in a template in the manner I posted above.
and I’m calling it with this in the template editor (in my setup I call it from an alert):
service: rest_command.rhasspy_notification
data:
payload_text: 'Tell me something'
I can’t see any difference between yours and mine, so it must be something different, maybe some setup in Rhasspy? Or the dumbest of all possibilities, the naming with “payload” vs. “payload_text”?
I’m thinking now that MQTT trigger only tests the message as a condition and can’t pass its content to the action. Perhaps MQTT sensor does that. If anyone has a way for trigger to pass the payload content to action, maybe they’ll give an example.
According to the documentation @123 linked above, why would than be “payload” available? I don’t think that would be available, if it won’t get passed through.
Have you checked the mqtt topic/message with ie. MQTT-Explorer? Not that the mqtt call would be something difficult, but who knows…
I’d suggest to go step-by-step, check the mqtt topic, check if HA accepts that topic and so on. Tedious debug work.
A short search here in the forum brought up nothing new, but this post: