openhab / openhab1-addons

Add-ons for openHAB 1.x
Eclipse Public License 2.0
3.43k stars 1.7k forks source link

MPD binding notification #2847

Closed zergasso closed 8 years ago

zergasso commented 9 years ago

In my openhab installation mpd binding updates info about track and artist played only once at system start, then nothing more even if a play/pause or previous/next is triggered on sitemap. Mpd server is on another (virtual) machine and the others clients (linux, android) in the network update info regularly on track changing.

item config is pretty straightforward as it is essentially copy/pasted from documentation of the MPD binding bundle:

String CurrentTrack    "Current track [%s]" { mpd="TITLE:avserver:tracktitle" }
String CurrentArtist    "Current artist [%s]" { mpd="ARTIST:avserver:trackartist" }
String ConcatInfo       "Now playing [%s]"

Switch Mpd_avserver_StartStop       "Start/Stop"      (Audio)  { mpd="ON:avserver:play, OFF:avserver:stop" }
Switch Mpd_avserver_NextPrev        "Track control"   (Audio)  { mpd="ON:avserver:next, OFF:avserver:prev" } 
Dimmer Mpd_avserver_VolumeControl   "Volume [%d%%]"   (Audio)  { mpd="INCREASE:avserver:volume_increase, DECREASE:avserver:volume_decrease, PERCENT:avserver:volume" }

rule config:

rule "concat"
        when
            Item CurrentTrack received update or
            Item CurrentArtist received update
        then
            ConcatInfo.postUpdate(CurrentTrack.state.toString + " / " + CurrentArtist.state.toString)
end

sitemap config:

Text label="Musica" icon="media_player1"
                    {
                        Text item=CurrentTrack
                        Text item=CurrentArtist
                        Text item=ConcatInfo
                        Switch item=Mpd_avserver_StartStop mappings=[OFF="Pause", ON="Play"]
                        Switch item=Mpd_avserver_NextPrev  mappings=[OFF="Previous", ON="Next"]
                        Slider item=Mpd_avserver_VolumeControl
                    }

some log:

tail -f /var/log/openhab/openhab.log | grep mpd
2015-07-04 16:19:59.433 [DEBUG] [o.o.b.mpd.internal.MpdActivator] - MPD binding has been started.
2015-07-04 16:19:59.451 [DEBUG] [o.o.binding.mpd.internal.MpdBinding] - MPD binding connecting to players
2015-07-04 16:19:59.719 [DEBUG] [o.o.binding.mpd.internal.MpdBinding] - MPD binding connecting to players
2015-07-04 16:19:59.734 [DEBUG] [o.o.binding.mpd.internal.MpdBinding] - Connected to player 'avserver' with config MPD [host=192.168.100.244, port=6800, password=null]
2015-07-04 16:19:59.737 [DEBUG] [o.o.binding.mpd.internal.MpdBinding] - Scheduled a daily MPD Reconnect of all MPDs
2015-07-04 16:19:59.744 [DEBUG] [o.o.binding.mpd.internal.MpdBinding] - Current song avserver: Best Progressive House Mix 2013 Vol. #2 Meets progvisions
2015-07-04 16:19:59.754 [DEBUG] [o.o.binding.mpd.internal.MpdBinding] - Updated title: CurrentTrack Best Progressive House Mix 2013 Vol. #2 Meets progvisions
2015-07-04 16:19:59.756 [DEBUG] [o.o.binding.mpd.internal.MpdBinding] - Updated artist: CurrentArtist, VA
2015-07-04 16:20:02.281 [DEBUG] [o.o.binding.mpd.internal.MpdBinding] - Volume on avserver changed to 100
2015-07-04 16:22:05.955 [INFO ] [o.o.binding.mpd.internal.MpdBinding] - executed commandLine 'stop' for player 'avserver'
2015-07-04 16:22:06.327 [DEBUG] [o.o.binding.mpd.internal.MpdBinding] - Play state of 'avserver' changed
2015-07-04 16:22:08.839 [DEBUG] [o.o.binding.mpd.internal.MpdBinding] - Volume on avserver changed to -1
2015-07-04 16:22:11.585 [INFO ] [o.o.binding.mpd.internal.MpdBinding] - executed commandLine 'play' for player 'avserver'
2015-07-04 16:22:19.536 [INFO ] [o.o.binding.mpd.internal.MpdBinding] - executed commandLine 'next' for player 'avserver'
2015-07-04 16:22:25.610 [INFO ] [o.o.binding.mpd.internal.MpdBinding] - executed commandLine 'prev' for player 'avserver'
teichsta commented 9 years ago

