RESTful Sensor with payload template

It appears like that the restful sensors do not support providing a template for the payload attribute, making it seemingly impossible to provide any variables or dynamic data in the request payload.

a) Is there some form of workaround? I guess I could use a shell command sensor and just use curl?
b) Is this something the HA team has considered adding? I would assume it’s a reasonably common use-case and shouldn’t be too complicated to add. A lot of the other attributes for RESTful sensors already support templates.

Found this: RESTful sensor: please allow templates for the Post payload

Did that: Add a template version of the RESTful payload attribute by DanielBaulig · Pull Request #73106 · home-assistant/core · GitHub

1 Like

Any update on this as I’m trying to send a token via payload that keeps renewing it every 24 hours and I don’t need type it manually

This is not something that I have a current personal need for anymore, so it’s not very high on my priorities list. If someone else wants to put up a new pull request based on my old one, I’d be more than happy to support that.

Otherwise I might get to it at some time. It seems useful to a lot of people. But can’t make any promises or commitments to timelines.

Appreciate the reply, if you have a workaround you can direct me to it that would be helpful

Depending on what you are trying to do specifically this may or may not work for you, but you could use a shell_command that calls out into curl (assuming curl is installed on the host/container) or into a python shell script that uses Python requests to send those requests.

You can retrieve returned data with service return values and you can provide arguments to shell_command using the data property. See the documentation for details.