URL Decode for String variables

Continuing the discussion from Release 2.3.9 Available:

What does the below mean?

I understand what decoding string variables is but in what context does this change apply? Can someone provide an example please?

1 Like

This is an option for setting a String variable. In this example, the rule was triggered with an HTTP endpoint, and the value in the URL was URL encoded. %value% holds the raw string, and after this action the URL decoded value is in the variable myVar.

Since Bruce added this to solve an issue I had, I can provide a more concrete example.

I have a rule that sends a notification. Depending on hub mode, time and our physical location (derived from Owntracks), that notification might be played on Echo devices at our home, on Echo devices at our vacation home, on our cell phones (via Pushover) or some combination of these.

I have several other rules that create notification messages. The rule mentioned above is somewhat complex and I didn't want to duplicate that code in every place I needed to send a notification. However, since HE doesn't have any formal concept of subroutines the issue was how to pass an arbitrary string (in this case, the notification message) from one rule into another. I could only think of two ways:

  1. Use a hub variable for the notification message and trigger the sending-rule on any change to it
  2. Pass the notification message via a URL call to the sending-rule's local endpoint (which sets %value%)

I chose #2 because I also wanted to invoke the rule via a cloud endpoint. However, HE doesn't urldecode the endpoint request. So, doing this.: https://cloud.hubitat.com/api/xxxx/apps/175/trigger/foo%20bar?access_token=xxx resulted in %value% containing "foo%20bar" instead of " foo bar"

So by using the new Url Decode option on %value% I get the expected (decoded) string.