function Entertainment_SetRemoteControl($Id, $Value) {
	   $DeviceName = IPS_GetName(IPS_GetParent($Id));
		if (!isDevicePoweredOnByDeviceName($DeviceName)) {
		  return;
		}
		IPSLogger_Dbg(__file__, 'Set RemoteControl for Device "'.$DeviceName.'": '.$Value);
		SetValue($Id, $Value);
		Entertainment_SetRoomControlByDeviceControlId($Id, $Value);
	}
	function Entertainment_SetRoomPower($PowerId, $Value, $PowerOnDevices=true) {
	   if (GetValue($PowerId) <> $Value) {
	      IPSLogger_Inf(__file__, 'Set Power for Room "'.IPS_GetName(IPS_GetParent($PowerId)).'" '.bool2OnOff($Value));
			SetValue($PowerId, $Value);
	      Entertainment_SetRoomVisible($PowerId, $Value);
			if ($PowerOnDevices) {
	      	Entertainment_SetDevicePowerByRoomId(IPS_GetParent($PowerId), $Value);
			}
	      Entertainment_SyncRoomControls(IPS_GetParent($PowerId));
	   }
	}
	function WinLIRC_ReceiveData_Variable($VariableId, $Value) {
	   if ($Value == "") {
			return;
		}

		$Button = $Value;
		$InstanceId = IPS_GetParent($VariableId);
		$ChildrenIds = IPS_GetChildrenIDs($InstanceId);
		foreach ($ChildrenIds as $Id) {
		   if ($Id <> $VariableId) {
		      $RemoteControl = GetValue($Id);
		   }
		}
     	IPSLogger_Com(__file__, "Received Data from WinLIRC-Variable, Control='$RemoteControl', Command='$Button'");
 		$MessageType = get_MessageTypeByControl($RemoteControl);
		WinLIRC_ReceiveData($RemoteControl, $Button, $MessageType);
	}
	function get_ControlType($ControlId) {
		$Name = IPS_GetName($ControlId);
		$ParentName = IPS_GetName(IPS_GetParent($ControlId));
		$CategoryId = IPS_GetParent(IPS_GetParent($ControlId));

		if ($CategoryId == c_ID_Roomes) {
			$RoomData = get_RoomConfiguration();
			foreach($RoomData[$ParentName] as $ControlType => $ControlProperties) {
				if (!is_array($ControlProperties)) continue;
			   if ($ControlProperties[c_Property_Name] == $Name) {
					return $ControlType;
				}
			}
			return "";
		} else if ($CategoryId == c_ID_Devices) {
			$DeviceData = get_DeviceConfiguration();
			foreach($DeviceData[$ParentName] as $ControlType => $ControlProperties) {
				if (!is_array($ControlProperties)) continue;
			   if ($ControlProperties[c_Property_Name] == $Name) {
					return $ControlType;
				}
			}
			return "";
		} else {
			return "";
		}
	}
Esempio n. 5
0
	function get_CirclyIdByControlId($ControlId) {
		$CirclyId = IPS_GetParent($ControlId);
		if ($CirclyId === false) {
			IPSLogger_Err(__file__, "CircleId could NOT be found for ControlId=$ControlId");
			exit;
		}

		return $CirclyId;
	}
Esempio n. 6
0
<?php

