I have created an addon to JRule which will connect to local socket and play audio Clips.
The benefit over using the normal sonos binding is that it will not interrupt what is playing, and it will continue to play what was played before once the clip finishes.
Hope it can help someone. It’s not that well tested yet so expect changes.
Well, I want to show case Jrule, you get Items and rules for free that you won’t get with the regular sonos-binding. Other than that I agree. I’ll see what I can do.
can i ask for something ? can you adjust so that the sinks have some kind of added name like _clip or whatever when they show up in the sinks list in the webui ?
milllion thanks
Where in the UI do you see this? (Screenshot?).
The audio sink are named “jsas:RINCON_XYZABVDEDFD”,
What would you like to rename them to? “jsas:RINCON_XYZABVDEDFD_clip” ?
I have added a new version
Some refactorings with names and also added possibility to cancelAudioClips (cancel overlay)
as well as flashing the led on the speaker when playing audio clips.
Thanks for taking the time and putting in the effort to build this. I came across this by accident, but it’s something I’ve been looking for. I have a number of Notifications that run and find it very annoying that the current stream is stopped to play the Notification.
I have completed the installation, but I’m getting this error. Which I suspect could be down to the version of Java I’m running. Can you help?
openjdk 17.0.10 2024-01-16 LTS
OpenJDK Runtime Environment Zulu17.48+15-CA (build 17.0.10+7-LTS)
OpenJDK 64-Bit Server VM Zulu17.48+15-CA (build 17.0.10+7-LTS, mixed mode, sharing)
[JRuleCompiler, Could not create create instance using default constructor: {}]{}
java.lang.reflect.InvocationTargetException: null
at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) ~[?:?]
at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:?]
at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) ~[?:?]
at java.lang.reflect.Constructor.newInstance(Constructor.java:480) ~[?:?]
at org.openhab.automation.jrule.internal.compiler.JRuleCompiler.loadClass(JRuleCompiler.java:151) ~[?:?]
at org.openhab.automation.jrule.internal.compiler.JRuleCompiler.lambda$1(JRuleCompiler.java:110) ~[?:?]
at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992) ~[?:?]
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762) ~[?:?]
at org.openhab.automation.jrule.internal.compiler.JRuleCompiler.loadClassesFromJar(JRuleCompiler.java:94) ~[?:?]
at org.openhab.automation.jrule.internal.handler.JRuleHandler.createRuleInstances(JRuleHandler.java:312) ~[?:?]
at org.openhab.automation.jrule.internal.handler.JRuleHandler.initialize(JRuleHandler.java:220) ~[?:?]
at org.openhab.automation.jrule.internal.JRuleFactory.init(JRuleFactory.java:95) ~[?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]
at java.lang.Thread.run(Thread.java:840) [?:?]
Caused by: java.lang.NoClassDefFoundError: com/google/gson/Gson
at org.openhab.automation.jrule.sonos.SonosWsClient.<init>(SonosWsClient.java:52) ~[?:?]
at org.openhab.automation.jrule.rules.user.SonosCoordinator.<init>(SonosCoordinator.java:29) ~[?:?]
at org.openhab.automation.jrule.rules.user.SonosCoordinator.get(SonosCoordinator.java:44) ~[?:?]
at org.openhab.automation.jrule.rules.user.SonosRuleModule.fetchThingAttributes(SonosRuleModule.java:96) ~[?:?]
at org.openhab.automation.jrule.rules.user.SonosRuleModule.lambda$fetchSonosThingAttributes$5(SonosRuleModule.java:85) ~[?:?]
at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) ~[?:?]
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179) ~[?:?]
at java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1707) ~[?:?]
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[?:?]
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[?:?]
at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[?:?]
at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[?:?]
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?]
at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) ~[?:?]
at org.openhab.automation.jrule.rules.user.SonosRuleModule.fetchSonosThingAttributes(SonosRuleModule.java:85) ~[?:?]
at org.openhab.automation.jrule.rules.user.SonosRuleModule.<init>(SonosRuleModule.java:26) ~[?:?]
... 18 more
Caused by: java.lang.ClassNotFoundException: com.google.gson.Gson
at java.net.URLClassLoader.findClass(URLClassLoader.java:445) ~[?:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:592) ~[?:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:525) ~[?:?]
at org.openhab.automation.jrule.internal.handler.JRuleHandler$JRuleClassLoader.loadClass(JRuleHandler.java:545) ~[?:?]
at org.openhab.automation.jrule.sonos.SonosWsClient.<init>(SonosWsClient.java:52) ~[?:?]
at org.openhab.automation.jrule.rules.user.SonosCoordinator.<init>(SonosCoordinator.java:29) ~[?:?]
at org.openhab.automation.jrule.rules.user.SonosCoordinator.get(SonosCoordinator.java:44) ~[?:?]
at org.openhab.automation.jrule.rules.user.SonosRuleModule.fetchThingAttributes(SonosRuleModule.java:96) ~[?:?]
at org.openhab.automation.jrule.rules.user.SonosRuleModule.lambda$fetchSonosThingAttributes$5(SonosRuleModule.java:85) ~[?:?]
at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) ~[?:?]
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179) ~[?:?]
at java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1707) ~[?:?]
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[?:?]
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[?:?]
at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[?:?]
at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[?:?]
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?]
at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) ~[?:?]
at org.openhab.automation.jrule.rules.user.SonosRuleModule.fetchSonosThingAttributes(SonosRuleModule.java:85) ~[?:?]
at org.openhab.automation.jrule.rules.user.SonosRuleModule.<init>(SonosRuleModule.java:26) ~[?:?]
... 18 more
Over the weekend I built a new server and installed openHAB, so clean install and still get the same error. Could it be the version of Java I’m running?
I doubt it. Have you tried the jar where gson is inclduded as well?
Difficult to understand what happens since I don’t get this error myself, have not seen other users getting it either.
If you are experimenting with new versions of openhab, you could try to install 4.0.0 and see if it works better? (Just to see that it is not a version thing)
installed following readme. but got stuck.
runing OH 4.2.0.M2 on Windows 11
using jrule-sonos-alpha4.jar
i have also tried with alpha1 as well. but no luck. i tried renaming jar to what it has in the readme.
think that it might be the back/forward slashes that could be the issue??
2024-07-02 14:52:32.210 [INFO ] [on.jrule.internal.engine.JRuleEngine] - [JRuleEngine] Initializing Java Rule Engine with Separate Thread Executors min: 2 max: 10
2024-07-02 14:52:37.265 [INFO ] [tomation.jrule.internal.JRuleFactory] - [JRuleFactory] Initializing Java Rules Engine v4.0.0.202404081933
2024-07-02 14:52:37.266 [INFO ] [.jrule.internal.handler.JRuleHandler] - [JRuleHandler] Initializing Start Initializing JRule Automation
2024-07-02 14:52:37.276 [INFO ] [.jrule.internal.handler.JRuleHandler] - [JRuleHandler] Initializing JRule writing external Jars: C:\Program Files\openhab\conf/automation/jrule\jar
2024-07-02 14:52:37.277 [ERROR] [.internal.compiler.JRuleJarExtractor] - [JRuleJar] Failed to extract jar due to uri exception jarFilePath: C:\Program Files\openhab\conf/automation/jrule\jar\jrule.jar to: C:\Program Files\openhab\conf/automation/jrule\jar\jrule.jar
2024-07-02 14:52:37.277 [ERROR] [.internal.compiler.JRuleJarExtractor] - [JRuleJar] Failed to extract jar due to uri exception jarFilePath: C:\Program Files\openhab\conf/automation/jrule\jar\openhab-core.jar to: C:\Program Files\openhab\conf/automation/jrule\jar\openhab-core.jar
2024-07-02 14:52:37.382 [INFO ] [.jrule.internal.handler.JRuleHandler] - [JRuleHandler] Compiling generated sources