diff --git a/AudioMax Multiroom System/module.json b/AudioMax Multiroom System/module.json index 9983e3d..afc1a1c 100644 --- a/AudioMax Multiroom System/module.json +++ b/AudioMax Multiroom System/module.json @@ -1,5 +1,5 @@ { -"id": "{F566210E-8CFA-466D-86AC-AC884350262A}", +"id": "{F3008344-9C01-4E48-9B47-CEC362B0919D}", "name": "AudioMaxSystem", "type": 3, "vendor": "ESERA-Automation", diff --git a/AudioMax Multiroom System/module.php b/AudioMax Multiroom System/module.php index 2123db8..fddcee7 100644 --- a/AudioMax Multiroom System/module.php +++ b/AudioMax Multiroom System/module.php @@ -4,9 +4,75 @@ class AudioMaxSystem extends IPSModule { public function Create(){ //Never delete this line! parent::Create(); - + //These lines are parsed on Symcon Startup or Instance creation //You cannot use variables here. Just static values. + + //CreateVariableProfile($ProfileName, $ProfileType, $Suffix, $MinValue, $MaxValue, $StepSize, $Digits, $Icon,$Wert,$Name,$Color) + $this->CreateVariableProfile("ESERA.AMVolume",1,"%",0,40,1,0,"Intensity"); + $this->CreateVariableProfile("ESERA.AMGain",1,"%",0,15,1,0,"Intensity"); + $this->CreateVariableProfile("ESERA.AMTone",1,"%",0,15,1,0,"Intensity"); + $this->CreateVariableProfile("ESERA.AMBalance",1,"%",0,15,1,0,"Intensity"); + $this->CreateVariableProfile("ESERA.AMInput",1,"",1,4,1,0,""); + $this->CreateVariableProfile("ESERA.AMMute",0,"",0,1,1,0,"Power"); + + $this->CreateVariableAssociation("ESERA.AMInput", 1, "Input 1", "Light" , 0x00FF00); + $this->CreateVariableAssociation("ESERA.AMInput", 2, "Input 2", "Light" , 0x00FF00); + $this->CreateVariableAssociation("ESERA.AMInput", 3, "Input 3", "Light" , 0x00FF00); + $this->CreateVariableAssociation("ESERA.AMInput", 4, "Input 4", "Light" , 0x00FF00); + + $position = 1; + + for($i = 1; $i <= 6; $i++){ + + $this->RegisterVariableinteger("volume".$i, "Volume ".$i, "ESERA.AMVolume"); + $this->EnableAction("volume".$i); + //$this->IPS_SetPosition(47381, $position); + //$this->SetPosition("volume".$i, $position); + + $this->RegisterVariableinteger("gain".$i, "Gain ".$i, "ESERA.AMGain"); + $this->EnableAction("gain".$i); + $position = $position + 1; + //$this->SetPosition("gain".$i, $position); + + $this->RegisterVariableinteger("bass".$i, "Bass ".$i, "ESERA.AMTone"); + $this->EnableAction("bass".$i); + $position = $position + 1; + //$this->IPS_SetPosition("bass".$i, $position); + + $this->RegisterVariableinteger("mid".$i, "Middle ".$i, "ESERA.AMTone"); + $this->EnableAction("mid".$i); + $position = $position + 1; + //$this->SetPosition("mid".$i, $position); + + $this->RegisterVariableinteger("treble".$i, "Treble ".$i, "ESERA.AMTone"); + $this->EnableAction("treble".$i); + $position = $position + 1; + //$this->IPS_SetPosition("treble".$i, $position); + + $this->RegisterVariableinteger("balance".$i, "Balance ".$i, "ESERA.AMBalance"); + $this->EnableAction("balance".$i); + $position = $position + 1; + //$this->IPS_SetPosition("balance".$i, $position); + + $this->RegisterVariableBoolean("amp".$i, "Amplifier ".$i, "~Switch"); + $this->EnableAction("amp".$i); + $position = $position + 1; + //$this->IPS_SetPosition("amp".$i, $position); + + $this->RegisterVariableBoolean("mute".$i, "Mute Output ".$i, "~Switch"); + $this->EnableAction("mute".$i); + $position = $position + 1; + //$this->IPS_SetPosition("mute".$i, $position); + + $this->RegisterVariableInteger("input".$i, "Input ".$i, "ESERA.AMInput"); + $this->EnableAction("input".$i); + $position = $position + 1; + //$this->IPS_SetPosition("input".$i, $position); + } + + $this->ConnectParent("{C73DD44F-BF0D-4180-A0F1-D296F68024B2}"); //AudioMax Interface + //CreateVariableProfile($ProfileName, $ProfileType, $Suffix, $MinValue, $MaxValue, $StepSize, $Digits, $Icon,$Wert,$Name,$Color) $this->CreateVariableProfile("ESERA.AudioMaxVolume",1,"%",0,40,1,0,"Intensity"); $this->CreateVariableProfile("ESERA.AudioMaxGain",1,"%",0,15,1,0,"Intensity"); @@ -78,6 +144,7 @@ public function Create(){ $this->ConnectParent("{C73DD44F-BF0D-4180-A0F1-D296F68024B2}"); //AudioMax Interface + } public function Destroy(){ //Never delete this line! @@ -85,30 +152,30 @@ public function Destroy(){ } - + public function ApplyChanges(){ //Never delete this line! parent::ApplyChanges(); $this->SetReceiveDataFilter(".*\"DeviceType\":\"AUDIO\".*"); } - - + + public function ReceiveData($JSONString) { $data = json_decode($JSONString); $this->SendDebug("AudioMaxSystem", "| Room Number:" . $data->RoomNumber . "| Audio Type:" . $data->AudioType . "| Audio Value:" . $data->AudioValue, 0); - + $Number = intval($data->RoomNumber, 10); //Daten der übergebenen Variable //$Type = strval($data->AudioType,10); //Daten der übergebenen Variable $Type = $data->AudioType; $Value = intval($data->AudioValue,10); - + $this->SendDebug("DGB Rec| Room Number:", $Number, 0); $this->SendDebug("DGB Rec| Audio Type:", $Type, 0); $this->SendDebug("DGB Rec| Audio Value:", $Value, 0); - - + + if ($Type == "VOL"){ SetValue($this->GetIDForIdent("volume".$Number), $Value); $this->SendDebug(("volume ".$Number), $Value,0); @@ -120,7 +187,7 @@ public function ReceiveData($JSONString) { if ($Type == "GAI"){ SetValue($this->GetIDForIdent("gain".$Number), $Value); $this->SendDebug(("gain ".$Number), $Value,0); - } + } if ($Type == "BAS"){ SetValue($this->GetIDForIdent("bass".$Number), $Value); $this->SendDebug(("bass ".$Number), $Value,0); @@ -145,8 +212,8 @@ public function ReceiveData($JSONString) { SetValue($this->GetIDForIdent("mute".$Number), $Value); $this->SendDebug(("mute ".$Number), $Value,0); } - - + + /* if ($data->DeviceNumber == 2){ if ($data->DataPoint == 1){ @@ -157,12 +224,12 @@ public function ReceiveData($JSONString) { } } */ - + } public function RequestAction($Ident, $Value) { //$Number = 1; - + switch($Ident) { case "volume1": //$Number = 1; case "volume2": @@ -172,7 +239,7 @@ public function RequestAction($Ident, $Value) { case "volume6": $Type = "VOL"; $Number = SubStr($Ident, 6, 1); - break; + break; case "gain1": case "gain2": case "gain3": @@ -190,7 +257,7 @@ public function RequestAction($Ident, $Value) { case "input6": $Type = "INP"; $Number = SubStr($Ident, 5, 1); - break; + break; case "bass1": case "bass2": case "bass3": @@ -199,7 +266,7 @@ public function RequestAction($Ident, $Value) { case "bass6": $Type = "BAS"; $Number = SubStr($Ident, 4, 1); - break; + break; case "mid1": case "mid2": case "mid3": @@ -208,7 +275,7 @@ public function RequestAction($Ident, $Value) { case "mid6": $Type = "MID"; $Number = SubStr($Ident, 3, 1); - break; + break; case "treble1": case "treble2": case "treble3": @@ -217,7 +284,7 @@ public function RequestAction($Ident, $Value) { case "treble6": $Type = "TRE"; $Number = SubStr($Ident, 6, 1); - break; + break; case "balance1": case "balance2": case "balance3": @@ -226,7 +293,7 @@ public function RequestAction($Ident, $Value) { case "balance6": $Type = "BAL"; $Number = SubStr($Ident, 7, 1); - break; + break; case "amp1": case "amp2": case "amp3": @@ -235,7 +302,7 @@ public function RequestAction($Ident, $Value) { case "amp6": $Type = "AMP"; $Number = SubStr($Ident, 3, 1); - break; + break; case "mute1": case "mute2": case "mute3": @@ -255,18 +322,23 @@ public function RequestAction($Ident, $Value) { $this->SendDebug(("DBG: connection: ". $Value), $Value,0); return; } + + + $this->SendDebug(("DBG: send: ".$Type ." ". $Number), $Value,0); + $this->SetAudioSettingAM($Number, $Type, $Value); //$this->SendDebug(("DBG: send: ".$Type ." ". $Number), $Value,0); //$this->SetAudioSettingAM($Number, $Type, $Value); + } public function SetAudioSettingAM(int $Number, int $Type , int $Value) { $this->Send("SET,AUDIO,". $Number .",". $Type . ",". $Value .""); - $this->SendDebug(("DBG: send: ". $Number. "," . $Type . "," . $Value), $Value,0); + $this->SendDebug(("DBG: send: ". $Number. "," . $Type . "," . $Value), $Value,0); } - + public function SetConnectionAM(int $Value) { SetValue($this->GetIDForIdent("connection"), $Value); @@ -311,11 +383,16 @@ private function CreateVariableProfile($ProfileName, $ProfileType, $Suffix, $Min IPS_SetVariableProfileText($ProfileName, "", $Suffix); IPS_SetVariableProfileValues($ProfileName, $MinValue, $MaxValue, $StepSize); IPS_SetVariableProfileDigits($ProfileName, $Digits); + IPS_SetVariableProfileIcon($ProfileName, $Icon); + //IPS_SetVariableProfileAssociation($ProfileName, $Wert,$Name,$Icon ,$color); + + IPS_SetVariableProfileIcon($ProfileName, $Icon); + } } - - + + //private function CreateVariableProfile($ProfileName, $ProfileType, $Suffix, $MinValue, $MaxValue, $StepSize, $Digits, $Icon,$Wert,$Name,$Color) { private function CreateVariableAssociation($ProfileName, $Wert, $Name, $Icon , $color) { IPS_SetVariableProfileAssociation($ProfileName, $Wert, $Name, $Icon , $color);