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
-
+FHEM Forum : Modul für MPD ( in german )
+
Define
- define <name> MPD <IP MPD Server | default localhost> <Port MPD Server | default 6600>
- Example:
-
- define myMPD MPD 192.168.0.99 7000
-
- if FHEM and MPD a running on the same device :
-
- define myMPD MPD
-
-
+ define <name> MPD <IP MPD Server | default localhost> <Port MPD Server | default 6600>
+ Example:
+
+ define myMPD MPD 192.168.0.99 7000
+
+ if FHEM and MPD a running on the same device :
+
+ define myMPD MPD
+
@@ -869,22 +891,23 @@ To install a MPD on a Raspberry Pi you will find a lot of documentation at the w
Currently, the following commands are defined.
- play =>- like MPC play , start playing song in playlist
- clear => like MPC clear , delete MPD playlist
- stop => like MPC stop, stops playing
- pause => like MPC pause
+ play => like MPC play , start playing song in playlist
+ clear => like MPC clear , delete MPD playlist
+ stop => like MPC stop, stops playing
+ pause => like MPC pause
previous => like MPC previous, play previous song in playlist
- next => like MPC next, play next song in playlist
- random => like MPC random, toggel on/off
- repaet => like MPC repeat, toggel on/off
+ next => like MPC next, play next song in playlist
+ random => like MPC random, toggel on/off
+ repaet => like MPC repeat, toggel on/off
+ updateDb => like MPC update
volume (%) => like MPC volume %, 0 - 100
volumeUp => inc volume ( + attr volumeStep size )
volumeDown => dec volume ( - attr volumeStep size )
playlist (playlist name) => set playlist on MPD Server
- playfile (file) => create playlist + add file to playlist + start playing
- updateDb => like MPC update
- interval => set polling interval of MPD server, overwrites attr interval temp , use 0 to disbale polling
.
- reset => reset MPD Modul
+ playfile (file) => create playlist + add file to playlist + start playing
+ IdleNow => send Idle command to MPD and wait for events to return
+ interval => set polling interval of MPD server, overwrites attr interval temp , use 0 to disable polling
+ reset => reset MPD Modul
mpdCMD => same as GET mpdCMD
@@ -902,30 +925,47 @@ To install a MPD on a Raspberry Pi you will find a lot of documentation at the w
attr <name> room MPD
statusRequest => get MPD status
- mpdCMD (cmd) => send cmd to MPD Server ( Ref http://www.musicpd.org/doc/protocol/ )
+ mpdCMD (cmd) => send a command to MPD Server ( MPD Command Ref )
currentsong => get infos from current song in playlist
- outputs => get infos about the defined MPD output devices
+ outputs => get name,id,status about all MPD output devices in /etc/mpd.conf
Attributes
-
- - interval | polling interval at MPD server, set 0 to disbale polling
- - password | (not ready yet) if password on MPD server is set
- - loadMusic | load MPD music data at startup
- - loadPlaylists | load MPD playlistsa at startup
- - volumeStep | Step size for Volume +/-
- - useIdle | send Idle cmd to MPD and wait for MPD events needs MPD Version 0.16.0 or greater
-
-
- Readings
-
+
+ - interval = polling interval at MPD server, use 0 to disable polling (default 30)
+ - password (not ready yet) if password on MPD server is set
+ - loadMusic 0|1 = load titles from MPD database at startup
+ - loadPlaylists 0|1 = load playlist names from MPD database at startup
+ - volumeStep 1|2|5|10 = Step size for Volume +/- (default 5)
+ - useIdle 0|1 = send Idle command to MPD and wait for MPD events needs MPD Version 0.16.0 or greater
+ - titleSplit 1|0 = split title to artist and title if no artist is given in songinfo (e.g. radio-stream)
+
+
+ Readings
+
all MPD internal values
-
-
+
-
=end html
+
+=begin html_DE
+
+
+MPD
+
+ FHEM Modul zur Steuerung des MPD ähnlich dem MPC (MPC = Music Player Command, das Kommando Zeilen Interface für den
+ Music Player Daemon ) (englisch)
+ Um den MPD auf einem Raspberry Pi zu installieren finden sich im Internet zahlreiche gute Dokumentaionen
+ z.B. hier
+
+
+ Eine deutsche Version der Modul Dokumentaion ist zur Zeit leider noch nicht verfügbar (aber in Arbeit)
+ Englische Version : MPD
+ Thread im FHEM Forum : Modul für MPD
+
+
+=end html_DE
=cut