// WLAN Enabled Variable triggert dieses Skript
SetValue($_IPS["VARIABLE"], $_IPS["VALUE"]);
// ID dieses WLANs rausfinden
$parentID = IPS_GetParent($_IPS["VARIABLE"]);
$idID = IPS_GetVariableIDByName("ID", $parentID);
$groupID = GetValue($idID);
$config["enabled"] = $_IPS["VALUE"];
$parentID = IPS_GetParent($_IPS["SELF"]);
UniFi_SetWLANConfig($parentID, $groupID, $config);
	function Entertainment_SetDevicePower($PowerId, $Value, $MessageType=c_MessageType_Action) {
	   $DeviceName = IPS_GetName(IPS_GetParent($PowerId));
      Entertainment_SetDevicePowerByDeviceName($DeviceName, $Value, $MessageType);
	}
	function Entertainment_SetSource($SourceId, $Value, $MessageType=c_MessageType_Action) {
	   if (GetValue($SourceId) <> $Value) {
		   $RoomId = IPS_GetParent($SourceId);
		   $SourceName = get_SourceName($RoomId, $Value);
		   IPSLogger_Inf(__file__, 'Set Source "'.$SourceName.'" of Room '.IPS_GetName($RoomId));
			SetValue($SourceId, $Value);
			if (!IsRoomPoweredOn($RoomId)) {
				Entertainment_SetRoomPowerByRoomId($RoomId, true, false);
			}
			Entertainment_SetDeviceControlByRoomId($RoomId, c_Control_Muting, false);
		   Entertainment_SetDevicePowerByRoomId($RoomId, true);
		   Entertainment_SendDataBySourceIdx($RoomId, $Value, $MessageType);
         Entertainment_SyncRoomControls($RoomId);
			Entertainment_PowerOffUnusedDevices();
		}
	}
