I use a service, voip.ms, which has a REST API, however it is implemented exclusively with HTTP GET requests. The RESTful Command integration does currently support GET requests; however, unlike the RESTful sensor integration, it does not allow parameters to be specified. This means that my API key, which is stored in a secret, cannot be easily used in a REST command. Instead, the full command URL with all parameters must be saved as a separate secret. Any changes to my API key need to be updated in multiple secrets, and commands cannot be dynamically generated based on variables, sensors, or user input, but rather must be hardcoded in advance.
This could be solved with templating, but that would require my API key to be stored in my configuration.yaml file instead of as a secret.
Here is an example of what I mean:
sensor:
- platform: rest
name: voipms_balance
resource: https://voip.ms/api/v1/rest.php
params:
api_username: !secret voipms_user
api_password: !secret voipms_pass
method: getBalance
value_template: '{{ value_json["balance"]["current_balance"] | round(2) }}'
unit_of_measurement: "$"
This sensor retrieves my account balance using secrets for username and password. For changes to my account, the yaml looks like this:
rest_command:
example_command1:
url: !secret voipms_do_something
method: GET
verify_ssl: true
example_command2:
url: !secret voipms_do_something_else
method: GET
verify_ssl: true
As you can see, I have had to hardcode the entire command as a secret in order to preserve the secrecy of my API key, since there is no way to concatenate it with a URL string. This is not an issue with the sensor however, since parameters can individually be specified.