Basically, I want the hub to receive a string from the internet, store it into a variable, and then use it like speak it to a device. I've seen posts referencing /setGlobalVariable=:, but I get an error if I stick it into the cloud endpoint url:
When I randomly added my string after the /trigger/ like this:
https://cloud.hubitat.com/api/<long-string>/apps/<rule-id>/trigger**/any text I want goes here**?access_token=<token-string>
My browser would replace the spaces with %20 and the string is stored in the rule's local variable named %value% (weird). The % in the string is also causing problems since the rule tried to interpret variable values and so there are many null20 in the string.
Is there an easier and more reliable way to pass in a string? I'm also open to other ways like sending the hub an sms or email message.
There should be a URLencode and URLdecode option.
I only see URL Encode option.
And this is output from the cloud endpoint:
And the value is stored correctly as a local variable:
But to manually replace the encoded characters like "%20" -> " ", I have to first store %value% into a normal local variable. But that results in the % signs being interpreted and I lose some of the content.
- original: This is a test of string input
- %value%: This%20is%20a%20test%20of%20string%20input
- copied to another var: Thisnull20anull20ofnull20input
The receiving endpoint will do the URL decode automatically...
The hubitat is the receiving endpoint.
Internet browser/app -> hubitat cloud endpoint -> my hubitat
In case there is any confusion, the cloud endpoint is created by setting a rule trigger to Cloud End Point.
Excerpt from Rule Machine API
Set Hub Variable
A Hub Variable can be set by an endpoint trigger. The format for the parameter is this:
varString portion is assumed to be URL encoded, and is URL decoded before being stored into the
varName Hub Variable.