Pushover image support

pushover
Tags: #<Tag:0x00007f0148a63088>

(André) #41

its actually a pain point with so many methods, currently we have 23 of them
its due to different parameters, which are optional. see my last comment on the PR

simple example, curently we have this two methods among others:

pushover(String message, String device)
sendPushoverImage(String message, String attachment)

you see the difference


(André) #42

a big refactoring is finished, the builder pattern is in place, feel free to try
readme
snapshot jar is updated
feedback is very appreciated


(SiHui) #43

I like breaking changes :grinning:

I tried

sendPushoverMessage(pushoverBuilder("test message"))
sendPushoverMessage(pushoverBuilder("test message").withAttachment("/path/to/file.jpeg"))
sendPushoverMessage(pushoverBuilder("test message").withDevice("DEVICE"))

on a #1246 openHAB snapshot without any issues.

THANKS!


(André) #44

compared to the latest stable version of the binding we do not have breaking changes, since all older methods are still supported, they are deprecated though


(SiHui) #45

Thx for clarifying.


(Frank Kintrup) #46

Either I’m to stupid or it does not work any more :frowning:
I got the supposedly latest snapshot jar from here:

http://areiter.net/org.openhab.action.pushover-1.12.0-SNAPSHOT.jar

I replaced my former snapshot.jar (1.12.0.201803261500) with this version (1.12.0.201804032255, dated 04.04.2018). It resides in my addons folder with an updated ZWAVE binding (which works fine, so this addon folder is used) and the pushover action is NOT installed via Paper UI. Naturally, I restarted openHAB :wink:

I still get this warning in my log file:

Going to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is recommended.

I can use the standard pushover action, but get an ‘?’ instead of an umlaut character on my phone.

If I try to use the new sendPushoverMessage instead I’ll get this error in my log:

The name 'sendPushoverMessage' cannot be resolved to an item or type; line 107, column 5, length 95

What may be wrong?


(Frank Kintrup) #47

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:


(Christoph Weitkamp) #49

Hi Hartmut,

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


(Alpoy) #51

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


(SiHui) #52

Yes.


(Sim) #53

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


(André) #54

@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


(scott dee) #55

are there plans to support OH image items?


(Christoph Weitkamp) #56

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:


(scott dee) #57

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


(ar) #58

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!


(Rick) #59

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?


(Christoph Weitkamp) #60

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))

(Rick) #61

That works! Thanks a million :slight_smile:


(Christoph Weitkamp) #62

Sounds good. You’re welcome.