I set up a simple automation that listens to an MQTT topic and sends the messages ({{ trigger.payload }}
) to my phone.
It works well, except I get the following error if the message is a serialised JSON object:
template value should be a string for dictionary @ data['message']
Is there some way to cast trigger.payload
to a string, or to disable whatever is parsing the object in the first place? I tried {{ trigger.payload | string }}
, but it didn’t help.
For now I’ve switched to serialising the messages as YAML.
This topic seems vaguely similar: Automation trigger on MQTT message with JSON payload not triggering - #2 by 123
Automation YAML:
alias: My alert
description: ""
trigger:
- platform: mqtt
topic: mytopic
condition: []
action:
- device_id: deadbeef
domain: mobile_app
type: notify
message: "{{ trigger.payload }}"
title: Update
mode: single