Pushover Notifications Driver [Slightly Enhanced]

Thanks for the work on this driver! Is there any way to get HSM to work with HTML-formatted URLs? Whenever I save the alert text with <A HREF=*** , it strips out everything inside the <>. It works fine on the test box on the device page.

Sounds like the HSM app is stripping it out. The driver is not removing it.

I assume your trying to add something like

[HTML]<a href="http://example.com/">word</a>

to the text of your HSM notification?

Exactly. I worked around this on the Telegram driver by using markdown instead of HTML. Could I do something similar? I need two links so I can't just use the supplemental URL.

I suppose maybe I could try modifying the driver to interpret some special characters that HSM doesn't choke on to my opening/closing HTML tags. I haven't really delved into the driver code.

Feel free, please. I gladly accept Pull Requests.

Ok, I'm trying to figure out the syntax. It seems like this should work to replace [open] with < but instead it's replacing all instances of each of the letters in open with <.

    if(message.contains("[open]")){
        message = message.replaceAll("[open]","<")

Wrote this a while back https://raw.githubusercontent.com/thebearmay/hubitat/main/libraries/bb2Html.groovy

Might have some code you can use.

1 Like

OK, I got it to work with the code below (replace instead of replaceAll). I put the following under the code in the driver for [HTML]. Let me know if you want me to submit anything to the project for this. I don't consider myself much of a dev so I haven't done that before but happy to do so if it might be helpful for others.

   if(message.contains("[open]")){
       message = message.replace("[open]","<")
    }
    
     if(message.contains("[close]")){
       message = message.replace("[close]",">")
    }
2 Likes

@Seattle - Thank you! I have added in your code as follows, as it seems like it should only apply if one is is using the [HTML] tag, correct? If not, please let me know and I can rearrange the code.

    if(message.contains("[HTML]")){ 
        html = "1"
        message = message.minus("[HTML]")
        if(message.contains("[OPEN]")){
            message = message.replace("[OPEN]","<")
        }
        if(message.contains("[CLOSE]")){
            message = message.replace("[CLOSE]",">")
        }
    }

Also, since all of the other tags are UPPERCASE, I opted to support "[OPEN]" and "[CLOSE]", instead of the lowercase 'open' and 'close' in your sample code.

Please let me know your thoughts. Once I hear back from you, I will update my GitHub repository.

1 Like

That's perfect--thanks!

1 Like

@Seattle - Please give the latest version from my GitHub repo a try. You should be able to simply open the Driver on your hub, and then click IMPORT, to update it. I would love to hear some feedback to know for certain that it works as you expect. Thanks again for your contribution!

https://raw.githubusercontent.com/ogiewon/Hubitat/master/Drivers/pushover-notifications.src/pushover-notifications.groovy

1 Like

Works great--thanks! Nice to be able to keep using your version.

Here's my code in the HSM in case anyone is trying to do something similar. Alert is for every sensor when my RV Hubitat is armed and it sends device status and buttons to Arm/Disarm (it's already armed if it alerted but this way I can arm from message history) or to Cancel alert. I also have the supplemental link in the device setup set to cancel alerts so it can be done without opening the notification. I keep my iPhone on silent all the time so it's nice to switch to Pushover for alerts since it supports doing this as a critical alert so there's always sound.

[HTML][OPEN]center[close]%device% - %value%[OPEN]BR[CLOSE][OPEN]A HREF="http://192.168.53.11/apps/api/106/devices/225/push/1?access_token=x-x-x-x-x"[CLOSE]Arm[OPEN]/A[CLOSE] | [OPEN]A HREF="http://192.168.53.11/apps/api/106/devices/225/push/2?access_token=x-x-x-x-x"[CLOSE]Disarm[OPEN]/A[CLOSE] | [OPEN]A HREF="http://192.168.53.11/apps/api/106/devices/225/push/3?access_token=x-x-x-x-x"[CLOSE]Cancel Alert[OPEN]/A[CLOSE][OPEN]/center[CLOSE]
3 Likes

Just add a Pushover device for each user. Select the correct user in the settings, and the save that device. In RM or other apps, just send your Notifications to whatever users you'd like. I have three Pushover devices - one for my iPhone, one for my wife's iPhone, and one for ALL devices (includes our iPhones and iPads.)

Another option was added by @s1godfrey about two years ago. It allows one to include the Pushover Device Name as part of the message. It gets parsed by the driver and the proper Pushover device receives the message.

From the 1st post in this thread...

3 Likes

Which driver are you using? The built-in Hubitat Pushover driver? Or my version found in the first post of this thread. They were once the exact same driver, but the community driver has been enhanced with some new features.

1 Like

Copy the code, paste it into a new driver, click save. Then change your pushover device to use the custom driver.

HPM is nice, but it isn't really all that magical to me. :wink:

2 Likes

From the Hubitat Documentation:

How to install Custom Drivers

Also, there are many developers who apps/drivers are not in HPM. The same directions would apply to using their apps/drivers.

2 Likes

@LibraSun, As @ogiewon stayed.

Just add a Pushover device for each user.

So create a separate pushover device for every user just like you created the first pushover device and label them Pushover - Sam and Pushover - Frank, for example.

Then when you specify the pushover device to Send or Speak a message, you can select both of the pushover device.

2 Likes

:point_up: exactly this!

1 Like

Glad you got it.
We all have climbed the same ladder.

Sorry for cross-posting this as I did start a thread in help section. I figured more people who utilize this functionality and driver will see this and be able to assist me.

Is anyone utilizing pushover for notification and has links setup in a rule?

I'd like to get rich notifications with a link to start/stop a RM rule.

If anyone who does utilize links in their pushover notifications, can you kindly supply my with a pic or how you have it setup in the message field to populate the link? Also, do I need to use this dev-based pushover integration or does the official one have this ability?