Pushover image support

this would be great for door open = snapshot on phone. looking forward to this!

Hey!
Just wanted to throw the hat in the ring and say that I am super keen for this feature to be implemented into the Binding.
So happy you are working on it. Looking forward to it!
Thanks
Muzz

there is already a PR for it: https://github.com/openhab/openhab1-addons/pull/5527

1 Like

Thanks,
As it looks like the documentation hasn’t been updated yet… can you help me out with quick example code…?
EDIT-> Ok, just learned what a GitHub Pull Request was…

Let me know how you go!
Cheers

EDIT2->
Can I download your GitHub PR files and test them in my openhab? @andre77

Nice! thanks!

If we need to test the new binding, I’m willing to try. Just provide me the jar file :slight_smile:

sure, you can test it
download pushover action as jar

use it like this:
sendPushoverImage(“Hello, this is a message with attached image.”, “/path/to/image.jpeg”);

feedback is very appreciated

1 Like

thanks for sharing

I have 2 errors:

Rule:

var FrontDoorCam = "FrontDoor.jpg"
var LocationSS = "/tmp/"
var ImgFile = "file://" + LocationSS + FrontDoorCam
pushoverImage("Pushover test attachment", ImgFile)

Error:

2018-03-28 20:31:53.799 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'TEST pushover': The name 'pushoverImage' cannot be resolved to an item or type; line 33, column 9, length 50

When I use my normal pushover command, which worked previously, I receive the message on my phone, but I also see an amount of errors in the logs:

pushover(null, null, "test message", null, "Push test", null, null, 0, "spacealarm")

Error

