On your command line, \ is being used as an escape character, which means the double quotes are being passed literally instead of enclosing strings. So instead of curl seeing a -H flag with the string Authorization: Bearer ABCDEFGH, it gets a -H flag with the string "Authorization, followed by a separate argument Bearer, which it interprets as a hostname. hence the “Could not resolve host” errors.
Thank you. I am getting closer. Now, the only error I get is, 400: Bad Request. What am I doing wrong? I definitely have my long-lasting token and entity-id correct.
This is the command-line I’m using exactly character for character:
I also enabled debug logging by adding: logger: to my configuration file. However, I don’t see anything in the System log when I POST API requests; and, get the response: 400: Bad Request. It seems like a major PITA just to do a simple API request using CURL.
EDIT: I also added an api: entry to my configuration.yaml file and rebooted. I wasn’t even sure if I was supposed to do that. However, that didn’t make any difference. I am still getting a 400: Bad Request response.
I just updated the original post with the new issue I’m facing. I would really appreciate help to troubleshoot this. I’m getting a 400: Bad Request response. Please see the command-line I’m using. I enabled debug logging, however, I don’t any information in the system log for API requests I’m making.
That really depends on how it it set up in HA. Don’t have Z-wave myself so I can’t tell how it is normally recognized by HA.
After you get it and set up in HA, you should be able to find it in the Developer Tools\States and use the appropriate service.
Thanks to everyone on here! I finally found a way to ditch the IFTTT webhook I was using and turn off a plug though HA via batch file in Windows. I’m not sure I would have been able to get the context right if I hadn’t found this thread.
I asked chatgpt for some help and I’m now using this curl command to fire a service on my home assistant (Volume up, there’s another for down)
#!/bin/bash
# Define your Home Assistant URL
HA_URL="myip:8123"
# Define your access token
ACCESS_TOKEN="my token"
# Define the service and command
SERVICE="remote"
COMMAND="send_command"
# Define the entity
ENTITY="remote.xiaomi_miio_192_168_1_98"
# Define the data in a separate variable
DATA='{"entity_id": "'"$ENTITY"'", "command": "volume_up", "num_repeats": 2}'
# Make the curl request with authentication
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d "$DATA" \
"$HA_URL/api/services/$SERVICE/$COMMAND"