Cool! Btw, does AllPlay require native libs or is it possible to do in pure Java?
I was struggling heavily when working on a generic AllJoyn binding, that's why I am asking. Although I think that "AllPlay based on AllJoyn" is only marketing speech and technically, you do not at all require the AllJoyn Core libraries, do you?
Hi,
unfortunately it does require native alljoyn libs :cry: .
However, I got it working with the native lib on both Windows 10 and a raspberry Pi 2. For Windows 10 I found a dll on the alljoyn website which worked, for the raspberry Pi I had to compile it myself. Don't ask my how many days I've spent until I was able to connect for the first time... :sweat_drops: (it could be so easy!)
As far as I understand AllPlay, it is just a collection of defined allJoyn interfaces with methods and properties (e.g. net.allplay.MediaPlayer) which the vendors need to implement.
That's why I can even control parts of the speakers from the Windows IoT Explorer (which doesn't really know about AllPlay):

There is also a closed-source AllPlay click SDK available for android and iOS, but I assume they are also using the native library.
Talking about native libs, I saw your comment here, that native libs should be bundles with the binding. I would love to do that as it would be really cool and convenient. Any ideas what's the best approach for this? I saw some libraries which copy the native library to a temporary folder and then load it but I didn't spent much time on this yet. Also I am not sure how many native libs we would need? ARM, Windows (x86+x64) and Linux (x86+x64)? This would bloat up the size of the binding to some megabytes...
Just add a Bundle-NativeCode instruction to your bundle as is done here and the OSGi container will extract the appropriate shared library and put it on the search path. It is better to have a larger distribution than to complicate installation by requiring users to manually handle shared libraries.
@watou thank you, that worked!
@watou your suggestions works when I start openhab in Eclipse directly, but when I try to run mvn clean install, I get the following error:
[INFO] Resolving class path of MavenProject: org.openhab.binding:org.openhab.binding.allplay:2.0.0-SNAPSHOT @ C:\Projects\openhab2\git\openhab2-addons\addons\binding\org.openhab.binding.allplay\pom.xml
[ERROR] Internal error: java.lang.RuntimeException: org.osgi.framework.BundleException: Bundle org.openhab.binding.allplay cannot be resolved
[ERROR] Resolution errors:
[ERROR] Bundle org.openhab.binding.allplay - No match found for native code: lib/x64/win/alljoyn_java.dll; processor=amd64; osname=win32; osname=Windows8; osname=Windows 8; osname=Win8; osname=Windows10; osname=Windows 10; osname=Win10
...
at org.eclipse.tycho.core.osgitools.OsgiBundleProject.getResolverState(OsgiBundleProject.java:265)
at org.eclipse.tycho.core.osgitools.OsgiBundleProject.resolveClassPath(OsgiBundleProject.java:164)
at org.eclipse.tycho.core.resolver.DefaultTychoResolver.resolveProject(DefaultTychoResolver.java:130)
I assume that error message means that it cannot find the alljoyn_java.dll in the classpath?
I tried to compare my binding with the systeminfo binding but cannot sport the difference...
Here is my build.properties:
source.. = src/main/java/
output.. = target/classes
bin.includes = META-INF/,\
.,\
OSGI-INF/,\
ESH-INF/,\
lib/
Part of my MANIFEST.MF:
Bundle-ClassPath: .,
lib/tchaikovsky.jar
Bundle-NativeCode: lib/x64/win/alljoyn_java.dll;processor=amd64;osname=win32;osname=Windows8;osname=Windows 8;osname=Win8;osname=Windows10;osname=Windows 10;osname=Win10
And the dll is placed in C:\Projects\openhab2\git\openhab2-addons\addons\binding\org.openhab.binding.allplay\lib\x64\win\alljoyn_java.dll
Anywhere else I should check? Any ideas what could be wrong?
@dominicdesu Does it help if you add a * at the end of the line?
@kaikreuzer yes, that seems to work, thanks! Actually I tried this before and it didn't work... maybe I had put it in the wrong place.
Any idea why this is necessary for my binding but not for the systeminfo binding? Would be nice to understand what's going on behind.
Sorry, no clue why there's a difference...
Hi,
are there any news about the allplay binding ? Have a few allplay speakers in my home and can help to test the binding if possible.
@Yannic-HAW, I am still working on the perfect way to reconnect to the speakers, as there are various way in which a speaker can get disconnected. However I am almost done and it would be great if somebody else would test the binding as well.
On which system is your OH2 running? I need to include a native library for every OS and currently I only have the libraries for Windows 10 64 bit and ARM (raspberryPi) included.
Btw. which manufacturer are you AllPlay speakers from? Would be good to test on something other than Panasonic :-)
@dominicdesu
Sounds great :-) Im running OH2 on Ubuntu 64 bit.
My AllPlay Speakers are also Panasonic brand in germany we do not really have different manufacturers for AllPlay speakers on the market :(
Okay, I don't have a compiled native library for Linux 64 bit yet. I need to have a look, hopefully on the weekend, if I can find it somewhere or if I need to compile it manually.
Maybe i can help you out a bit. I have compiled the Alljoyn core for Linux 32 and 64 bit :)
alljoyn_linux.zip
Awesome, this helps a lot! Thanks!
I won't have time today, but I'll try to integrate the native libraries and build a binding for testing asap.
@dominicdesu Consider using the Bundle-NativeCode directive in MANIFEST.MF to have OSGi extract the platform-specific native library from the bundle and add it to Java's search path, like is done in the 1.x Systeminfo binding. That way, neither the user nor binding code needs to handle platform-specific libraries (except ARM processors need a little help).
@watou yes, that's what I did after your suggestion on 20 June and it is working great ๐
Cool! And sorry, I should have remembered! ๐
@Yannic-HAW I have now compiled the binding including the native libraries you provided.
I am not sure if it will actually work, as the other library I am using is called liballjoyn_java.so, while the ones you provided are called liballjoyn.so.
Don't know if this java-specific native library is actually necessary or not... well looking forward to your feedback :-)
Edit: Attachement deleted
Hi,
okay my fault i thought compiling just the core is enough. I build the java core also and now have the liballjoyn_java.so
Because the binding links against the wrong libary without the _java i copied the liballplay_java.so to my classpath and looked into the karaf log.
There are a few exceptions now and the first one is:
java.lang.NoClassDefFoundError: org/alljoyn/bus/common/KeyInfoNISTP256
(Before i added the lib to the classpath there was an exception that java cant find the liballplay_java.so after adding it to the path manually the exception is gone so i assume the lib is loaded now)
@Yannic-HAW,
I installed a Ubuntu VM and was able to reproduce your problem.
The issue was apperarently that the JNI file (alljoyn.jar) needed an update as I was using one from an older alljoyn version. After I updated the JNI file, the binding worked for me on Ubuntu x64 in a VM.
Would be great if you could try again with the attached binding :-)
Edit: Attachment deleted as the binding is now merged.
@dominicdesu
Sorry for the delay. I have tested the plugin now on a daily basis for more than a week and it works well without any issues. (tested on Linux 32 and 64 bit) Even reconnecting is no problem with my panasonic sc-all.
Amazing work :) A small suggestion for the future would be to also implement the group functionality
sorry but this addon is the reason I start with OpenHAB. Can someone explain me shortly where to get and how to install it on docker openhab/openhab?
I use the AMD64-Online build and mapped all the volumes to a nfs drive.
Thanks
@dominicdesu Do you still plan to create a PR for it?
@kaikreuzer the main functionality is ready, however I still have an issue with reconnections (sometimes allJoyn reports a speaker as disconnected and then I am unable to reconnect to it again, no matter what I do). Didn't want to publish a binding which only works for some days and then looses speakers.
Unfortunately the analysis takes a while as I usually have to wait 1-3 days until one of my speakers gets disconnected...
Interestingly it seems to work for @Yannic-HAW (thanks for the feedback btw.). I would like to try a few more things, I'll try to report back before the end of the year.
In the meanwhile it is possible to drop the binding from the post above (https://github.com/openhab/openhab2-addons/issues/1041#issuecomment-250929629) into the addons folder in order to try it out.
@Toonix Is this enough information for you or do you need more details? Unfortuntely I don't know anything about the docker setup...
Here it is ๐ .
Thanks to everybody so far for your suggestions, help and feedback!
@dominicdesu it was working fine for me on my old openhab2 installation which i basically made to test the migration from openhab1 to openhab2. I'm not sure about this disconnects you had though, it seems this issue didnt happen for me. But yesterday i started completely from scratch with a new openhab2 installation using apt-get and the daily snapshots, and this doesnt work any more. I think it is related to this issue:
https://github.com/openhab/openhab2-addons/pull/1552
as I get the following messages in my logfile during startup:
12:55:27.789 [INFO ] [lplay.internal.AllPlayHandlerFactory] - AllPlayHandlerFactory activate start
12:55:27.789 [INFO ] [lplay.internal.AllPlayHandlerFactory] - Connecting to allPlay bus
12:55:27.850 [INFO ] [lplay.internal.AllPlayHandlerFactory] - Starting discovery of speakers
12:55:27.858 [INFO ] [lplay.internal.AllPlayHandlerFactory] - AllPlayHandlerFactory activate end
12:55:27.858 [INFO ] [lplay.internal.AllPlayHandlerFactory] - AllPlayHandlerFactory createHandler start for thing allplay:speaker:5bb542e6-1198-4afb-bcd8-d91a611708f6
12:55:27.921 [INFO ] [play.internal.CentralSpeakerRegistry] - Speaker Announced: EGTVGramofon
12:55:27.921 [INFO ] [play.internal.CentralSpeakerRegistry] - Adding speaker EGTVGramofon
12:55:27.921 [INFO ] [play.internal.CentralSpeakerRegistry] - Informing 0 listener about announced speaker 4d56f675-1187-4bb2-ab40-a63b52d0c86c
12:55:27.922 [INFO ] [play.internal.CentralSpeakerRegistry] - Speaker Announced: EGLivingGramofon
12:55:27.922 [INFO ] [play.internal.CentralSpeakerRegistry] - Adding speaker EGLivingGramofon
12:55:27.922 [INFO ] [play.internal.CentralSpeakerRegistry] - Informing 0 listener about announced speaker 5bb542e6-1198-4afb-bcd8-d91a611708f6
12:55:28.549 [INFO ] [.astro.internal.job.AbstractDailyJob] - Scheduled astro event-jobs for thing astro:moon:local
12:55:28.574 [INFO ] [.astro.internal.job.AbstractDailyJob] - Scheduled astro event-jobs for thing astro:sun:local
12:55:28.871 [INFO ] [nding.allplay.handler.AllPlayHandler] - [Initialize] start
12:55:28.872 [ERROR] [ome.core.thing.internal.ThingManager] - Exception occured while initializing handler of thing 'allplay:speaker:5bb542e6-1198-4afb-bcd8-d91a611708f6': java.lang.IllegalArgumentException: Illegal status INITIALIZING. Bindings only may set UNKNOWN, ONLINE, OFFLINE or REMOVED.
java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Illegal status INITIALIZING. Bindings only may set UNKNOWN, ONLINE, OFFLINE or REMOVED.
at java.util.concurrent.FutureTask.report(FutureTask.java:122)[:1.8.0_111]
at java.util.concurrent.FutureTask.get(FutureTask.java:206)[:1.8.0_111]
at org.eclipse.smarthome.core.common.SafeMethodCaller.callAsynchronous(SafeMethodCaller.java:188)[96:org.eclipse.smarthome.core:0.9.0.201612221226]
at org.eclipse.smarthome.core.common.SafeMethodCaller.call(SafeMethodCaller.java:81)[96:org.eclipse.smarthome.core:0.9.0.201612221226]
at org.eclipse.smarthome.core.common.SafeMethodCaller.call(SafeMethodCaller.java:65)[96:org.eclipse.smarthome.core:0.9.0.201612221226]
at org.eclipse.smarthome.core.thing.internal.ThingManager$9.run(ThingManager.java:710)[103:org.eclipse.smarthome.core.thing:0.9.0.201612221226]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_111]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_111]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)[:1.8.0_111]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)[:1.8.0_111]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_111]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_111]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_111]
Caused by: java.lang.IllegalArgumentException: Illegal status INITIALIZING. Bindings only may set UNKNOWN, ONLINE, OFFLINE or REMOVED.
at org.eclipse.smarthome.core.thing.internal.ThingManager$1.ensureValidStatus(ThingManager.java:184)[103:org.eclipse.smarthome.core.thing:0.9.0.201612221226]
at org.eclipse.smarthome.core.thing.internal.ThingManager$1.statusUpdated(ThingManager.java:149)[103:org.eclipse.smarthome.core.thing:0.9.0.201612221226]
at org.eclipse.smarthome.core.thing.binding.BaseThingHandler.updateStatus(BaseThingHandler.java:386)[103:org.eclipse.smarthome.core.thing:0.9.0.201612221226]
at org.openhab.binding.allplay.handler.AllPlayHandler.initialize(AllPlayHandler.java:75)[220:org.openhab.binding.allplay:2.0.0.201610011836]
at org.eclipse.smarthome.core.thing.internal.ThingManager$9$1.call(ThingManager.java:713)[103:org.eclipse.smarthome.core.thing:0.9.0.201612221226]
at org.eclipse.smarthome.core.thing.internal.ThingManager$9$1.call(ThingManager.java:1)[103:org.eclipse.smarthome.core.thing:0.9.0.201612221226]
at org.eclipse.smarthome.core.common.SafeMethodCaller$CallableWrapper.call(SafeMethodCaller.java:179)[96:org.eclipse.smarthome.core:0.9.0.201612221226]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_111]
... 3 more
12:55:28.873 [INFO ] [lplay.internal.AllPlayHandlerFactory] - AllPlayHandlerFactory createHandler start for thing allplay:speaker:4d56f675-1187-4bb2-ab40-a63b52d0c86c
12:55:28.883 [INFO ] [nding.allplay.handler.AllPlayHandler] - [Initialize] start
12:55:28.884 [ERROR] [ome.core.thing.internal.ThingManager] - Exception occured while initializing handler of thing 'allplay:speaker:4d56f675-1187-4bb2-ab40-a63b52d0c86c': java.lang.IllegalArgumentException: Illegal status INITIALIZING. Bindings only may set UNKNOWN, ONLINE, OFFLINE or REMOVED.
java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Illegal status INITIALIZING. Bindings only may set UNKNOWN, ONLINE, OFFLINE or REMOVED.
at java.util.concurrent.FutureTask.report(FutureTask.java:122)[:1.8.0_111]
at java.util.concurrent.FutureTask.get(FutureTask.java:206)[:1.8.0_111]
at org.eclipse.smarthome.core.common.SafeMethodCaller.callAsynchronous(SafeMethodCaller.java:188)[96:org.eclipse.smarthome.core:0.9.0.201612221226]
at org.eclipse.smarthome.core.common.SafeMethodCaller.call(SafeMethodCaller.java:81)[96:org.eclipse.smarthome.core:0.9.0.201612221226]
at org.eclipse.smarthome.core.common.SafeMethodCaller.call(SafeMethodCaller.java:65)[96:org.eclipse.smarthome.core:0.9.0.201612221226]
at org.eclipse.smarthome.core.thing.internal.ThingManager$9.run(ThingManager.java:710)[103:org.eclipse.smarthome.core.thing:0.9.0.201612221226]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_111]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_111]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)[:1.8.0_111]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)[:1.8.0_111]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_111]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_111]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_111]
Caused by: java.lang.IllegalArgumentException: Illegal status INITIALIZING. Bindings only may set UNKNOWN, ONLINE, OFFLINE or REMOVED.
at org.eclipse.smarthome.core.thing.internal.ThingManager$1.ensureValidStatus(ThingManager.java:184)[103:org.eclipse.smarthome.core.thing:0.9.0.201612221226]
at org.eclipse.smarthome.core.thing.internal.ThingManager$1.statusUpdated(ThingManager.java:149)[103:org.eclipse.smarthome.core.thing:0.9.0.201612221226]
at org.eclipse.smarthome.core.thing.binding.BaseThingHandler.updateStatus(BaseThingHandler.java:386)[103:org.eclipse.smarthome.core.thing:0.9.0.201612221226]
at org.openhab.binding.allplay.handler.AllPlayHandler.initialize(AllPlayHandler.java:75)[220:org.openhab.binding.allplay:2.0.0.201610011836]
at org.eclipse.smarthome.core.thing.internal.ThingManager$9$1.call(ThingManager.java:713)[103:org.eclipse.smarthome.core.thing:0.9.0.201612221226]
at org.eclipse.smarthome.core.thing.internal.ThingManager$9$1.call(ThingManager.java:1)[103:org.eclipse.smarthome.core.thing:0.9.0.201612221226]
at org.eclipse.smarthome.core.common.SafeMethodCaller$CallableWrapper.call(SafeMethodCaller.java:179)[96:org.eclipse.smarthome.core:0.9.0.201612221226]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_111]
... 3 more
Interesting though that it seems to crash the webserver somehow - After this i'm no more able to access PaperUI, Habpanel, Basic UI or anything else.
When I remove the jar file from my addons folder it somehow crashes karaf too:
12:57:59.465 [DEBUG] [org.openhab.binding.allplay ] - BundleEvent STOPPING - org.openhab.binding.allplay
12:57:59.469 [DEBUG] [org.openhab.binding.allplay ] - ServiceEvent UNREGISTERING - {org.eclipse.smarthome.config.discovery.DiscoveryService}={component.name=org.openhab.binding.allplay.discovery, component.id=217, service.id=351, service.bundleid=220, service.scope=bundle} - org.openhab.binding.allplay
12:57:59.473 [DEBUG] [org.openhab.binding.allplay ] - ServiceEvent UNREGISTERING - {org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory}={component.name=org.openhab.binding.allplay.internal.AllPlayHandlerFactory, component.id=218, service.id=352, service.bundleid=220, service.scope=bundle} - org.openhab.binding.allplay
12:57:59.479 [INFO ] [me.event.ThingStatusInfoChangedEvent] - 'allplay:speaker:5bb542e6-1198-4afb-bcd8-d91a611708f6' changed from UNINITIALIZED (HANDLER_INITIALIZING_ERROR): Illegal status INITIALIZING. Bindings only may set UNKNOWN, ONLINE, OFFLINE or REMOVED. to UNINITIALIZED (HANDLER_MISSING_ERROR)
12:57:59.490 [INFO ] [me.event.ThingStatusInfoChangedEvent] - 'allplay:speaker:4d56f675-1187-4bb2-ab40-a63b52d0c86c' changed from UNINITIALIZED (HANDLER_INITIALIZING_ERROR): Illegal status INITIALIZING. Bindings only may set UNKNOWN, ONLINE, OFFLINE or REMOVED. to UNINITIALIZED (HANDLER_MISSING_ERROR)
12:57:59.492 [INFO ] [lplay.internal.AllPlayHandlerFactory] - AllPlayHandlerFactory deactivate start
Connection to localhost closed by remote host.
Connection to localhost closed.
pi@KGTec1Openhab2Server:/var/log/openhab2$
Update:
Although i deleted the Allplay Jar from the addons folder, stopped and started openhab service multiple times and even rebooted my server it still seems to be "existent" in Karaf:
openhab> bundle:list
START LEVEL 100 , List Threshold: 50
ID | State | Lvl | Version | Name
-----------------------------------------------------------------------------------------------------
9 | Active | 80 | 2.3.0.201506221200 | JAX-RS Gson Provider
...
220 | Active | 80 | 2.0.0.201610011836 | AllPlay Binding
openhab>
furthermore the things created by the Allplay binding were still existing, i deleted these manually using the Paper UI.
Hi,
thanks for the info. I will change the initializing to something else.
Maybe your second issue is related to this thread? Don't know what I could have done wrong in the binding to be so persistent ๐ . However I will keep my eyes open.
Although i deleted the Allplay Jar from the addons folder, stopped and started openhab service multiple times
What you have to do is to uninstall the bundle that you want to get rid off.
Simply do a
bundle:uninstall 220
I did that as well - Karaf crashes and the bundle stays :)
However I will look further into it sometime next week :)
Von meinem iPhone gesendet
Am 23.12.2016 um 21:12 schrieb Kai Kreuzer notifications@github.com:
Although i deleted the Allplay Jar from the addons folder, stopped and started openhab service multiple times
What you have to do is to uninstall the bundle that you want to get rid off.
Simply do abundle:uninstall 220
โ
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
Most helpful comment
Just add a Bundle-NativeCode instruction to your bundle as is done here and the OSGi container will extract the appropriate shared library and put it on the search path. It is better to have a larger distribution than to complicate installation by requiring users to manually handle shared libraries.