Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MPD] doesn't work with external mpd player #10142

Closed
agh251256 opened this issue Feb 13, 2021 · 14 comments · Fixed by #10166
Closed

[MPD] doesn't work with external mpd player #10142

agh251256 opened this issue Feb 13, 2021 · 14 comments · Fixed by #10166
Labels
bug An unexpected problem or unintended behavior of an add-on

Comments

@agh251256
Copy link

MPD Binding doesn't work with external MPD-Player. I've openhab on an raspberry installed and on two raspberries I installed MPD as musicplayer. Both player worked fine and I can control this with Gnome Music Player Client.
Now I'will try this with openhab. The version on OH 2.5.latest and 3,x gives the same result. it will not work completly. OH Binding goes online and that all. I can't control anything.
My OH Installation run on IP xx.xx.xx.10 my MPD's on xx.xx.xx.13 an .20 .

The only thing what I've found is an error in the Syslog on my OH3 Raspi (after the latest update, there is nothing in the syslog):
Feb 8 20:27:57 raspiOHTest karaf[32614]: Exception in thread "OH-binding-mpd:mpd:Musik" java.lang.IllegalArgumentException: Value must be between 0 and 100 Feb 8 20:27:57 raspiOHTest karaf[32614]: #011at org.openhab.core.library.types.PercentType.validateValue(PercentType.java:57) Feb 8 20:27:57 raspiOHTest karaf[32614]: #011at org.openhab.core.library.types.PercentType.<init>(PercentType.java:42) Feb 8 20:27:57 raspiOHTest karaf[32614]: #011at org.openhab.binding.mpd.internal.handler.MPDHandler.updateMPDStatus(MPDHandler.java:257) Feb 8 20:27:57 raspiOHTest karaf[32614]: #011at org.openhab.binding.mpd.internal.protocol.MPDConnection.handleResponseStatus(MPDConnection.java:218) Feb 8 20:27:57 raspiOHTest karaf[32614]: #011at org.openhab.binding.mpd.internal.protocol.MPDConnection.onResponse(MPDConnection.java:172) Feb 8 20:27:57 raspiOHTest karaf[32614]: #011at org.openhab.binding.mpd.internal.protocol.MPDConnectionThread.processPendingCommands(MPDConnectionThread.jav Feb 8 20:27:57 raspiOHTest karaf[32614]: #011at org.openhab.binding.mpd.internal.protocol.MPDConnectionThread.run(MPDConnectionThread.java:81)
Thats all, no errors more, not in the openhab.log and so on. The events.log shows me the sending commands, but nothing works.
There are no firewalls inside my internal network. People, how brings the binding up to work are using MPD and OH on the same IP adrress, on the same raspi. That's not the way for me.

@agh251256 agh251256 added the bug An unexpected problem or unintended behavior of an add-on label Feb 13, 2021
@J-N-K
Copy link
Member

J-N-K commented Feb 13, 2021

Looks like you get a value that can‘t be converted to PercentType. Increase Binding loglevel and see if you get more information.

@agh251256
Copy link
Author

I found to change the loglevel.
I'm pressing the play button for playing the current playlist in the mpd. After changing the loglevel, I get:
2021-02-13 18:00:30.450 [WARN ] [s.impl.WebApplicationExceptionMapper] - javax.ws.rs.ClientErrorException: HTTP 405 Method Not Allowed at org.apache.cxf.jaxrs.utils.SpecExceptions.toHttpException(SpecExceptions.java:117) at org.apache.cxf.jaxrs.utils.ExceptionUtils.toHttpException(ExceptionUtils.java:168) at org.apache.cxf.jaxrs.utils.JAXRSUtils.findTargetMethod(JAXRSUtils.java:514) at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:181) at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:78) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:267) at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234) at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208) at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160) at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:216) at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:301) at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:278) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:852) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:544) at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:71) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:536) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1581) at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1307) at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:293) at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:482) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1549) at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1204) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) at org.eclipse.jetty.server.Server.handle(Server.java:494) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:374) at org.eclipse.jetty.server.HttpChannel.run(HttpChannel.java:314) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:782) at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:918) at java.base/java.lang.Thread.run(Thread.java:834)
I hope, it helps

@J-N-K
Copy link
Member

J-N-K commented Feb 13, 2021

I can reproduce the original issue (and that is a bug), but controlling a mpd instance works fine (from a remote computer). Did you configure mpd to listen on the IP address? The dault is listen to localhost only.

@agh251256
Copy link
Author

agh251256 commented Feb 13, 2021 via email

@J-N-K
Copy link
Member

J-N-K commented Feb 14, 2021

Please try if the first fix also fixes your other problems:

