I would like to call a service using MQTT.
I want to send an MQTT message to my Home Assistant instance with the following JSON payload:
{ "service" : "service_to_trigger", "data" : "data_for_the_service" }
I have the following automation set up:
alias: PW service call request
description: ''
trigger:
- platform: mqtt
topic: pixelweather/request/call_service
condition: []
action:
- service: '{{trigger.payload_json["service"]}}'
data: {{{trigger.payload_json["data"]}}}
mode: single
Unfortunately, for some reason, I can’t save this automation. I’m assuming that there’s a syntax error, specifically with data: {{{trigger.payload_json["data"]}}}
. This is most likely invalid syntax, but I could not find any similar example in the documentation, so I have no idea what the correct syntax would be. I don’t even know if something like this can be done. I know it would be easier if I created multiple automations for each service I want to call, but an automation like this would be universal.