Spaces in http get command

I wasn't a fan of Pushover due to lack of configurability and set up Prowl iPhone notifications to work, which is great. Prowl has 5 different alerts with a configurable sound for each, including vibrate irrespective of if the phone global switch is set to vibrate. In use I think this is far superior to Pushover, and it doesn't even cost $5. Also sometimes when my phone was asleep the notifications never popped up in Pushover but did in Prowl when I had both working at the same time.

I call Prowl notifications by URL get command which happily substitutes device names by use of the %device% variable. But since all my devices have spaces in their names, they do not work when substituted into the %device% variable since the URL becomes invalid until I edit the spaces out of the names.

Is there a way to have the URL get command automatically replace space characters with say underscores when the %device% var is parsed?

There are ways. What do you use to send the http get?

Thanks. I'm using Hubitat 2.1.2.123|RM4.0|Actions|Send or speak an message, send http request|send http get|https://www.prowlapp.com/publicapi/*%device%*%value%*.html

There is a rather painful way you could do it, by putting the device name in a variable and removing the spaces. Makes think that a replace function for setting a string variable would be handy. Then you could stuff %device% into a variable, then replace the spaces, then use that variable in the url.

I wonder if it might be quick and easy to expose gawk as a preprocessor to the text stored in the URL field? Given the sensitivity of URLS and the ubiquitous applicability of get/post commands, I'd vote it would be worth it. Or simpler, a simple check box next to the URL field with the option to "Replace white spaces in URL with underscores" which would be applied after substituting any vars with their values?

Not all applications would want to substitute blanks with underscore. Some will want %20 to preserve the blank. Replace would have broader applicability than just URLs.

It's officially on my wishlist :wink:

Thanks for the reply.

Why not just create a Prowl Notifications Driver? You could then share it with the community. Feel free to use my original Pushover driver as a starting point. It has the advantage of allowing you to modify the data before it is sent. And it is then very easy to use in any App that supports notifications.

Hehe....

1 Like

Would it make sense to do a urlencode on the URL string before the get command is issued by the rule?

Using %20 etc is the standard way how webservers work and should not cause any side effects.

Edit: it is actually defined under rfc 3986 on how to encode URIs with “special” characters
https://tools.ietf.org/html/rfc3986#section-2.4

Now /that/ is cool :slight_smile:

I seriously didn't expect to get Bruce's attention and come up with a fix anytime soon. Thanks man! Hopefully we will see that in the release one day :slight_smile:

@dan.t and @ogiewon, your logic is sound.

1 Like

I'm on the new release and the connectors is great for controlling fan temp setpoints from dashboards. I have been looking for the 'replace' action shown above for several days in the updated GUI but haven't found it. Where should one click to find the 'replace' action? I actually thought I looked everywhere several times...

Thanks!

It is under Set Variable...

Thanks. It totally works :slight_smile:

Set device_rep to ' %device%'
Replace ' ' from device_rep with '_'
Set value_rep to '%value%'
Replace ' ' from value_rep with '_'
Send GET to: https://www.prowlapp.com/publicapi/add?apikey=31459287&application=Hubitat&event= %device_rep%&description=%value_rep%&priority=%prowl_priority_neg2to2%

The connector works nice here to have a dashboard tile set %prowl_priority_neg2to2% for 5 different options for notification alarm setting in the app (no sound; vibrate; or various sounds avail).

I /did/ use underscores instead of %20 because I'm aiming for human readable, not machine readable. But in general the comments about %20 are sensible.

1 Like

I tried to run with this and make some hourly notifications for when the garage door is open late etc. but hit a stop.

For example,

Select Trigger Events (ANY will trigger)
Each of these hours: 0:00,1:00,2:00,3:00,4:00,5:00,6:00,7:00,21:00,22:00,23:00, at 0 minutes after the hour

IF (Garage door sideyard sensor open(T) [TRUE]) THEN
Set value_rep to '%value%'
Replace ' ' from value_rep with ''
Set device_rep to '%device%'
Replace ' ' from device_rep with '
'
Send GET to: https://www.prowlapp.com/publicapi/add?apikey=3pt1415926535&application=Hubitat&event=% device_rep%&description=%value_rep%&priority=%prowl_priority_neg2to2%
END-IF

This works if I replace %device_rep% and %value_rep% with test1 and test2 in the URL but doesn't work if I use the vars in the URL. Logging shows correct execution but I can't see what the vars are replaced with when the notification fails.

My best guess is that since the trigger does not have the relevant device in it, perhaps the action doesn't get passed any device information. I can prove this by replacing the periodic scheduling with a 'contact sensor open' event regarding the relevant device and the notification works. But since multiple triggers use OR for evaluation, including the device in a separate entry in the list of triggers in order to pass the relevant device var to the action breaks the periodic scheduling aspect.

I suppose in brief, how can I get a relevant device var passed to the action without breaking the scheduling?

Try using Device Attribute to set a variable.

Thanks!