update org.openhab.binding.mpd https://janessa.me/esh/org.openhab.binding.mpd-3.1.0-SNAPSHOT.jar

I doubt it helps, but it's worth a try.

@agh251256
Copy link
Author

agh251256 commented Feb 14, 2021 via email

@agh251256
Copy link
Author

One question again, because I'm interesting of that. I've looking your changing code. I'm not a programer in java/C++, but I can understand a little bit. Now my question: Why do you set the volume to undef and not to the min or max value?

@J-N-K
Copy link
Member

J-N-K commented Feb 14, 2021

Playlist/album: no idea, I don‘t even use mpd

From my understanding a value of -1 means „not set/unknown“, so UNDEF seems to be the closest equivalent.

@agh251256
Copy link
Author

You can thinking about using playlist and so on, to complete the binding. ;-)
Thank you very much for your help

My understanding is that values can be +/- and greater than 100 :-)

Must I close this issue?

@J-N-K
Copy link
Member

J-N-K commented Feb 14, 2021

I think volume is usually 0-100%, what would a value of -10 mean in this context (ok, it could be dB or something like that, but that is not what mpd is reporting)?

No, please don’t close this issue until someone fixes it on openHAB.

stefanroellin added a commit to stefanroellin/openhab-addons that referenced this issue Feb 15, 2021
Fixes openhab#10142.

Signed-off-by: Stefan Roellin <stefan@roellin-baumann.ch>
@stefanroellin
Copy link
Contributor

Which version of mpd are you using? According to the protocol specification a volume -1 is deprecated and should not occur in never versions. I have nevertheless submitted a fix.
You can use an action to change the playlist - see the example at the bottom of https://www.openhab.org/addons/bindings/mpd/

stefanroellin added a commit to stefanroellin/openhab-addons that referenced this issue Feb 15, 2021
Fixes openhab#10142.

Signed-off-by: Stefan Roellin <stefan@roellin-baumann.ch>
Also-by: Jan N. Klug <jan.n.klug@rub.de>
@agh251256
Copy link
Author

Both mpd version are 0.19.21 Debian stretch

for changing the playlist/album, it's better to know which playlist/album exist. In the example, I saw some possible actions, but I don't know what is also possible. My next handicap is the english language, that is not so well. What I missed are more functions like gmpc, I know that's a dream :-)

@stefanroellin
Copy link
Contributor

This is a really old version! If you encounter other problems with the mpd binding I suggest you update to a more recent version.

With actions you can do almost everything you can do with gmpc. Have you tried the example? Define a switch named morning_music and define the rule:

rule "turn on morning music"
when
        Item morning_music changed to ON
then
        val actions = getActions("mpd","mpd:mpd:music")  // change "mpd:mpd:music" to your thing id
        if(actions === null) {
                logWarn("myLog", "actions is null")
                return
        }

        actions.sendCommand("clear");                // clears the queue
        actions.sendCommand("load", "MorningMusic"); // loads the playlist named "MorningMusic" 
        actions.sendCommand("shuffle");              // shuffle the queue
        actions.sendCommand("play");                 // play
end

Now, if the switch changes to ON, the queue is cleared, the playlist "MorningMusic" is loaded and shuffled and then played.

If you don't want to hard-code the name of the playlist you can define a string item and use the state of the item for the playlist.

For a list of commands see https://www.musicpd.org/doc/html/protocol.html

@agh251256
Copy link
Author

Dear Stefan,
I've understood the example, you can believe it. :-) Your last sentence is a good note, that I missed in the discription of the binding.

Hilbrand pushed a commit that referenced this issue Feb 17, 2021
Fixes #10142.

Signed-off-by: Stefan Roellin <stefan@roellin-baumann.ch>
Also-by: Jan N. Klug <jan.n.klug@rub.de>
themillhousegroup pushed a commit to themillhousegroup/openhab2-addons that referenced this issue May 10, 2021
Fixes openhab#10142.

Signed-off-by: Stefan Roellin <stefan@roellin-baumann.ch>
Also-by: Jan N. Klug <jan.n.klug@rub.de>
Signed-off-by: John Marshall <john.marshall.au@gmail.com>
thinkingstone pushed a commit to thinkingstone/openhab-addons that referenced this issue Nov 7, 2021
Fixes openhab#10142.

Signed-off-by: Stefan Roellin <stefan@roellin-baumann.ch>
Also-by: Jan N. Klug <jan.n.klug@rub.de>
marcfischerboschio pushed a commit to bosch-io/openhab-addons that referenced this issue May 5, 2022
Fixes openhab#10142.

Signed-off-by: Stefan Roellin <stefan@roellin-baumann.ch>
Also-by: Jan N. Klug <jan.n.klug@rub.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of an add-on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants