From aca0dcd89f1895681baec8c880602c082b28d130 Mon Sep 17 00:00:00 2001 From: wzut Date: Mon, 17 Feb 2014 21:32:40 +0000 Subject: [PATCH] 73_MPD : command added IdleNow , doc update , V0.95 git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@4980 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/73_MPD.pm | 126 +++++++++++++++++++++++++++++--------------- 1 file changed, 83 insertions(+), 43 deletions(-) diff --git a/fhem/FHEM/73_MPD.pm b/fhem/FHEM/73_MPD.pm index 6f56a1e55..aec332e89 100644 --- a/fhem/FHEM/73_MPD.pm +++ b/fhem/FHEM/73_MPD.pm @@ -3,6 +3,8 @@ # (c) 2014 Copyright: Wzut # All rights reserved # +# FHEM Forum : http://forum.fhem.de/index.php/topic,18517.0.html +# # This code is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or @@ -17,7 +19,12 @@ # GNU General Public License for more details. ################################################################ -# Version 0.9 - 15.02.14 + +# Version 0.95 - 17.02.14 +# add command set IdleNow +# +# Version 0.9 - 15.02.14 +# Version 0.8 - 01.02.14 , first version on SVN package main; @@ -62,7 +69,8 @@ my %sets = ( "updateDb:noArg" => "", "interval" => "", "mpdCMD" => "", - "reset:noArg" => "" + "reset:noArg" => "", + "IdleNow:noArg" => "" ); @@ -252,7 +260,8 @@ sub MPD_GetUpdate($) { if (AttrVal($name, "useIdle", 0) && !$error) { $hash->{helper}{RUNNING_PID} = BlockingCall("MPD_IdleStart", $name."|".$hash->{HOST}."|".$hash->{PORT}, "MPD_IdleDone", $hash) unless(exists($hash->{helper}{RUNNING_PID})); - Log 4 , "$name IdleStart with PID : ".$hash->{helper}{RUNNING_PID}{pid}; + $hash->{IPID} = $hash->{helper}{RUNNING_PID}; + Log 4 , "$name IdleStart with PID : ".$hash->{helper}{RUNNING_PID}{pid} if($hash->{helper}{RUNNING_PID}); } @@ -284,7 +293,7 @@ sub MPD_Set($@) my $vol_now = int($hash->{VOLUME}); my $vol_new; - if ($cmd eq "reset") { $hash->{".reset"} = 1; $ret = MPD_updateConfig($hash); } + if ($cmd eq "reset") { $hash->{".reset"} = 1; MPD_updateConfig($hash); return undef;} if ($cmd eq "pause") { $ret = mpd_cmd($hash, "pause"); } if ($cmd eq "stop") { $ret = mpd_cmd($hash, "stop"); } if ($cmd eq "update") { $ret = mpd_cmd($hash, "update"); } @@ -359,11 +368,24 @@ sub MPD_Set($@) { return "$name: Set with short interval, must be 0 or greater" if(int($a[2]) < 0); # update timer + RemoveInternalTimer($hash); $hash->{INTERVAL} = $a[2]; InternalTimer(gettimeofday()+$hash->{INTERVAL}, "MPD_GetUpdate", $hash, 0) if ($hash->{INTERVAL}); return undef; } + if ($cmd eq "IdleNow") + { + return "$name: sorry, one Idle process is always running with pid ".$hash->{helper}{RUNNING_PID}{pid} if($hash->{helper}{RUNNING_PID}); + $hash->{helper}{RUNNING_PID} = BlockingCall("MPD_IdleStart", $name."|".$hash->{HOST}."|".$hash->{PORT}, "MPD_IdleDone", $hash) unless(exists($hash->{helper}{RUNNING_PID})); + if($hash->{helper}{RUNNING_PID}) + { + $hash->{IPID} = $hash->{helper}{RUNNING_PID}{pid}; + return "$name: idle process started with PID : ".$hash->{IPID}; } + else { return "$name: idle process start failed !"; } + } + + # die ersten beiden brauchen wir nicht mehr shift @a; @@ -404,7 +426,7 @@ sub MPD_Set($@) mpd_cmd($hash, "status"); - readingsSingleUpdate($hash,"error",$ret,1) if($ret); + # readingsSingleUpdate($hash,"error",$ret,1) if($ret); ToDo : warum ist error manchmal = "0" ?? InternalTimer(gettimeofday()+$hash->{INTERVAL}, "MPD_GetUpdate", $hash, 0) if ($hash->{INTERVAL}); @@ -847,20 +869,20 @@ sub MPD_summaryFn($$$$) {

MPD

FHEM module to control a MPD like the MPC (MPC = Music Player Command, the command line interface to the Music Player Daemon )
To install a MPD on a Raspberry Pi you will find a lot of documentation at the web e.g. http://www.forum-raspberrypi.de/Thread-tutorial-music-player-daemon-mpd-und-mpc-auf-dem-raspberry-pi in german
-
Attributes - -
- Readings - - =end html + +=begin html_DE + + +

MPD

+ +=end html_DE =cut