Calling this service and setting the “to”, “title”, and “message” fields work great. However, I want to use a template to send sensor values in the message
If you are using the developer tools (call service tab) to send the data over, it won’t work. That tab is meant for debugging and it does not resolve templates.
Your code will work in a data_template field in an service call.
- service: rest_command.xxxxx
data_template:
to: abc
title: CPU Temp
message: CPU Temp is {{states('sensor.cpu_temp')}}
or
- service: rest_command.xxxxx
data_template:{"to":"abc","title":"CPU Temp","message":"CPU Temp is {{states('sensor.cpu_temp')}}"}
Hmm… I tried this and it looks like I can use existing services in an automation/script; but what I want to do is create/define a new (custom) service with a data template as suggested by @petro.