@mgbowman @petrklus any idea why this could happen?

snizzleorg commented 8 years ago

I have the same problem. the play state is reflected only sometimes.

then the items are uninitialised:

steffen@automator ~ $ curl http://automator.local:8080/rest/items/CurrentArtist/state
Uninitializedsteffen@automator ~ $ 

Item definitions are as above

Steamrunner commented 8 years ago

I believe this binding is simply incomplete, I found following section in the source code:

/**
* More advanced state detection - allows to detect track changes etc. 
* However, the underlying MPD library does not seem to support this well
*/
public void playerChanged(PlayerChangeEvent pce) {

}

The binding seems to rely library javampd 4.1, the latest stable version of this library seems to be 5.0.3, is this binding still actively maintained? Or should we give it a try ourselves?

snizzleorg commented 8 years ago

I wonder how many people are actually using the binding to control mpd in my case I use it to control forked-daapd in lack of a proper forked-daapd binding which of course would be much preferred

mgbowman commented 8 years ago

I'm currently using it to control mpd, albeit in its simplest form:

Switch MPD_Player1 { mpd="ON:player1:play, OFF:player1:stop" }

I never had any success with the track / artist features of the binding.

At one point, I hacked on this binding and added output enable / disable support (which was merged):

Switch MPD_Player1_Output1 { mpd="ON:player1:enable=1, OFF:player1:disable=1" }
Switch MPD_Player1_Output2 { mpd="ON:player1:enable=2, OFF:player1:disable=2" }
...

If there's interest, I will get a dev env going and do my best to update the binding to use the latest javampd and debug the track / artist issues.

teichsta commented 8 years ago

The binding seems to rely library javampd 4.1, the latest stable version of this library seems to be 5.0.3, is this binding still actively maintained? Or should we give it a try ourselves?

@Steamrunner i've created the binding long time ago but don't use it any more … so: yes, it would be great if you could talk over and help actively maintaining it again.

Thanks, Thomas E.-E.

snizzleorg commented 8 years ago

@Steamrunner although I would prefer a native forked-daapd (iTunes) binding this would be most welcome. I'm happy to help test and debug it.

teichsta commented 8 years ago

although I would prefer a native forked-daapd (iTunes) binding this would be most welcome. I'm happy to help test and debug it.

sure, but creating a new binding is much more effort than "simply" updating the underlying lib, hoping the API didn't change, and additionally implementing some handler methods. Would you agree?

snizzleorg commented 8 years ago

of course I agree. especially since I'm unable in actually doing any of the work necessary ;-)

pistoletov1974 commented 8 years ago

i have the problem with mpd binding. My player is mpd and i play internet radio streams from mpd installed on ARM Soc board. The track info does not updated in streams. I need to switch to another stream and switch it back, only after this the track and artist items received update.

stefanroellin commented 8 years ago

@pistoletov1974 your problem should be fixed with pull request #3500 which was merged two days ago and therefore should be available in the nightly builds.

Unfortunately the pull request does not fix all issues. I have observed that the binding at least once lost the connection to mpd completely and was not able to recover. I will try to reproduce my observation.

pistoletov1974 commented 8 years ago

@stefanroellin thank you! This is awesome news!

bazooker commented 8 years ago

Hello Guys, is there any way to get current status of MPD - for example "playing" or "paused"?

9037568 commented 8 years ago

Closing due to inactivity.