Restful command does not find item

Hi,

I’d need a bit help getting restful command sent with parameters taken from other items, I have created buttons using lovelace gui for replicating AC remote.

I’ve created also automation which calls rest command if such send button is pressed. So far it works, button calls the automation.

Then I have done rest command like this, in configuration.yml:


heatpump_with_params:
    url: http://192.168.1.100:1880/api
    method: POST
    content_type: "application/json"
    headers:
       accept: "application/json"
    payload: '{ "token": "xxxx", "cmd":"on", "temp":"{{ states(input_number.heatpump_temp) | int }}", "mode":"{{ states(input_select.heatpump_mode) }}", "fan": "{{ states(input_select.heatpump_fan) }}" }'

But such variables are not found. The entity ids are copied from items, so no spelling mistakes should be there.

What is wrong with the syntax?

Error:

Stopped because an error was encountered at August 3, 2022 at 12:09:18 (runtime: 0.02 seconds)

UndefinedError: 'input_number' is undefined

I’m using node-red controlled arduino as the rest api, which is documented here. The API could make use of the values set by user in HA gui. https://github.com/ikke-t/toshiba-ac-ir-remote

The entity names need to be in quotes. Unfortunately you have already used single and double quotes here. The simplest workaround may be to put the payload onto a new line:

    payload: >
      { "token": "xxxx", "cmd":"on", "temp":"{{ states('input_number.heatpump_temp') | int }}", "mode":"{{ states('input_select.heatpump_mode') }}", "fan": "{{ states('input_select.heatpump_fan') }}" }
1 Like

That was it, thanks! I tried and failed with all different backslash combos…

1 Like