Rest commands

I am getting very confused about Rest commands.

I have an action in a script that should just post the following:

"http://xxxxxxxxxi/water-tank-back/insert_data.php?dist={{ cmvalue }}"

cmvalue is a sensor value that is literally just a float number in text form e.g. 38.1

All this call should do is pass that cmvalue into a php file on a web page.

I have tried many things but currently, I have this:

in configuration.yaml:

rest_command: !include rest_commands.yaml

in rest_commands.yaml:

water_tank_back_garden_cmd:
  url: "http://raspberrypihifi/water-tank-back/insert_data.php?dist={{ cmvalue }}"
  method: POST

action in my script:

  - service: rest_command.water_tank_back_garden_cmd
    data:
      cmvalue: "{{ states('input_text.water_tank_back_garden_distance_in_cm' }}"

I get 2 related issues in the script:

  1. Error in describing action: Cannot read properties of undefined (reading ‘water_tank_back_garden_cmd’)

  2. If I actually carry on and try to run that step, it does not recognise rest_command.water_tank_back_garden_cmd

I have used rest: rather than rest_command: for other calls in my system but these do not seem compatible. I really am struggling here with the simplest of calls. Anyone help?

You have to use something like this:

water_tank_back_garden_cmd:
  url: "http://raspberrypihifi/water-tank-back/insert_data.php?dist={{ states('input_text.water_tank_back_garden_distance_in_cm')}}"
  method: POST
service: rest_command.water_tank_back_garden_cmd
data: {}

I believe I had tried that code before. Adding cmvalue as a separate variable and setting in the call was my latest attempt but I did have the sensor state in the url earlier.

I did directly copy your suggestions anyway and retried, making sure that all yaml was reloaded.

Still getting

Unable to find service rest_command.water_tank_back_garden_cmd

The error is different from the previous ones.

Have you tried restarting HA instead of reloading?

Yes, if this is the first time you configure something for a platform, you must restart HA. After that you can reload a platform (if supported by the UI).

Your config looks correct to me.