Esempio n. 9
0
            if ($sleeptimer) {
                $SleeptimerArray = explode(":", $sonos->GetSleeptimer());
                $SleeptimerMinutes = $SleeptimerArray[0] * 60 + $SleeptimerArray[1];
                if ($SleeptimerArray[2]) {
                    $SleeptimerMinutes = $SleeptimerMinutes + 1;
                }
            } else {
                $SleeptimerMinutes = 0;
            }
            SetValueInteger(IPS_GetObjectIDByName("Sleeptimer", IPS_GetParent($_IPS["SELF"])), $SleeptimerMinutes);
        }
    }
    $nowPlaying = GetValueString(IPS_GetObjectIDByName("nowPlaying", IPS_GetParent($_IPS["SELF"])));
    if ($actuallyPlaying != $nowPlaying) {
        SetValueString(IPS_GetObjectIDByName("nowPlaying", IPS_GetParent($_IPS["SELF"])), $actuallyPlaying);
    }
}
// Set Group Volume
if (IPS_GetProperty(IPS_GetParent($_IPS["SELF"]), "GroupCoordinator")) {
    $groupMembers = GetValueString(IPS_GetObjectIDByName("GroupMembers", IPS_GetParent($_IPS["SELF"])));
    $groupMembersArray = array();
    if ($groupMembers) {
        $groupMembersArray = array_map("intval", explode(",", $groupMembers));
    }
    $groupMembersArray[] = IPS_GetParent($_IPS["SELF"]);
    $GroupVolume = 0;
    foreach ($groupMembersArray as $key => $ID) {
        $GroupVolume += GetValueInteger(IPS_GetObjectIDByName("Volume", $ID));
    }
    SetValueInteger(IPS_GetObjectIDByName("GroupVolume", IPS_GetParent($_IPS["SELF"])), intval(round($GroupVolume / sizeof($groupMembersArray))));
}
Esempio n. 10
0
 private function ParentIDermitteln($ParentNr, $InstanzID)
 {
     switch ($this->ReadPropertyInteger($ParentNr)) {
         case 1:
             $ParentID = IPS_GetParent($InstanzID);
             break;
         case 2:
             $ParentID = IPS_GetParent(IPS_GetParent($InstanzID));
             break;
         case 3:
             $ParentID = IPS_GetParent(IPS_GetParent(IPS_GetParent($InstanzID)));
             break;
         case 4:
             $ParentID = IPS_GetParent(IPS_GetParent(IPS_GetParent(IPS_GetParent($InstanzID))));
             break;
         case 5:
             $ParentID = IPS_GetParent(IPS_GetParent(IPS_GetParent(IPS_GetParent(IPS_GetParent($InstanzID)))));
             break;
         case 6:
             $ParentID = IPS_GetParent(IPS_GetParent(IPS_GetParent(IPS_GetParent(IPS_GetParent(IPS_GetParent($InstanzID))))));
             break;
         case 7:
             $ParentID = IPS_GetParent(IPS_GetParent(IPS_GetParent(IPS_GetParent(IPS_GetParent(IPS_GetParent(IPS_GetParent($InstanzID)))))));
             break;
         case 8:
             $ParentID = IPS_GetParent(IPS_GetParent(IPS_GetParent(IPS_GetParent(IPS_GetParent(IPS_GetParent(IPS_GetParent(IPS_GetParent($InstanzID))))))));
             break;
         case 9:
             $ParentID = IPS_GetParent(IPS_GetParent(IPS_GetParent(IPS_GetParent(IPS_GetParent(IPS_GetParent(IPS_GetParent(IPS_GetParent(IPS_GetParent($InstanzID)))))))));
             break;
         default:
             $ParentID = IPS_GetParent($InstanzID);
             break;
     }
     return $ParentID;
 }
		/**
		 * @public
		 *
		 * Methode um autretende IR Events zu processen
		 *
		 * @param integer $variable ID der auslösenden Variable
		 * @param string $value Wert der Variable
		 */
		public function HandleIREvent($variable, $value) {
			$configuration = IPSMessageHandler_GetEventConfigurationIR();
			
			if ($value == '') {
				return;
			}

			$irButton = $value;
			$irInstanceId = IPS_GetParent($variable);
			$childrenIds = IPS_GetChildrenIDs($irInstanceId);
			foreach ($childrenIds as $id) {
				if ($id <> $variable) {
					$irRemoteControl = GetValue($id);
				}
			}
			IPSLogger_Com(__file__, "Received Data from IR-Variable, Control='$irRemoteControl', Command='$irButton'");
			
			$irMessage = $irRemoteControl.','.$irButton;
			if (array_key_exists($irRemoteControl.'.'.$irButton, $configuration)) {
				$params = $configuration[$irRemoteControl.'.'.$irButton];
			} elseif (array_key_exists($irRemoteControl.'.*', $configuration)) {
				$params = $configuration[$irRemoteControl.'.'.$irButton];
			} else {
				$params = '';
			}

			if ($params<>'') {
				if (count($params) < 2) {
					throw new IPSMessageHandlerException('Invalid IPSMessageHandler Configuration, Event Defintion needs 2 parameters');
				}
				$component = IPSComponent::CreateObjectByParams($params[0]);
				$module    = IPSModule::CreateObjectByParams($params[1]);

				if (function_exists('IPSMessageHandler_BeforeHandleEvent')) {
					if (IPSMessageHandler_BeforeHandleEvent($variable, $value, $component, $module)) {
						$component->HandleEvent($variable, $value, $module);
					}
				} else {
					$component->HandleEvent($variable, $value, $module);
				}
				if (function_exists('IPSMessageHandler_AfterHandleEvent')) {
					IPSMessageHandler_AfterHandleEvent($variable, $value, $component, $module);
				}
			}
}
Esempio n. 12
0
 protected function UpdateUserData()
 {
     $id = $this->GetIDForIdent("name");
     $ModulID = IPS_GetParent($id);
     $Username = $this->ReadPropertyString("Username");
     $Userpassword = $this->ReadPropertyString("Userpassword");
     $User = $this->ReadPropertyString("User");
     $this->API_AccountGetuserslist($Username, $Userpassword, $users);
     if (!$users) {
         $this->Logging("Fehler beim Holen der Username und Passwort ueberpruefen");
         $this->SetStatus(202);
         return;
     }
     $gefunden = false;
     foreach ($users as $user) {
         if ($user['shortname'] == $User) {
             $gefunden = true;
             $personid = $user['id'];
             $publickey = $user['publickey'];
             $data = $user;
         }
     }
     if (!$gefunden) {
         $this->Logging("User Shortname " . $User . " nicht gefunden.");
         $this->SetStatus(202);
         return;
     }
     $startdate = 0;
     // Startdatum
     $enddate = 0;
     // Endedatum
     $this->SetStatus(102);
     // User
     $this->DoUser($ModulID, $data);
     // Groesse
     $limit = 1;
     $meastype = 4;
     $devtype = 1;
     $this->API_MeasureGetmeas($personid, $publickey, $data, $startdate, $enddate, $meastype, $devtype, $limit);
     $this->DoGroesse($ModulID, $data);
     if ($this->ReadPropertyBoolean("BodyMeasures") == true) {
         $this->Logging("BodyMeasures Daten werden geholt.");
         // Gewicht
         $limit = 4;
         $meastype = false;
         $devtype = 1;
         $this->API_MeasureGetmeas($personid, $publickey, $data, $startdate, $enddate, $meastype, $devtype, $limit);
         $this->DoGewicht($ModulID, $data);
     }
     if ($this->ReadPropertyBoolean("BloodMeasures") == true) {
         $this->Logging("BloodMeasures Daten werden geholt.");
         // Blutdruck
         $limit = 3;
         $meastype = false;
         $devtype = 4;
         $this->API_MeasureGetmeas($personid, $publickey, $data, $startdate, $enddate, $meastype, $devtype, $limit);
         $this->DoBlutdruck($ModulID, $data);
     }
 }
