Rest_command data input using template

When I enter this code,

service: rest_command.poolaction
data:
action_code: 5
device_number: 1
value: {{states(‘input_number.pool_heater_setpoint’)}}

it saves as:

  • service: rest_command.poolaction
    data:
    action_code: 5
    device_number: 1
    value:
    “[object Object]”: null

I’ve checked the template in the template editor under developer tools and it works fine. Any suggestions?

thankyou

Please format your pasted code correctly as per section 11 of the forum FAQ.

You need to quote single line templates.

1 Like

This is what I put into yaml

action:
  - service: rest_command.poolaction
    data:
      action_code: 5
      device_number: 1
      value: {{states('input_number.pool_heater_setpoint')}}

This is what shows after saving:

action:
  - service: rest_command.poolaction
    data:
      action_code: 5
      device_number: 1
      value:
        "[object Object]": null

As I said:

value: "{{ states('input_number.pool_heater_setpoint') }}"

that suggestion returns a string rather than a number and as such, is not triggering the correct downstream response. Is there something further that you can suggest?

Fix your downstream response.

unfortunately, that is not possible. I am feeding instructions to a cloud based intermediary that is then instructing my pool controller what to do. this is the only piece I have not been able to get working… thanks for your help

value: >
   {{ states('input_number.pool_heater_setpoint')|float(0) }}

excellent!. float(0) didn’t work but I changed it to int and success!

with thanks