Skip to content

Commit

Permalink
Change the MSG separator characters from <> to ::
Browse files Browse the repository at this point in the history
Newer versions of Hubitat don't allow the characters <> to be saved in an app's preferences.
  • Loading branch information
john3300 committed Apr 6, 2024
1 parent 6e9afab commit 45debd6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions HTTP-Notifications.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Platform: Hubitat
* Modification History:
* Date Who What
* v1.0.1 2024-04-05 Brian Johnson Change the MSG separator characters from <> to ::
* v1.0.0 2020-08-16 Brian Johnson Initial version
*
* Copyright (c) 2020 Brian Johnson
Expand Down Expand Up @@ -42,7 +43,7 @@ metadata {

preferences {
input name: "httpUrl", type: "text", title: "Notification URL:", required: true
input name: "queryString", type: "text", title: "Query String:", description: "Use &lt;MSG&gt; as placeholder for message", required: false
input name: "queryString", type: "text", title: "Query String:", description: "Use ::MSG:: as placeholder for message", required: false
}
}

Expand All @@ -55,7 +56,7 @@ def deviceNotification(message) {
]

if (queryString) {
queryString = queryString.replaceAll("<MSG>", URLEncoder.encode(message, "UTF-8"))
queryString = queryString.replaceAll("::MSG::", URLEncoder.encode(message, "UTF-8"))
postParams.put("queryString", queryString)
}

Expand All @@ -70,4 +71,4 @@ def deviceNotification(message) {
} catch (Exception e) {
log.error "Error calling httpPost ${e}"
}
}
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This driver is the counterpart to my [MagicMirror²](https://github.com/MichMich
![Screenshot](screenshot.png)

- **Notification URL:** (Required) Where to send your notifications to.
- **Query String:** (Optional) Any query parameters you want to send. Use `<MSG>` as a placeholder for the notification message.
- **Query String:** (Optional) Any query parameters you want to send. Use `::MSG::` as a placeholder for the notification message.

Only the message will be URL encoded before it's sent. If your query string needs encoding you will need to do that on your own.

Expand All @@ -18,10 +18,10 @@ Only the message will be URL encoded before it's sent. If your query string need
|Preference|Value|
|--|--|
|Notification URL|`http://magicmirror:8080/MMM-HomeAutomationNotifications`|
|Query String|`type=WARNING&message=<MSG>`|
|Query String|`type=WARNING&message=::MSG::`|

## Using the driver

1. Add a virtual device and select HTTP Notifications as the type.
2. Configure the device to set your preferences.
3. Now you can select the device as your target for text notifications in an app such as the built-in Notifications app.
3. Now you can select the device as your target for text notifications in an app such as the built-in Notifications app.
Binary file modified screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 45debd6

Please sign in to comment.