Simulate curl command from RM

I am trying to control my Delta VoiceIQ faucet bypassing Alexa.
Is it possible to simulate curl command by using RM HTTP POST action:

curl -X https://device.legacy.deltafaucet.com/api/device/toggleWater?deviceId=<Your_Device_ID> -H “Authorization: Bearer <YOUR_TOKEN>”

From the browser NETWORK info window it looks like something like this:

:Authority:
device.legacy.deltafaucet.com
:Method:
POST
:Path:
/api/device/toggleWater?deviceId=<Your_Device_ID>&toggle=off
:Scheme:
https
Accept:
*/*
Accept-Encoding:
gzip, deflate, br
Accept-Language:
en-US,en;q=0.9,ru-RU;q=0.8,ru;q=0.7
Authorization:
Bearer <YOUR_TOKEN>

I do have real DEVICE_ID and TOKEN values.

You could try adding it to the URL for the POST request, like this:

https://device.legacy.deltafaucet.com/api/device/toggleWater?deviceId=<device_id>&access_token=<YOUR_TOKEN>

Edit: this may or may not work, depending on the underlying implementation of both RM and the remote server to which you're making the API call.

It looks like it should be possible, though I'm not sure your CURL command is valid (did you mean -X POST, maybe?). A POST will normally also come with a body, which I don't see above but you might see listed as "request" or "request body" or similar in your browser's Network Console (though it could be blank--I'm not sure what information it could need that is not already in that URL, this being the kind of data that would often be included there).

You can always create a rule with just this action, install it, and use the Run Actions button in the interface to test it.

I tried your suggestion. Unfortunately it was not working. But this was expected.

If you get all the curl commands figured out it could be added to a driver and then it would be integrated into hubitat.

Have you tried using a postman proxy so you can capture all the traffic.

2 Likes

I found this CURL command example on reddit post claiming it works.
i have no idea how to test this CURL command. I tried to enter it into Windows CMD console but it generated an error "url is not defined". I have only Windows PC.

Here is an example how to configure Home Assistant (I actually have one running)

input_text:
  delta_device_id:
    name: delta_device_id
    initial: !secret delta_device_id

rest_command: 
  delta_toggle:
    method: POST
    url: >
      https://device.legacy.deltafaucet.com/api/device/toggleWater?deviceId={{states.input_text.delta_device_id.state}}
    headers:
      Authorization: !secret delta_token
      User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36
      Referer: https://device.legacy.deltafaucet.com/

Certainly i am OK to try this in HA but I cannot figure out where to enter real
DEVICE_ID and TOKEN in the above configuration script.

No.
Unfortunately I have no idea what it is and how to run it. I have only Windows PC handy.
And I have no idea how to test the suggested CURL command from Windows PC.

Likely because it doesn't really work. :slight_smile: Perhaps that syntax is valid in some curl implementation. I would try the modification I suggested above (plus at least getting rid of the "smart quotes"):

curl -X POST https://device.legacy.deltafaucet.com/api/device/toggleWater\?deviceId=XXXXX -H "Authorization: Bearer XXXXX"

I would suggest the Home Assistant forum for help with Home Assistant. For Hubitat, the more I think about this, the less I think RM will work. I don't think there is a way to specify headers, which you appear to need. However, there is a community driver that will let you send HTTP commands, including POST, and does have options for headers:

I would suggest that option instead and see if you can figure out the appropriate configuration based on its readme and the information you have.

1 Like

OK. I tried the modified CURL command. This one did not throw any errors but also did not work
(nothing was happening). I guess, first I have to make this CURL command working.
And of course, I am trying to learn and understand HA configuration scripting.

Right now I have this integration working with help of Alexa. I "like" clouds a lot. So, getting rid
of Alexa (it still will be Delta cloud) will be very nice. I am OK if I can make things working with HA
but direct control from HE is preferable. Eventually I will try the suggested HE driver but first
I have to get that CURL command working.

I have a backslash before the question mark because this is needed on macOS, where I was testing, to escape this character. You may not need this on Windows, or the escape character may be different (I don't recall and don't have a good way to test right now). You could also likely avoid these differences by using WSL if you aren't now, though that might be overkill if you aren't already.

But yes, figuring out a CURL command that works first would give you a better chance of making this work on Hubitat -- or anywhere.

I also have a Delta faucet working through Alexa — will be very interested to see if/how this works on HE!

I am sure Alexa could be out of equation (at least one cloud less).
Maybe together we can make this happens.
I came across this discussion:
https://www.reddit.com/r/homeassistant/comments/101lp3w/controlling_delta_voice_iq_faucet_from_ha/
(I am not sure, it is still somewhat active but I even tried to ask a question, let me see if the answer will come.)
Here is a an instruction how to retrieve DEVICE_ID and TOKEN (token happens to be extremely long). Delta VoiceIQ API for homeassistant · GitHub
And the above link has an example for Home Assistant configuration.yml
I do have Home Assistant and will be OK to use it but of course, direct HE control is more preferable. As we speak I am trying to get this CURL command working but so far no luck.
Here is a response:

  • Trying 13.107.237.41:443...
  • Connected to device.legacy.deltafaucet.com (13.107.237.41) port 443 (#0)
  • schannel: disabled automatic use of client certificate
  • ALPN: offers http/1.1
  • ALPN: server accepted http/1.1
  • using HTTP/1.1

POST /api/device/toggleWater?deviceId=<device_id> HTTP/1.1
Host: device.legacy.deltafaucet.com
User-Agent: curl/8.0.1
Accept: /
Authorization: Bearer
< HTTP/1.1 400 Bad Request
< Date: Sun, 04 Jun 2023 11:44:20 GMT
< Content-Length: 0
< Connection: keep-alive
< X-Powered-By: ASP.NET
< set-cookie: xyz; Path=/; Secure; HttpOnly;
< set-cookie: abc; SameSite=none; Path=/; Secure; HttpOnly;
< x-azure-ref: xxx
< X-Cache: CONFIG_NOCACHE
<

Somewhere in a middle there is a line:
< HTTP/1.1 400 Bad Request

I am not an expert in all these things but does it mean something is not right with a CURL command?
Also when I am playing with Delta web page the command has &toggle=on appended after <devoce_id> When i tried to add this to my CURL command there is some sort of error message at the end:
'toggle' is not recognized as an internal or external command,
So, I am not sure what is wrong with CURL command but still trying ...

I don't mind to use a HA but in the suggested configuration script i don't know (yet) where to enter real DEVICE_ID and TOKEN values.

Would would be ideal I think is if someone could create a driver for the device using the API information… if one hasn’t already been created… I’ll do a new post specifically for that - might be easier than trying to figure out how to do it with Curl with I don’t know anything about either…

Thank you, this may help.

I think (but I could be wrong) the successful CURL command could be a required step before driver or app could be created.

Meanwhile I will try to get HA working ...

2 Likes

Maybe! I know nothing about how this works unfortunately. I’m always impressed by the skills of those that can do these drivers!