Esempio n. 13
0
            IPS_ApplyChanges($SonosID);
        }
    }
    $rinconMapping[] = array("ID" => $SonosID, "RINCON" => $rincon);
    if ($SonosID === IPS_GetParent($_IPS["SELF"])) {
        $ownRincon = $rincon;
    }
}
$ipAddress = IPS_GetProperty(IPS_GetParent($_IPS["SELF"]), "IPAddress");
$timeout = IPS_GetProperty(IPS_GetParent($_IPS["SELF"]), "TimeOut");
if (!$timeout || Sys_Ping($ipAddress, $timeout) == true) {
    $sonos = new SonosAccess($ipAddress);
    $sonosGroupCoordinator = explode(":", $sonos->GetZoneGroupAttributes()["CurrentZoneGroupID"])[0];
    foreach ($rinconMapping as $key => $value) {
        if ($value["RINCON"] === $sonosGroupCoordinator) {
            $sonosGroupCoordinatorID = $value["ID"];
            break;
        }
    }
    // If groupCoordinator in Sonos = this instance --> set ID to 0 (does not belong to group)
    if ($sonosGroupCoordinatorID === IPS_GetParent($_IPS["SELF"])) {
        $sonosGroupCoordinatorID = 0;
    }
    if ($sonosGroupCoordinatorID !== $MemberOfGroup) {
        if ($groupForcing) {
            SNS_SetGroup(IPS_GetParent($_IPS["SELF"]), $MemberOfGroup);
        } else {
            SNS_SetGroup(IPS_GetParent($_IPS["SELF"]), $sonosGroupCoordinatorID);
        }
    }
}
	function Entertainment_SetRoomControlByDeviceControlId($DeviceControlId, $Value) {
		$RoomControlIds = get_RoomControlIdsByDeviceControlId($DeviceControlId);
		foreach ($RoomControlIds as $RoomControlId) {
			IPSLogger_Dbg(__file__, 'Set Control "'.IPS_GetName($RoomControlId).'" "'.$Value.'" in Room "'.IPS_GetName(IPS_GetParent($RoomControlId)).'"');
			SetValue($RoomControlId, $Value);
		}
	}
Esempio n. 15
0
		private function ReceiveCodeSpecial($code) {
			IPSLogger_Trc(__file__, 'Received SpecialCode='.$code.' from EDIP');
			switch ($code) {
				case 1: // Navigate Back
					if (GetValue($this->objectEditId)<>0) {
						SetValue($this->objectEditId,0);
					} elseif ($this->currentId <> $this->rootId) {
						$this->currentId = IPS_GetParent($this->currentId);
						SetValue(IPS_GetObjectIDbyIdent(EDIP_VAR_CURRENT, $this->instanceId), $this->currentId);
					} else {
					}
					break;
			}
		}