function Entertainment_SetRoomControlVisibility($RoomControlId, $Value) {
	   $RoomName     = IPS_GetName(IPS_GetParent($RoomControlId));
	   $RoomConfig   = get_RoomConfiguration();
	   $ControlName  = IPS_GetName($RoomControlId);
	   $WFRoomName   = $RoomConfig[$RoomName][c_Property_Name];
	   if ($WFRoomName=="") return;
	   $WFRoomId     = IPS_GetCategoryIDByName($WFRoomName, c_ID_WebFrontRoomes);

      $WFControlId = false;
		$ChildrenIds = IPS_GetChildrenIDs($WFRoomId);
		foreach($ChildrenIds as $ChildrenIdx => $ChildrenId) {
		   if (IPS_LinkExists($ChildrenId)) {
		      if (IPS_GetName($ChildrenId)==$ControlName) {
		         $WFControlId = $ChildrenId;
		      }
			} else {
				$WFControlId = @IPS_GetLinkIDByName($ControlName, $WFRoomId);
			}
		}

		if ($WFControlId!==false) {
			$WFControl=IPS_GetObject($WFControlId);
			if ($WFControl['ObjectIsHidden']<> !$Value) {
				IPS_SetHidden($WFControlId, !$Value);
			}
		}

	}
예제 #2
0
파일: orga.php 프로젝트: Spoosie/KH_UniFi
function CreateVariable($Name, $Type, $Value, $Ident = '', $ParentID = 0)
{
    echo "CreateVariable: ( {$Name}, {$Type}, {$Value}, {$Ident}, {$ParentID} ) \n";
    if ('' != $Ident) {
        $VarID = @IPS_GetObjectIDByIdent($Ident, $ParentID);
        if (false !== $VarID) {
            SetVariable($VarID, $Type, $Value);
            return;
        }
    }
    $VarID = @IPS_GetObjectIDByName($Name, $ParentID);
    if (false !== $VarID) {
        $Obj = IPS_GetObject($VarID);
        if (2 == $Obj['ObjectType']) {
            $Var = IPS_GetVariable($VarID);
            if ($Type == $Var['VariableValue']['ValueType']) {
                SetVariable($VarID, $Type, $Value);
                return;
            }
        }
    }
    $VarID = IPS_CreateVariable($Type);
    IPS_SetParent($VarID, $ParentID);
    IPS_SetName($VarID, $Name);
    if ('' != $Ident) {
        IPS_SetIdent($VarID, $Ident);
    }
    SetVariable($VarID, $Type, $Value);
}
 protected function HideOrDeaktiv(bool $hidden)
 {
     if ($this->ReadPropertyBoolean("Invert")) {
         $hidden = !$hidden;
     }
     if ($this->ReadPropertyInteger("Target") == 0) {
         echo "Target invalid.";
         return;
     }
     $Target = $this->ReadPropertyInteger("Target");
     if (!IPS_ObjectExists($Target)) {
         echo "Target invalid.";
         return;
     }
     if ($this->ReadPropertyInteger("TargetType") == 0) {
         $this->SetHiddenOrDisabled($Target, $hidden);
     } elseif ($this->ReadPropertyInteger("TargetType") == 1) {
         $Source = $this->ReadPropertyInteger("Source");
         $Childs = IPS_GetChildrenIDs($Target);
         foreach ($Childs as $Child) {
             if ($Child == $Source) {
                 continue;
             }
             if (IPS_GetObject($Child)['ObjectType'] == 6) {
                 if (IPS_GetLink($Child)['TargetID'] == $Source) {
                     continue;
                 }
             }
             $this->SetHiddenOrDisabled($Child, $hidden);
         }
     } else {
         echo "TargetType invalid.";
         return;
     }
 }
	function Entertainment_Before_SendData($Parameters) {
		if ($Parameters[0]==c_Comm_WinLIRC and $Parameters[1]=='yamahareceiver') {
			$Button      = $Parameters[2];

			// Special Handling for Muting of YamahaReceiver: Use InputSelector Phone for Muting,
			// Switch back to current Input when Muting Off
			// ==================================================================================
			if ($Button == "muteon") {
				IPSLogger_Dbg(__file__, "Set Muting 'On' for Yamaha Receiver (Switch to Phone Input)");
            WinLIRC_SendData(array(c_Comm_WinLIRC, 'yamahareceiver', 'phone'));
				return false; // Abort current Processing

			} else if ($Button=='muteoff') {
				$RoomId = get_RoomId(c_Room_LivingRoom);
				$SourceIdx = get_SourceIdxByRoomId($RoomId);
		   	Entertainment_SendDataBySourceIdx($RoomId, $SourceIdx, c_MessageType_Action);
				return false; // Abort current Processing

		   // Special Handling for Yamaha Tuner, YamahaReceiver supports only Previous/Next Station for Tuner
		   // --> Simulate Buttons for Station "1" - "8" by Previous and Next.
	   	// ===============================================================================================
			} else if ($Button == "0" or $Button == "1" or $Button == "2" or $Button == "3" or $Button == "4" or
			           $Button == "5" or $Button == "6" or $Button == "7") {
				$ControlId   = get_ControlIdByDeviceName(c_Device_YamahaTuner, c_Control_Program);
				$StationNew  = GetValue($ControlId);
				$StationObj  = IPS_GetObject($ControlId);
				$StationCurr = $StationObj["ObjectInfo"];
				IPSLogger_Trc(__file__, "Switch YamahaTuner from StationCurrent=".$StationCurr." to  StationNew=".$StationNew);

				if ($StationNew-$StationCurr <= 4 and $StationNew-$StationCurr >= 0) {
				   $IRButton = 'presetnext';
					$Count = $StationNew-$StationCurr;
				} else if (($StationCurr-$StationNew) < 0) {
				   $IRButton = 'presetlast';
					$Count = 8-($StationNew-$StationCurr);
				} else if (($StationCurr-$StationNew) <= 4) {
				   $IRButton = 'presetlast';
					$Count = $StationCurr-$StationNew;
				} else {
				   $IRButton = 'presetnext';
					$Count = 8-$StationCurr+$StationNew;
				}

				IPS_SetInfo ($ControlId, $StationNew);
				IPSLogger_Dbg(__file__, "Switch Yamaha TunerStation from ".$StationCurr." to ".$StationNew." ==> ".$Count."x ".$IRButton);
				for ($idx=1; $idx<=$Count; $idx++) {
					include_once "Entertainment_InterfaceWinLIRC.ips.php";
               WinLIRC_SendData(array(c_Comm_WinLIRC, 'yamahareceiver', $IRButton));
					sleep(0.2);
				}
				return false; // Abort current Processing
			}
		}
		return true;
	}
	function Migrate_Category($categoryId, $filePath) {
		foreach (IPS_GetChildrenIDs($categoryId) as $idx=>$childId) {
			$object = IPS_GetObject($childId);
			switch($object['ObjectType']) {
				case 0: // Category
				case 1: // Instance
					Migrate_Category($childId, $filePath);
					break;
				case 3: // Script
					Delete_Script($childId, $filePath);
					break;
				default:
					// Ignore
			}
		}
	}
 protected function HideOrDeaktiv(bool $hidden)
 {
     if ($this->ReadPropertyBoolean("Invert")) {
         $hidden = !$hidden;
     }
     // Links erzeugen / prüfen wird nur bei ApplyChanges gemacht
     $Source = $this->ReadPropertyInteger("Source");
     $Childs = IPS_GetChildrenIDs($this->InstanceID);
     foreach ($Childs as $Child) {
         if (IPS_GetObject($Child)['ObjectType'] != 6) {
             continue;
         }
         if (IPS_GetLink($Child)['TargetID'] == $Source) {
             continue;
         }
         $this->SetHiddenOrDisabled($Child, $hidden);
     }
 }
