Pushover image support

Solved! It looks like the older snapshot jar still lived somewhere in a cache or tmp folder of openHAB and was preferred by openHAB, maybe because the filename of the .jar-file did not change between versions?
After clearing those folders and restarting openHAB all problems are solved :slight_smile:

Hi Hartmut,

Assuming you are using the snapshot version of OH2 have a look at the snapshot documentation:

Is this version added to the snapshot release(s) or do I have to manually download it?

Yes.

1 Like

Is it possible to use “URL” instead of “local file”?

This is my .sitemap

Text label="Garden" icon="garden" {
    Image url="http://192.168.1.123/channels/1/picture" refresh=3000
}

And I need to push that “Image” from “real-time”

Regards

Sim

@Sim
yes, not directly though
this is, how i do it

val camURL = "http://user:pw@camera1/Streaming/channels/1/picture"
val file = now.toString.replaceAll("[:\\/ \\+]+", "_") +".jpg"
val outputFile = "/tmp/camera/" + file
var String curl_result = executeCommandLine("curl -m 10 -o " + outputFile + " " + camURL, 5000)
sendPushoverMessage(pushoverBuilder(msg).withAttachment(outputFile))
// delete the temp file after 60 seconds
createTimer(now.plusSeconds(60)) [|
    executeCommandLine("rm " + outputFile)
]

“curl” must be installed

2 Likes

are there plans to support OH image items?

Hi scott,

let’s assume you have an Image item called Webcam_Image. You can adjust the above script in the first line:

val camURL = Webcam_Image.state.toFullString
val file = now.toString.replaceAll("[:\\/ \\+]+", "_") +".jpg"
...

// Edit: I filed an issue for it:

1 Like

even better would be
sendPushoverMessage(“message”,openHabImageItem) :wink:

With Openhab 2.2 I only have the option of getting version 1.11.0 which does not seem to have this support. Can anyone explain where to get a newer version?

Edit: Sorry, just figured that it would be available normally considering the new documentation is up. I understand now that it needs to be manually downloaded / installed for now.

Edit2: Doesn’t seem to be working?
19:54:53.426 [ERROR] [untime.internal.engine.RuleEngineImpl] - Rule ‘driveway_camera_alert_rule’: The name ‘sendPushoverImage’ cannot be resolved to an item or type; line 67, column 3, length 87

253 │ Active │ 80 │ 1.12.0.201804032255 │ openHAB Pushover Action

Edit3: What kintrupf said about the cache seems correct? I had to restart openhab to get the binding to load properly. Everything is working now. I found a link to the latest module I think here: https://openhab.jfrog.io/openhab/libs-pullrequest-local/org/openhab/action/org.openhab.action.pushover/1.12.0-SNAPSHOT/
It is what the latest documentation describes: https://docs.openhab.org/addons/actions/pushover/readme.html

Nice work guys! Pretty awesome!

First of all, thanks for putting all your effort in this great binding!

I’m trying to get the new Pushover commands working in Jython. The following works in xTend:

sendPushoverMessage(pushoverBuilder(msg))

But this doesn’t work in Jython:

Pushover.sendPushoverMessage(pushoverBuilder(msg))

