MQTT json value to a string

Hello, I’m trying to setup this automation .

the trigger is a json, and the value is checked in the condition part, this is working , as the action correctly sends the message if the message is a fixed string, but I’m not able to translate the json value into a string that the message can take.

How do I pass the mqtt json value as a string to the message parameter ?

alias: ‘CallerID 1’
trigger:
platform: mqtt
topic: home/sip
condition:
condition: template
value_template: ‘{{ “incoming” == trigger.payload_json.status }}’
action:
service: notify.salatv_tv
data:
message: ‘{{ trigger.payload_json.callerID }}’

Claudio

PS

here is the json value

{
“status”: “incoming”,
“callerID”:“391-555-5555”,
“uri”:“sip:[email protected];user=phone
}

OK

I’m going to reply to myself here:

changing data: to data_template: in the service section worked.

Thank you for listening.

Claudio

Glad you got it working. In future when pasting blocks of code don’t use the quote text option. Use the block quote ( </> button) as it preserves the indentation which is important. Aanother way is to put three backticks on a line above and below the block of code.

Ok, will do that, I’ll admit the code didn’t look good :slight_smile:

Claudio

1 Like