예제 #7
0
 private function processChilds($childCategory, $state)
 {
     $childs = IPS_GetChildrenIDs($childCategory);
     foreach ($childs as $child) {
         $link = @IPS_GetLink($child);
         if ($link) {
             $variableID = $link["TargetID"];
             $variableObject = IPS_GetObject($variableID);
             $variable = IPS_GetVariable($variableID);
             $ipsValue = $state;
             // request associated action for the specified variable and value
             if ($variable["VariableCustomAction"] > 0) {
                 IPS_RunScriptEx($variable["VariableCustomAction"], array("VARIABLE" => $variableID, "VALUE" => $ipsValue));
             } else {
                 IPS_RequestAction($variableObject["ParentID"], $variableObject["ObjectIdent"], $ipsValue);
             }
         }
     }
 }
예제 #8
0
             IPS_SetIdent($VarId, $ident);
         }
         HM_RequestStatus($HMDevice, $ident);
     }
 }
 $Childs = IPS_GetChildrenIDs($HMDevice);
 if (count($Childs) == 0) {
     echo "Gerät mit der Addresse " . (string) $Channel['Address'] . " hat keine Datenpunkte." . PHP_EOL;
     echo "  Gerät mit Namen '" . utf8_decode((string) $Channel['Name']) . "' wird wieder gelöscht." . PHP_EOL;
     echo "--------------------------------------------------------------------" . PHP_EOL;
     IPS_DeleteInstance($HMDevice);
     continue;
 }
 $DeviceHidden = true;
 foreach ($Childs as $Var) {
     $Obj = IPS_GetObject($Var);
     if (array_key_exists($Obj['ObjectIdent'], $Mapping)) {
         $Name = sprintf($Mapping[$Obj['ObjectIdent']]['Name Raum'], utf8_decode((string) $Channel['Name']), utf8_decode((string) $Channel->Room[0]['Name']));
         //				    $Name = 		$NameMappingRoom[$Obj['ObjectIdent']];
         IPS_SetName($Var, $Name);
         // Profil ändern, wenn nicht leer im Mapping
         if ($Mapping[$Obj['ObjectIdent']]['Profil'] != '') {
             if (!@IPS_SetVariableCustomProfile($Var, $Mapping[$Obj['ObjectIdent']]['Profil'])) {
                 echo "Fehler bei Gerät mit der Addresse " . (string) $Channel['Address'] . " und Datenpunkt " . $Obj['ObjectIdent'] . PHP_EOL;
                 echo "  Profil '" . $Mapping[$Obj['ObjectIdent']]['Profil'] . "' konnte nicht zugewiesen werden." . PHP_EOL;
                 echo "--------------------------------------------------------------------" . PHP_EOL;
             }
         }
         if (IPS_GetVariable($Var)['VariableAction'] > 0) {
             // Standardaktion möglich
             if ($Mapping[$Obj['ObjectIdent']]['Action'] === true) {
 /**
  * constructor
  *
  * first constructor: used to bind an existing device variable to the power meter. 
  * e.g. the 'POWER' variable for HomeMatic HM-ES-PMSw1-Pl, there is no need to create a new variable, but
  * it's necessary to enable logging for it and provide a interface for that variable
  *
  * @param integer $instanceId instance id of the variable
  * @param IPSVariableProfile $profile variable profile for this variable
  * @param boolean $enableLogging enables or disables the ips functionality to log variable changes in a database
  * @param integer $archiveId instance id of the archive control (usually located in IPS\core)
  * @param boolean $debug enables / disables debug information
  *
  * @throws Exception if the parameter \$profile is not an IPSVariableProfile datatype
  * @access public
  */
 private function __construct1($instanceId, $profile = NULL, $enableLogging = false, $archiveId = NULL, $debug = false)
 {
     if (isset($profile) && !$profile instanceof IPSVariableProfile) {
         throw new Exception("Parameter \$profile must be an instance of IPSVariableProfile!");
     }
     //if($debug) echo "Parameter \$enableLogging = $enableLogging\n";
     $obj = @IPS_GetObject($instanceId);
     if ($obj == NULL) {
         throw new Exception("Object with id '{$instanceId}' does not exist");
     }
     $this->id = $instanceId;
     $this->name = $obj["ObjectName"];
     $this->parent = $obj["ParentID"];
     $this->aggregationType = 0;
     $var = IPS_GetVariable($this->id);
     if ($profile->getName() != $var["VariableProfile"]) {
         IPS_SetVariableCustomProfile($this->id, $profile->getName());
         IPS_SetInfo($this->id, "this variable was edited by script " . $_IPS['SELF'] . " - variable profile was set to '" . $profile->getName() . "'");
     }
     $this->profile = $profile;
     $this->enableLogging = $enableLogging;
     $this->archiveId = $archiveId;
     $this->debug = $debug;
     $this->verifyVariableLogging();
 }
예제 #10
0
 public function Update()
 {
     $holiday = $this->GetFeiertag();
     if (!IPS_GetObject($this->GetIDForIdent("IsHoliday"))['ObjectIsHidden']) {
         IPS_SetHidden($this->GetIDForIdent("IsHoliday"), true);
     }
     $this->SetValueString("Holiday", $holiday);
     if ($holiday != "Arbeitstag" and $holiday != "Wochenende") {
         $this->SetValueBoolean("IsHoliday", true);
     } else {
         $this->SetValueBoolean("IsHoliday", false);
     }
 }
예제 #11
0
		function IPS_GetIdent($objId) {
			$object = IPS_GetObject($objId);
			$ident  = $object['ObjectIdent'];
			return $ident;
		}
예제 #12
0
 /**
  * Liest alle zu Überwachenden Variablen ein.
  *
  * @access private
  */
 private function GetAllTargets()
 {
     $Links = IPS_GetChildrenIDs($this->InstanceID);
     foreach ($this->NoTriggerVarList->Items as $IPSVar) {
         $this->UnregisterVariableWatch($IPSVar->VarId);
         $this->UnregisterLinkWatch($IPSVar->LinkId);
     }
     $TriggerVarList = new TNoTriggerVarList();
     foreach ($Links as $Link) {
         $Objekt = IPS_GetObject($Link);
         if ($Objekt['ObjectType'] != otLink) {
             continue;
         }
         $Target = @IPS_GetObject(IPS_GetLink($Link)['TargetID']);
         if ($Target === false) {
             continue;
         }
         if ($Target['ObjectType'] != otVariable) {
             continue;
         }
         //      zur Liste hinzufügen und Register auf Variable, Link etc...
         $NoTriggerVar = new TNoTriggerVar($Target['ObjectID'], $Link, false);
         $TriggerVarList->Add($NoTriggerVar);
     }
     $this->NoTriggerVarList = $TriggerVarList;
     foreach ($TriggerVarList->Items as $IPSVar) {
         $this->RegisterVariableWatch($IPSVar->VarId);
         $this->RegisterLinkWatch($IPSVar->LinkId);
     }
 }
예제 #13
0
 function IPS_GetInfo($ObjectId)
 {
     return ($var = @IPS_GetObject($ObjectId)) ? $var['ObjectInfo'] : false;
 }
예제 #14
0
 protected function SetHiddenOrDisabled($ObjectID, $Value)
 {
     if (IPS_GetObject($ObjectID)["ObjectIsHidden"] != $Value) {
         IPS_SetHidden($ObjectID, $Value);
     }
 }
예제 #15
0
 protected function SetHidden($Ident, $isHidden)
 {
     if (IPS_GetObject($this->GetIDForIdent($Ident))['ObjectIsHidden'] != $isHidden) {
         IPS_SetHidden($this->GetIDForIdent($Ident), $isHidden);
     }
 }
예제 #16
0
		/**
       * @public
		 *
		 * Empfang von Daten
		 *
	    * @param string $string - Empfangene Daten vom Display
	    * @param boolean $useEvents - Anlegen von Events für jede visualisierte Variable
		 */
		public function ReceiveText($string, $useEvents=true) {
		   if ($useEvents) {
				$this->DropEvents();
			}
			if (substr($string,0,1)==chr(27)) {
				switch(substr($string,1,1)) {
					case 'A': // Button Code received
						$cmd = ord(substr($string,3));
						$object = $this->GetObjectDataByCmd($cmd);
						if ($object===false) {
							$this->ReceiveCodeSpecial($cmd);
							break;
						}

						$objectData = IPS_GetObject((int)$object['Id']);
						switch($objectData['ObjectType']) {
							case 0: // Category
							case 1: // Instance
								$this->ReceiveCodeCategory($object);
								break;
							case 2: // Variable
								$this->ReceiveCodeVariable($object);
								break;
							case 3: // Script
								$this->ReceiveCodeScript($object);
								break;
							default:
								// Unsupported Object ...
						}
						break;

					case 'B': // Bargraph Value received
						$graph = ord(substr($string,3,1));
						$value = ord(substr($string,4));
						$object = $this->GetObjectDataByCmd($graph);
						$object['Value'] = (int)$value-10; // Correct Value (BarGraph 0..100 doesnt work, 10..110 works???)
						$this->ReceiveCodeVariable($object);
						break;
					default:
						// Unsupported Message Type
				}
			}

			$this->RefreshDisplay();

		   if ($useEvents) {
				$this->GenerateEvents();
			}
		}