(The command pushover(msg) works, via Pushover.pushover(msg)

Does anyone has an idea what the Jython syntax should be?

Hi @ricadelic,

I am not familiar with Jython and do not know if I can help you very much. But if the Jython syntax requires to prepend the class name in front of a method name you maybe can try to use it like this:

Pushover.sendPushoverMessage(Pushover.pushoverBuilder(msg))
1 Like

That works! Thanks a million :slight_smile:

Sounds good. You’re welcome.

Gents,

I’ve been trying to get myself some nice attachments in my pushover messages but whatever i try… adding an attachment to my pushover rules gives me:

Could not process file '/static/Haardmeubel1.jpg': File is not a normal file., will send the message without attachment.

Part of my rule :slight_smile:

sendPushoverMessage(pushoverBuilder("test message").withApiKey("BLABLABLA").withUser("BLABLABLA").withDevice("sm-g960f").withPriority(0).withSound("echo").withAttachment("/static/Haardmeubel1.jpg"))

What am i doing wrong?

see the source code
you get an IOException for some reason.
does the file ‘/static/Haardmeubel1.jpg’ really exist and is it readable by the user, which is running openhab?

Got it… it actually requires the full file path, not just a relative one like i used…

I got it up and running in my Openhab setup using Node-red to handle the rules and inject images from my zoneminder server to finally send out a pushover message with attachment. For those interested…

Proof of working:

A basic description of my rule flow:

  • Openhab item Doorbell receives an update when doorbell is pressed

  • Node Red monitors the Openhab Doorbell item for updates. if an update is registered the state of the update is checked for the ON state.

  • If doorbell state is ON, we rate limit the amount of doorbell presses to 1 every 10 seconds . this allows all Doorbell automation to run correctly and also prevents people from molesting my doorbell.

  • as a result of pressing the doorbell…

  • Node Red plays doorbell.mp3 using Openhabs default audio sink (whole house SONOS)

  • Node Red flashes the alert channel of the Hue lighting through Openhab

  • Node Red writes a log entry in Openhab.log (Doorbell rang @ timestamp)

  • Node Red updates the Missed_doorbell_notification item is use for visual presentation in Habpanel

  • Node Red sets the doorbell notification text (openhab string item vPushover) to" there is someone at the door"

  • Node Red sets the doorbell notification sound (openhab string item vPushoverSound) to" gamelan"

  • Node Red sets the doorbell notification image (openhab string item vPushoverImage) to"/home/openhab/camera.jpg" after grabbing a fresh image from Zoneminder using http request.

  • the nodered.rules files is triggered based upon an update of vPushover and a message is sent through pushover.

The actual Node-red flow:

[{"id":"87f3ff46.cc45","type":"comment","z":"5445dc5f.c79e24","name":"Doorbell pressed - play doorbell sound through SONOS","info":"Test","x":220,"y":40,"wires":[]},{"id":"ed6d3ad0.8fd4e8","type":"openhab2-in","z":"5445dc5f.c79e24","name":"Doorbell","controller":"be8b0821.df18b8","itemname":"Doorbell","x":80,"y":100,"wires":[[],["e8bdfc9f.7fbd9"]]},{"id":"e8bdfc9f.7fbd9","type":"switch","z":"5445dc5f.c79e24","name":"Item Updated","property":"payload.type","propertyType":"msg","rules":[{"t":"eq","v":"ItemStateEvent","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":260,"y":100,"wires":[["1dd131ad.bb0e9e"]]},{"id":"1dd131ad.bb0e9e","type":"switch","z":"5445dc5f.c79e24","name":"Evaluate Doorbell","property":"payload.payload.value","propertyType":"msg","rules":[{"t":"eq","v":"ON","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":470,"y":100,"wires":[["1e99fe3.f0ae402"]]},{"id":"80308549.790458","type":"change","z":"5445dc5f.c79e24","name":"Send Doorbell.mp3","rules":[{"t":"set","p":"payload","pt":"msg","to":"doorbell.mp3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":950,"y":100,"wires":[["11fb9b37.f053f5"]]},{"id":"11fb9b37.f053f5","type":"openhab2-out","z":"5445dc5f.c79e24","name":"vSound","controller":"be8b0821.df18b8","itemname":"vSound","topic":"ItemUpdate","payload":"","x":1120,"y":100,"wires":[]},{"id":"1e99fe3.f0ae402","type":"delay","z":"5445dc5f.c79e24","name":"Rate Limite 1msg per 10s","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"10","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":710,"y":100,"wires":[["80308549.790458","8eeb319f.bd7d8","7f0acf61.b468d","2ea210a4.6f1ef","3ff78d87.074e02"]]},{"id":"68ea1491.60c20c","type":"openhab2-out","z":"5445dc5f.c79e24","name":"gHueAlert","controller":"be8b0821.df18b8","itemname":"gHueAllAlert","topic":"ItemCommand","payload":"","x":1120,"y":140,"wires":[]},{"id":"8eeb319f.bd7d8","type":"change","z":"5445dc5f.c79e24","name":"Send Alert","rules":[{"t":"set","p":"payload","pt":"msg","to":"SELECT","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":930,"y":140,"wires":[["68ea1491.60c20c"]]},{"id":"7f0acf61.b468d","type":"change","z":"5445dc5f.c79e24","name":"Send ON","rules":[{"t":"set","p":"payload","pt":"msg","to":"ON","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":920,"y":200,"wires":[["48a7a77f.53b658"]]},{"id":"48a7a77f.53b658","type":"openhab2-out","z":"5445dc5f.c79e24","name":"HabPanelNotification_Missed_Doorbell","controller":"be8b0821.df18b8","itemname":"HabPanelNotification_Missed_Doorbell","topic":"ItemCommand","payload":"","x":1220,"y":200,"wires":[]},{"id":"2ea210a4.6f1ef","type":"change","z":"5445dc5f.c79e24","name":"Create Log Entry","rules":[{"t":"set","p":"payload","pt":"msg","to":"Doorbell rang","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":950,"y":260,"wires":[["8b14e806.dc0038"]]},{"id":"8b14e806.dc0038","type":"openhab2-out","z":"5445dc5f.c79e24","name":"vLog","controller":"be8b0821.df18b8","itemname":"vLog","topic":"ItemUpdate","payload":"","x":1110,"y":260,"wires":[]},{"id":"3ff78d87.074e02","type":"http request","z":"5445dc5f.c79e24","name":"Front Door Camera","method":"GET","ret":"bin","url":"http://172.16.11.8/zm/cgi-bin/nph-zms?mode=single&monitor=1&scale=100&rand=1526327141","tls":"","x":950,"y":320,"wires":[["c5ec73ee.10da5","d7693e60.83604","abce55af.de82e8","be86d34d.6d8a3"]]},{"id":"c5ec73ee.10da5","type":"file","z":"5445dc5f.c79e24","name":"Save Camera Snapshot","filename":"/home/openhab/camera.jpg","appendNewline":false,"createDir":false,"overwriteFile":"true","x":1230,"y":320,"wires":[]},{"id":"48b55371.89f1bc","type":"openhab2-out","z":"5445dc5f.c79e24","name":"vPushover Image","controller":"be8b0821.df18b8","itemname":"vPushoverImage","topic":"ItemUpdate","payload":"","x":1210,"y":380,"wires":[]},{"id":"d7693e60.83604","type":"change","z":"5445dc5f.c79e24","name":"Set Pushover Image","rules":[{"t":"set","p":"payload","pt":"msg","to":"/home/openhab/camera.jpg","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":960,"y":380,"wires":[["48b55371.89f1bc"]]},{"id":"abce55af.de82e8","type":"delay","z":"5445dc5f.c79e24","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":920,"y":460,"wires":[["9eb30e6a.5e43"]]},{"id":"9eb30e6a.5e43","type":"change","z":"5445dc5f.c79e24","name":"Set Pushover Image","rules":[{"t":"set","p":"payload","pt":"msg","to":"Er staat iemand aan de deur!","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1100,"y":460,"wires":[["f3459409.054f98","d86b137d.a3827"]]},{"id":"f3459409.054f98","type":"openhab2-out","z":"5445dc5f.c79e24","name":"vPushover","controller":"be8b0821.df18b8","itemname":"vPushover","topic":"ItemUpdate","payload":"","x":1290,"y":460,"wires":[]},{"id":"be86d34d.6d8a3","type":"change","z":"5445dc5f.c79e24","name":"Set Pushover Sound","rules":[{"t":"set","p":"payload","pt":"msg","to":"gamelan","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":960,"y":420,"wires":[["10637063.a04d7"]]},{"id":"10637063.a04d7","type":"openhab2-out","z":"5445dc5f.c79e24","name":"vPushover Sound","controller":"be8b0821.df18b8","itemname":"vPushoverSound","topic":"ItemUpdate","payload":"","x":1210,"y":420,"wires":[]},{"id":"9825142.280f6e8","type":"openhab2-out","z":"5445dc5f.c79e24","name":"vPushover Image","controller":"be8b0821.df18b8","itemname":"vPushoverImage","topic":"ItemUpdate","payload":"","x":1310,"y":520,"wires":[]},{"id":"bdb00579.d7b048","type":"change","z":"5445dc5f.c79e24","name":"Reset Pushover Image","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1100,"y":520,"wires":[["9825142.280f6e8"]]},{"id":"d86b137d.a3827","type":"delay","z":"5445dc5f.c79e24","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":920,"y":520,"wires":[["bdb00579.d7b048"]]},{"id":"be8b0821.df18b8","type":"openhab2-controller","z":"","name":"Openhab2 - Prod","protocol":"http","host":"localhost","port":"8080","path":"","username":"","password":""}]

My nodered.rules and item file:

rule "Nodered vPushover"
when
	Item vPushover received update
then
	sendPushoverMessage(pushoverBuilder("" + vPushover.state.toString + "").withApiKey("YOURAPIKEYGOESHERE").withUser("YOURUSERKEYGOESHERE").withPriority(0).withSound(""+ vPushoverSound.state.toString +"").withAttachment(""+ vPushoverImage.state.toString +""))
end
String vNotification	"Notification [%s]"
String vPushover		"Pushover [%s]"
String vSound			"Sound [%s]"
String vSpeech			"Speech [%s]"

String vPushoverImage	"Pushover Image [%s]"
String vPushoverSound	"Pushover Sound [%s]"

Feel free to try it out!

Hi.
I think the documentation are just a little bit confusing. Wouldn’t it be better to completely remove all the deprecated stuff from the documentation? And also the pushoverBuilder() function isn’t really mentioned anywhere but in the examples section (although the examples make it kinda clear how it works).

I’ve also got a concrete question: Is there any difference between using withEmergencyPriority() and withPriority(3)?

Apart from the abovementioned uncertainties, I could just thank for a nice addon :wink:

Nope. If you are on stable 2.3 and did not update the binding manually to 2.4 this is still the way it works.