2018-03-28 20:39:35.650 [INFO ] [org.openhab.action.pushover         ] - FrameworkEvent INFO - org.openhab.action.pushover
java.io.IOException: Exception in opening zip file: /var/lib/openhab2/cache/org.eclipse.osgi/213/0/bundleFile
	at org.eclipse.osgi.framework.util.SecureAction.getZipFile(SecureAction.java:321) ~[?:?]
	at org.eclipse.osgi.storage.bundlefile.ZipBundleFile.basicOpen(ZipBundleFile.java:93) ~[?:?]
	at org.eclipse.osgi.storage.bundlefile.ZipBundleFile.getZipFile(ZipBundleFile.java:106) ~[?:?]
	at org.eclipse.osgi.storage.bundlefile.ZipBundleFile.checkedOpen(ZipBundleFile.java:65) ~[?:?]
	at org.eclipse.osgi.storage.bundlefile.ZipBundleFile.getEntry(ZipBundleFile.java:240) ~[?:?]
	at org.eclipse.osgi.storage.bundlefile.BundleFile.getResourceURL(BundleFile.java:136) ~[?:?]
	at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findResourceImpl(ClasspathManager.java:418) ~[?:?]
	at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalResources(ClasspathManager.java:395) ~[?:?]
	at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalResources(ModuleClassLoader.java:321) ~[?:?]
	at org.eclipse.osgi.internal.loader.BundleLoader.findLocalResources(BundleLoader.java:837) ~[?:?]
	at org.eclipse.osgi.internal.loader.BundleLoader.findResources(BundleLoader.java:693) ~[?:?]
	at org.eclipse.osgi.internal.loader.ModuleClassLoader.getResources(ModuleClassLoader.java:231) ~[?:?]
	at org.eclipse.osgi.internal.framework.ContextFinder.getResources(ContextFinder.java:165) ~[?:?]
	at java.util.ServiceLoader$LazyIterator.hasNextService(ServiceLoader.java:348) ~[?:?]
	at java.util.ServiceLoader$LazyIterator.hasNext(ServiceLoader.java:393) ~[?:?]
	at java.util.ServiceLoader$1.hasNext(ServiceLoader.java:474) ~[?:?]
	at javax.xml.parsers.FactoryFinder$1.run(FactoryFinder.java:293) ~[?:?]
	at java.security.AccessController.doPrivileged(Native Method) ~[?:?]
	at javax.xml.parsers.FactoryFinder.findServiceProvider(FactoryFinder.java:289) ~[?:?]
	at javax.xml.parsers.FactoryFinder.find(FactoryFinder.java:267) ~[?:?]
	at javax.xml.parsers.DocumentBuilderFactory.newInstance(DocumentBuilderFactory.java:120) ~[?:?]
	at org.openhab.action.pushover.internal.Pushover.parseResponse(Pushover.java:370) ~[?:?]
	at org.openhab.action.pushover.internal.Pushover.pushover(Pushover.java:350) ~[?:?]
	at org.openhab.action.pushover.internal.Pushover.pushover(Pushover.java:101) ~[?:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeOperation(XbaseInterpreter.java:1085) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeOperation(XbaseInterpreter.java:1060) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._invokeFeature(XbaseInterpreter.java:1046) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeFeature(XbaseInterpreter.java:991) ~[?:?]
	at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.invokeFeature(ScriptInterpreter.java:141) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:901) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:864) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:223) ~[?:?]
	at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.doEvaluate(ScriptInterpreter.java:215) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:203) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:446) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:227) ~[?:?]
	at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.doEvaluate(ScriptInterpreter.java:215) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:203) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:459) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:243) ~[?:?]
	at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.doEvaluate(ScriptInterpreter.java:215) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:203) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:446) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:227) ~[?:?]
	at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.doEvaluate(ScriptInterpreter.java:215) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:203) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.evaluate(XbaseInterpreter.java:189) ~[?:?]
	at org.eclipse.smarthome.model.script.runtime.internal.engine.ScriptImpl.execute(ScriptImpl.java:82) ~[?:?]
	at org.eclipse.smarthome.model.rule.runtime.internal.engine.RuleEngineImpl.lambda$2(RuleEngineImpl.java:343) ~[?:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
	at java.lang.Thread.run(Thread.java:748) [?:?]
Caused by: java.io.FileNotFoundException: /var/lib/openhab2/cache/org.eclipse.osgi/213/0/bundleFile (No such file or directory)
	at java.util.zip.ZipFile.open(Native Method) ~[?:?]
	at java.util.zip.ZipFile.<init>(ZipFile.java:225) ~[?:?]
	at java.util.zip.ZipFile.<init>(ZipFile.java:155) ~[?:?]
	at java.util.zip.ZipFile.<init>(ZipFile.java:169) ~[?:?]
	at org.eclipse.osgi.framework.util.SecureAction.getZipFile(SecureAction.java:304) ~[?:?]
	... 59 more

We rename this action to sendPushoverImage(). Didn’t we?

@wars Had you uninstalled the original Pushover action before you put the new one into your addons folder?

Works perfectly :grinning:

I put the snapshot jar in my addons folder, uninstalled the original Pushover binding, restarted openHAB.
Then I wrote the following in a rule which could be fired by a switch:

    sendPushoverImage("Test", "/volume1/SmartHome/openHAB/conf/icons/basic/washer.png")

And after clicking on the switch Pushover on my Android displayed the image!
No exceptions in my log, and the original “pushover” still works, too.

Thanks a lot!

1 Like

ups sorry guys, sure, the method name is “sendPushoverImage” and not “pushoverImage” !
so the code should look like this:

sendPushoverImage(“Hello, this is a message with attached image.”, “/path/to/image.jpeg”);

It’s working with sendPushoverImage and after a restart of OpenHAB :slight_smile:
Thanks for the effort !

Although I see one warning message (I used a .jpg file of 216KB):

2018-03-29 11:24:44.185 [WARN ] [he.commons.httpclient.HttpMethodBase] - Going to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is recommended.

Is also possible to give extra parameters such as device, priority, sound… ? Or is the Pushover API not supporting this?

glad, its working for you
here is the code of the SNAPSHOT version, you are using

you can use the method

pushover(String apiKey, String user, String message, String device, String title, String url, String urlTitle, int priority, String sound, String attachment)

some kind of a builder pattern would be a better approach there, feel free to implement :slight_smile:

Thanks

I’m already using this kind of method for my other Pushover messages, but didn’t knew that the attachment can be added now.
So there is no difference between pushover and sendPushoverImage ? Except that the 2nd only accepts title, message & attachment?

correct
the old “pushover” method accepts additionally an optional “String attachment” parameter at the end of the list
“sendPushoverImage” accepts two parameters: message and path to the file, no title

just changed the code to avoid this warning

[WARN ] [he.commons.httpclient.HttpMethodBase] - Going to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is recommended.

the warning is gone, i updated the snapshot jar file on my server, feel free to use it

1 Like

Works! :smiley: Two things i am missing tough:

  • Support for special characters, earlier my pushover would show æøå letters, this does not work now (replaced with “?”)

  • Possibility to add priority to the sendPushoverImage

Thnx for awesome work :slight_smile:

good catch, will have a look at it later today

edit:
just fixed the encoding, special characters should be fine now, the jar file is updated
i later will add another method to set the priority

edit2:
@rogerrem
just added the method

sendPushoverImage(String message, int priority, String attachment)

feel free to test it, do not forget to renew the jar file

edit3:

sorry @rogerrem
the correct method is: sendPushoverImage(String message, String attachment, int priority)

Tested it now, but now it seems it doesnt work at all, downloaded the jar file from your previous post again.

2018-04-02 19:09:42.064 [ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during
the execution of rule 'Ringeklokke': The name 'sendPushoverImage(<XStringLiteral
Impl>,<XNumberLiteralImpl>,<XStringLiteralImpl>)' cannot be resolved to an item
or type.

Strange, the jar does not seem to work at all, the normal pushover(xxx) does not work anymore either.

Cannot confirm, the “normal” pushover functions do work as before.
Note that you cannot have both bindings installed: you need to uninstall the “old” pushover binding and drop the new one into your addons folder.