Templating in a RESTful command

Hi
i am trying to create an automation that stores last volume level of my AVR and another to restore it later.

the first part already works via input_text helper (couldn’t get it to work with input_number)

what i am having trouble with is the latter part, restoring this value. i can control the Denon Volume via simple URL-calls, like so:

"http://DENON-IP/goform/formiPhoneAppDirect.xml?MV35"

in this example it will change volume to “35”, works like a charm.

so for my intents and purposes i tried the following in config.yaml. but it doesn’t work :frowning:

  denon_set_last_vol:
    url: "http://DENON-IP/goform/formiPhoneAppDirect.xml?MV"
    method: GET
    headers:
      content_type: 'text/plain'
    payload: '{{states('input_text.denon_last_volume_text')|float}}'

neither does it work if i try the following for testing purposes

payload: '35'

maybe somebody has an idea. much appreciated. thanks!

I think you need:

  denon_set_last_vol:
    url: "http://DENON-IP/goform/formiPhoneAppDirect.xml?MV{{ states('input_text.denon_last_volume_text')|int}}"
    method: GET
    headers:
      content_type: 'text/plain'

thanks for the reply!!

i had already tried this but your suggestion still allowed me to find the answer.

The Denon AVR only accepts whole numbers (no floats) in my testing i had always used 29.5 as a value and it never worked.

appended float() | round(0) to the template and now it works

thanks again! i love this community

So what was the final code?
Others might find it useful

rest_command:
  denon_set_last_vol:
    url: "http://DENON-IP/goform/formiPhoneAppDirect.xml?MV{{ states('input_number.denon_last_volume_number') | float() | round(0)}}"
    method: GET
    headers:
      content_type: 'text/plain'

(got the automation working w input_number as well in the process (instead of input_text))

Float and round(0) is the same thing as int.