I am doing some testing trying to understand this HTTP stuff and I am having a hard time. Hopefully someone can set me straight.
I am using a Sonoff with Tasmota installed for testing.
From the browser I can do:
http://192.168.3.127/cm?cmnd=Power%20on
http://192.168.3.127/cm?cmnd=Power%20off
and they work.
Should I be trying get or post in Rule Machine to do it?
I have RM set up to test
Send POST to: 192.168.3.127 -->(text) body: /cm?cmnd=Power%20on
I have this result in logs:
Action: Send POST to: 192.168.3.127 -->(text) body: /cm?cmnd=Power%20on
yet nothing happens
I think it all looks good but obviously something is wrong????
typically browsers are doing GET
requests.
If you want further confirmation, you can open the developer tools in your browser, and inspect the requests sent in the Network
tab. On Windows, this is Ctrl + Shift + I
-- on mac, command + option + I
In RM enter the URL without the %20, and select the urlEncode option. RM will interpret the %20 as a variable replacement request otherwise.
Sorry but i am still misunderstanding something as it still does nothing. Maybe the screenshot shows my mistake.
At the least, what you have put in the body should just be appended to the end of the url. I think it's also likely that this should be http GET.
Yes it should be a GET and it works in a driver but does not in RM. The only way I can make it work in RM is to replace the space with a variable containing %20. No encoding.
http://192.168.3.127:80/cm?cmnd=Power%space%On
Where %space% contain %20 as a string
Looks like you dropped the n
in cmnd
?
You might need to just actually put a space (instead of %20
) in your URL. Hubitat can encode it automatically for you, in which case I believe you'd then need "URL encode?" checked. If not, I think variable substitution (RM also uses %
to enclose variable names) takes precedence.
Or maybe I have that backwards. The wording is so succinct it's almost confusing. But that sounds right.
I wonder why you would choose to control a device directly with RM instead of using a driver for it?
As @buchanan.larry and I tried: It should work but it does not. That is why I suggested this workaround.
I had corrected the dropped n when I tesed, but forgot to redo the screen capture I posted. I appreciate all your ideas but nothing worked so far. I wanted to learn how to do this simple HTTP send in preparation for what I really want to do.
Have you tried using %20 and turning on the “URL encode?” switch.
Well, it works for me. I can turn my tasmota device on and off this way. (which is no use to me since I use a driver).
If you dont mind please do a screen capture of what worked for you so I can figure out what I am missing. And FYI: I have Tasmota working with driver but wanted to get this working to do some other stuff. Thanks
For what I can see, it looks exactly like yours.
this is what I get in the tasmota console when I click "Run Actions":
I have it working now. I turned on highest level web debugging in Tasmota and found no entry for Hubitat sending anything at all. From the browser even an improper send request shows up in the Tasmota console with web reporting debug on. So I removed the rule completely in RM. Rebooted Hubitat and created the rule over again, exactly as before, and this time it worked. Thanks for all the help. I should have thought of this earlier but I still would have needed help with the idea of creating a variable to send %20
Which of course is not necessary...
Just use +
(plus sign) instead of any space in URLs, and don't use URL Encode!
Yep, it works. Lot a wasted time.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.