|
From: <vl...@us...> - 2013-01-20 12:32:03
|
Revision: 1350
http://openautomation.svn.sourceforge.net/openautomation/?rev=1350&view=rev
Author: vlamers
Date: 2013-01-20 12:31:53 +0000 (Sun, 20 Jan 2013)
Log Message:
-----------
changed playlist Handling into array for numbers over 10
Modified Paths:
--------------
wiregate/plugin/generic/mpd_Player2.pl
Modified: wiregate/plugin/generic/mpd_Player2.pl
===================================================================
--- wiregate/plugin/generic/mpd_Player2.pl 2013-01-20 10:15:48 UTC (rev 1349)
+++ wiregate/plugin/generic/mpd_Player2.pl 2013-01-20 12:31:53 UTC (rev 1350)
@@ -16,13 +16,13 @@
my $Kanal2 = "Rear"; # Channel of the second speaker pair
my $volkanal2 = "40%"; # The volume of the 2nd Speaker
my $cardnum = "1"; # Hardware Number of the Sound card
-my $Speaker = "Speaker,1"; # Name of the output ( My soundcard is defined as following: Speaker,1 Front; Speaker,1 Rear
+my $Speaker = "Speaker,0"; # Name of the output ( My soundcard is defined as following: Speaker,1 Front; Speaker,1 Rear
## mpd
my $mpdname = "mpd2"; # the name of the mpd instance
my $IP = "192.168.178.33"; # The IP where the mpd Instanz is running
my $Port = "6601"; # Port of the mpd Instanz
-my $volume_anfang = "35"; # This Volume will be set for mpd
+my $volume_anfang = "30"; # This Volume will be set for mpd
# Aus wenn Fernseher an
my $Fernseher = '3/0/0'; # Fernseher
@@ -51,7 +51,7 @@
my $Partymodus = '13/1/21'; # GA for Partymodus
my $vol_party = "100%"; # With % Symbol
-# Quellen
+# Outputs
my $kueche = '13/1/5'; # k\xFCche enable/disable
my $kueche_nr = "1"; # mpd output number
my $wohnz = '13/1/8'; # Wohnzimmer enable/disable
@@ -64,12 +64,15 @@
# Playlist
my $playlist = '13/1/24'; # the playlist number will be send here (value 1 - 255)
-my $playlist1 = "Antenne";
-my $playlist2 = "Christina";
-my $playlist3 = "Volker";
-my $playlist4 = "Kinderlieder";
+my $pl;
+my $nummer;
+my @playlist;
+push @playlist, {name=>"Antenne", nummer=>"1"};
+push @playlist, {name=>"Christina", nummer=>"2"};
+push @playlist, {name=>"Volker", nummer=>"3"};
+push @playlist, {name=>"Welle1", nummer=>"4"};
##################################################
################Ende Einstellungen################
##################################################
@@ -85,7 +88,7 @@
$plugin_subscribe{$Partymodus}{$plugname} = 1;
$plugin_subscribe{$addr_pn}{$plugname} = 1;
$plugin_subscribe{$laut_GA}{$plugname} = 1;
-$plugin_subscribe{$knx_addr_vol}{$plugname} = 1;
+# $plugin_subscribe{$knx_addr_vol}{$plugname} = 1;
$plugin_subscribe{$wohnz}{$plugname} = 1;
$plugin_subscribe{$kueche}{$plugname} = 1;
$plugin_subscribe{$Bad}{$plugname} = 1;
@@ -94,29 +97,31 @@
# Radio on/off
if ($msg{'dst'} eq ($knx_addr_player2))
-{ if ($msg{'apci'} eq 'A_GroupValue_Write') # change volume
+{ if (($msg{'apci'} eq 'A_GroupValue_Write') && defined $msg{'value'})
{ if ($msg{'value'} == 01) {
- knx_write($verstaerker,1,1);
+# my $debug = `/etc/init.d/$mpdname restart`;
+ my $debug = `amixer -c $cardnum set $Speaker $Kanal $vol_alsa && amixer -c $cardnum set $Speaker $Kanal2 $volkanal2`;
+ knx_write($laut_GA ,$volume_anfang,5);
+ knx_write($playlist,1,1);
+ knx_write($verstaerker,1,1);
knx_write($Bad,0,1);
knx_write($wohnz,1,1);
knx_write($kueche,1,1);
- my $debug = `/etc/init.d/$mpdname restart`;
- my $debug = `amixer -c $cardnum set $Speaker $Kanal $vol_alsa && amixer -c $cardnum set $Speaker $Kanal2 $volkanal2`;
- knx_write($playlist,1,1);
- knx_write($laut_GA ,$volume_anfang,5);
- return "Player 2 l\xE4uft";
+return "Player 2 l\xE4uft";
+
+
}
if ($msg{'value'} == 00) {
knx_write($verstaerker,0,1); # Verstaerker aus
my $debug = `MPD_HOST=$IP MPD_PORT=$Port mpc stop`;
return "Player 2 aus";}}}
# Aus wenn Fernseher an
-if ($msg{'dst'} eq ($Fernseher) && ($msg{'apci'} eq 'A_GroupValue_Write') && ($msg{'value'} == 1)) {
+if ($msg{'dst'} eq ($Fernseher) && ($msg{'apci'} eq 'A_GroupValue_Write') && (defined $msg{'value'}) && ($msg{'value'} == 1)) {
knx_write( $knx_addr_player2, 0,1 );
return "Player 2 aus Fernseher"; }
#################### Volume step ################################
if ($msg{'dst'} eq ($Vol_addr))
-{ if ($msg{'apci'} eq 'A_GroupValue_Write') # change volume
+{ if (($msg{'apci'} eq 'A_GroupValue_Write') && defined $msg{'value'}) # change volume
{ if ($msg{'data'} == $vol_up_data) {
my $debug = `MPD_PORT=$Port MPD_HOST=$IP mpc volume +$volumestep`;
return; }
@@ -125,15 +130,15 @@
my $debug = `MPD_PORT=$Port MPD_HOST=$IP mpc volume -$volumestep`;
return;}}}
###################### Vol receive ####################################
-if ($msg{'dst'} eq ($laut_GA) && ($msg{'apci'} eq 'A_GroupValue_Write'))
+if (($msg{'dst'} eq ($laut_GA)) && (($msg{'apci'} eq 'A_GroupValue_Write')) && ((defined $msg{'value'})))
{ my $vol1 = decode_dpt5($msg{'data'});
my $vol = round($vol1);
my $debug = `MPD_PORT=$Port MPD_IP=$IP mpc volume $vol`;
my $debug = `MPD_PORT=$Port MPD_IP=$IP mpc volume > /tmp/test.txt`;
- knx_write($knx_addr_vol,$vol,5);
+ # knx_write($knx_addr_vol,$vol,5);
return $vol1;}
###################### Partymodus ##########################################
-if ($msg{'dst'} eq ($Partymodus) && ($msg{'apci'} eq 'A_GroupValue_Write'))
+if ($msg{'dst'} eq ($Partymodus) && ($msg{'apci'} eq 'A_GroupValue_Write') && (defined $msg{'value'}))
{ if ($msg{'data'} == 01) {
knx_write($kueche,00,1);
knx_write($wohnz,1,1);
@@ -148,7 +153,7 @@
return;}}
######################### prev / next #####################################################
if ($msg{'dst'} eq ($addr_pn))
-{ if ($msg{'apci'} eq 'A_GroupValue_Write') # change volume
+{ if (($msg{'apci'} eq 'A_GroupValue_Write') && (defined $msg{'value'})) # change volume
{ if ($msg{'value'} == 1) {
my $debug = `MPD_PORT=$Port MPD_HOST=$IP mpc next`;
return "next"; }
@@ -156,28 +161,33 @@
if ($msg{'value'} == 0) {
my $debug = `MPD_PORT=$Port MPD_HOST=$IP mpc prev`;
return "prev";}}}
-####################### Quellen ########################################
+####################### Outputs ########################################
# wohnz
- if ($msg{'dst'} eq $wohnz && ($msg{'apci'} eq 'A_GroupValue_Write'))
+ if (($msg{'dst'} eq $wohnz && ($msg{'apci'} eq 'A_GroupValue_Write')) && (defined $msg{'value'}))
{ if (($msg{'value'} == 01)) {
+return ($msg{'value'});
my $debug = `MPD_HOST=$IP MPD_PORT=$Port mpc enable $wohnz_nr`;
+plugin_log($plugname, "quellen");
return; }
if (($msg{'value'} == 00)) {
my $debug = `MPD_HOST=$IP MPD_PORT=$Port mpc disable $wohnz_nr`;
+plugin_log($plugname, "quellen");
return; }}
# kueche
- if ($msg{'dst'} eq $kueche && ($msg{'apci'} eq 'A_GroupValue_Write'))
+ if (($msg{'dst'} eq $kueche && ($msg{'apci'} eq 'A_GroupValue_Write')) && (defined $msg{'value'}))
{ if (($msg{'data'} == 01)) {
my $debug = `MPD_HOST=$IP MPD_PORT=$Port mpc enable $kueche_nr`;
- return "OK"; }
+plugin_log($plugname, "quellen");
+return "OK"; }
if (($msg{'data'} == 00)) {
my $debug = `MPD_HOST=$IP MPD_PORT=$Port mpc disable $kueche_nr`;
+plugin_log($plugname, "quellen");
return "nOK";}else {return 0;}}
# Bad
- if ($msg{'dst'} eq $Bad && ($msg{'apci'} eq 'A_GroupValue_Write'))
+ if ($msg{'dst'} eq $Bad && ($msg{'apci'} eq 'A_GroupValue_Write') && (defined $msg{'value'}))
{
if (($msg{'value'} == 01)) {
my $debug = `MPD_HOST=$IP MPD_PORT=$Port mpc enable $Bad_nr`;
@@ -189,31 +199,25 @@
###################### Playlist #########################################
if ($msg{'dst'} eq ($playlist) && ($msg{'apci'} eq 'A_GroupValue_Write'))
-{ if ($msg{'data'} == 01){
- my $playlist = $playlist1;
+# && (defined $msg{'value'})
+
+{
+my $nummer = decode_dpt(0,$msg{'data'},6.001);
+foreach my $element (@playlist){
+if ($nummer == $element->{nummer}){
+
+
+
+
+
+
my $debug = `MPD_PORT=$Port MPD_IP=$IP mpc clear`;
- my $debug = `MPD_PORT=$Port MPD_IP=$IP mpc load $playlist`;
+ my $debug = `MPD_PORT=$Port MPD_IP=$IP mpc load $element->{name}`;
my $debug = `MPD_PORT=$Port MPD_IP=$IP mpc play`;
- return "1";}
-if ($msg{'data'} == 02){
- my $playlist = $playlist2;
- my $debug = `MPD_PORT=$Port MPD_IP=$IP mpc clear`;
- my $debug = `MPD_PORT=$Port MPD_IP=$IP mpc load $playlist`;
- my $debug = `MPD_PORT=$Port MPD_IP=$IP mpc play`;
- return "2";}
-if ($msg{'data'} == 03){
- my $playlist = $playlist3;
- my $debug = `MPD_PORT=$Port MPD_IP=$IP mpc clear`;
- my $debug = `MPD_PORT=$Port MPD_IP=$IP mpc load $playlist`;
- my $debug = `MPD_PORT=$Port MPD_IP=$IP mpc play`;
- return "3";}
-if ($msg{'data'} == 04){
- my $playlist = $playlist4;
- my $debug = `MPD_PORT=$Port MPD_IP=$IP mpc clear`;
- my $debug = `MPD_PORT=$Port MPD_IP=$IP mpc load $playlist`;
- my $debug = `MPD_PORT=$Port MPD_IP=$IP mpc play`;
- return "4";}
+ return $element->{name};
+;}}}
+
else {
my $pl = ($msg{'data'});
return $pl;
-}}
\ No newline at end of file
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|