Sending pushover.net alerts


#1

I am just learning and with the help of @ipaterson was able to get this working

was asked to write up a example of how to use here

below are steps needed.

create a pushover account at https://pushover.net/

once created, on the main page you will see

Pushover_User_Key

you will need this key, this is the “user” token

then on same page, you will need to go down to

 "Your Applications   (Create an Application/API Token)"

click on "Create an Application/API Token"
for name use something like "MySmartThingsApp"
for type use Plugin
for Description put something like "Smart Things Alerts"
for url leave blank
for icon use
https://community.webcore.co/uploads/default/original/1X/8df5d06a10cd03bab948dfcfca91e6de39592df9.png
save the image locally and then click browse and add it
check the agree too terms and click create
you will see this the app key, remember this as will need to send pushover alerts, this is the app “token”

then download the Pushover app to phone, is $4.99 per platform, so pay once, use on all your device for that platform

https://pushover.net/faq#overview-fees

login to app with your email\password you created account with

after that you can you can send message via pushover in Webcore with

this is a image of the webrequest task

the sounds you can use are

pushover
bike
bugle
cashregister
classical
cosmic
falling
gamelan
incoming
intermission
magic
mechanical
pianobar
siren
spacealarm
tugboat
alien
climb
persistent
echo
updown
none

Link for more info on pushover api
https://pushover.net/api

the meaning of the Message Priorities are on that link, I mainly use 0 as that is just the normal send a msg with a sound
a priority of 2 would be an emergency page and will repeat ever minute until you go into app and acknowledge you read it

below is a sample you can import, but the anonomizer changed the url from https://api.pushover.net/1/messages.json to https://webcore.co, so will need to change that back


Push notifications only to those present in home
Push notice t a pc?
#2

Great write up @John68!
I’m moving this as it certainly earns a place in into the tutorials section!

I’ll be doing this myself as soon as I have some time. Nice work


#3

This is great. Thanks for getting this working.

I have made this into a generic piston which can be easily consumed in other pistons by passing the arguments via Global variables.

Before importing the Piston using backup code, please create following Global variables.

PUSHOVER_MESSAGE
PUSHOVER_PRIORITY
PUSHOVER_SOUND
PUSHOVER_TITLE

Piston an be executed as shown below

image

Let me know what you all think.


#4

that was gonna be one of my next questions, how do you create your own methods for easy code reuse, thanks


#5

I like it, cause can have separate profiles, adding _John _Lisa ect, if more then one pushover account to send too, then do not have to re-enter the keys every time


#6

You may be better using $arg rather than global variables, from my understanding they may not be updated when the notification piston is called. Using execute piston sending in arguments then accessing them via $arg. in the called piston is more reliable, also no need to pollute your global variables with message strings etc. and no need to clean them down after use (for null checks etc.)


#7

Hi @faze, I noticed that option when calling the piston, but I could not see a way to add arguments in piston. I could not find any info on this in the wiki as well. Any screenshot will be helpful.


#8

This should do it:

image

Then

Note: you don’t need to set the variable messages like I have and can use $args.message wherever needed.


#9

I like the args better then global vars, thanks


#10

Thanks, I was able to get the arguments working.

However, I also wanted to check if the argument is blank.

So far I have tried If value is “” “null” “blank”, but thing is working.

All of above fails.


#11

Try $args.undefined


#12

Oops that was left in whilst I worked out a null check! It does need fixing but I don’t yet know how to do a null/blank/white space check, if only I could import a class library… wait I’ve had an idea for a feature request!


#13

Thanks @c1arkbar. That worked.


#14

Is priority a number or value?


#15

can be a value of -2 to 2, I use 0 for most of my alerts

https://pushover.net/api
search for “Message Priority” for more


#16

Thanks I never use the feature. I have an issue with the global piston I’m trying to fix.

║An error occurred while executing the event: java.lang.NullPointerException: Cannot get property ‘v’ on null object


#17

Thought I’d share my piston with everyone’s comments and suggestions incorporated (all appreciated!). It takes advantage of most of the API features without making usage overly cumbersome.

Features incorporated: (arg name in parenthesis)

  • Recipient Specification (POuser) - Specify an individual or group if users are subscribed to your SmartThings Pushover app
  • Message (POmessage)
  • Title (POtitle)
  • Priority (POpriority) - All priorities are supported. For priority 2, the required expire and retry values are set as 3600 and 30, but you’re welcome to change them to fit your needs
  • Notification Sound (POsound) - list of supported sounds
  • Callback URL (POcallback) - For priority 2 notifications, an acknowledgement callback URL can be defined. You can use a piston execution URL here to trigger a follow-up piston.

By default, these values are passed to the Pushover API:

  • priority = 0
  • title = SmartThings
  • user = The user token you specify to be the default recipient.

Since these are sent by default, the only argument you HAVE to include in the piston call is the message. Here’s a very short piston example calling the notification piston:

Let me know if you have any questions or suggestions on how to improve it!


#18

Do you have to define the variables from pushover and each person that you want to call the pushover Piston from? For example I import your first person above and then I want to include pushover notifications on an existing piston what I have to include all those to find variables in your image number two in each piston that I want to have a pushover event and also obviously call up the execute pushover piston and argument?

For the URL that points to pushover I noticed in your test piston there brackets around it but when I go to update it it goes between two colons which should it be?

Leslie is there any way to call the Post function with the URLs as a variable since they’re pretty much the same and in the different spots so that you only have to set it once and then call it in the multiple spots you have it?


#19

NOTE: I updated the piston above so you may want to delete and re-import.

No, the only argument you HAVE to define and pass is POmessage (the message text). If you don’t specify a user, it will send it to whomever’s user/group key you initialized the user variable with in the define section.

For example, if you’re the only one that is going to be getting Pushover notifications, you could initialize the user variable with your user key and never have to worry about it again.

That URL should be https://api.pushover.net/1/messages.json. I guess it anonymized it when I clicked the green camera.


#20

I did that but get an error

2/3/2018, 5:55:10 PM +863ms
+0ms ╔Received event [Casa de Pines].test = 1517705710862 with a delay of 0ms
+188ms ║[:]
+1067ms ║Error executing external web request: groovyx.net.http.HttpResponseException: Bad Request
+1073ms ╚Event processed successfully (1073ms)