function PurgeLogFiles($Directory, $Extension, $ID_OutSwitch, $ID_OutDays) {
	   if (GetValue($ID_OutSwitch)) {
			IPSLogger_Dbg(c_LogId, 'Purging *.'.$Extension.' LogFiles in Directory '.$Directory);
			$Days = GetValue($ID_OutDays);
			$ReferenceDate=Date('Ymd', strtotime("-".$Days." days"));
		   if ($Directory == "") {
				$Directory = IPS_GetKernelDir().'logs\\';
		   }

			if (($handle=opendir($Directory))===false) {
			   IPSLogger_Err(c_LogId, 'Error Opening Directory '.$Directory);
				Exit;
			}

			while (($File = readdir($handle))!==false) {
		      $FileDate      = substr($File, strlen('IPSLogger_'), 8);
		      $FileExtension = substr($File, strlen('IPSLogger_')+8+1, 3);
		      if ($Extension==$FileExtension) {
					IPSLogger_Trc(c_LogId, 'Found File: '.$File.', FileDate='.$FileDate.', RefDate='.$ReferenceDate);
					if ($FileDate < $ReferenceDate) {
						IPSLogger_Inf(c_LogId, 'Delete LogFile: '.$Directory.$File);
					   unlink($Directory.$File);
					}
				}
			}
			closedir($handle);
		}
	}
Пример #2
0
	function NetPlayer_LoadFiles ($cd_path) {
	  	//Get Directory to Load
	  	SetValue(NP_ID_CDDIRECTORYPATH, $cd_path);

	  	// Get PlayList
	  	$playlist = array();
	  	NetPlayer_GetPlayList ($cd_path, $playlist);
	  	NetPlayer_CopyCoverFile ($cd_path);

	  	// Leeren der vorher bestehenden Playlist:
		$player = NetPlayer_GetIPSComponentPlayer();
		$player->ClearPlaylist();
	  	$tracklist = "";

	   // Durchlaufen des Playlist-Arrays und anhängen an die Mediaplayer-Instanz-Playlist
	   $idx = 1;
	   foreach($playlist as $data)
	   {
	      IPSLogger_Dbg(__file__, "Add File=".$data);
			$player->AddPlaylist($data);
	      $tracklist.='<tr><td><div id="rc_mp_track'.$idx.'" track="'.$idx.'" class="containerControlTrack">'.convert(basename($data))."</div></td></tr>";
	      $idx++;
	   }
	   SetValue(NP_ID_CDTRACKLISTHTML, $tracklist);
		$player->Play();

	   $Directory = basename($cd_path);
	   SetValue(NP_ID_CDINTERPRET, substr($Directory,0,strpos($Directory, "[")));
	   SetValue(NP_ID_CDALBUM, substr($Directory,strpos($Directory, "[")+1, strpos($Directory, "]")-strpos($Directory, "[")-1));
   }
Пример #3
0
	function IPSWatering_LogChange($CircleId, $Value, $ControlId) {
		$CircleName  = get_CirclyNameByID($CircleId);
		$ControlType = get_ControlType($ControlId);
		IPSLogger_Dbg(__file__,"Configuration Change for Circle '$CircleName': $ControlType=$Value");
		if ($Value) {
			IPSWatering_Log("Änderung Konfiguration ('$CircleName'): $ControlType=$Value");
		}
	}
	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_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;
	}
Пример #6
0
	function Entertainment_PowerOffUnusedRoomes() {
	   IPSLogger_Dbg(__file__, 'PowerOff unused Roomes ...');
		$RoomIds =  get_ActiveRoomIds();
		foreach ($RoomIds as $RoomId) {
		   $RoomActice = false;
		   $DeviceNames = get_DeviceNamesByRoomId($RoomId);
			foreach ($DeviceNames as $DeviceName) {
				$RoomActive = isDevicePoweredOnByDeviceName($DeviceName) or $RoomActice;
			}
			if (!$RoomActive) {
			   Entertainment_SetRoomPowerByRoomId($RoomId, false);
			}
		}
	}
Пример #7
0
	function Entertainment_SetDevicePowerByDeviceName($DeviceName, $Value, $MessageType=c_MessageType_Action) {
		IPSLogger_Trc(__file__, 'Handle Device Power for "'.$DeviceName.'" '.bool2OnOff($Value));
		$PowerId = get_ControlIdByDeviceName($DeviceName, c_Control_DevicePower, false);
		if ($PowerId!==false) {
		   if (!is_bool($Value)) { 												/*Toggle Power Value*/
      		$Value = !GetValue($PowerId);
				IPSLogger_Dbg(__file__, "Toogle Device Power for '$DeviceName' to ".bool2OnOff($Value));
   		}
			if (GetValue($PowerId) <> $Value) {
				IPSLogger_Inf(__file__, 'Set Device Power for "'.$DeviceName.'" '.bool2OnOff($Value));
				if ($Value) {
					Entertainment_SendDataByDeviceName($DeviceName, c_Control_DevicePower,
																	array(c_Property_CommPowerOn, c_Property_CommPower), $MessageType);
				} else {
					Entertainment_SendDataByDeviceName($DeviceName, c_Control_DevicePower,
																	array(c_Property_CommPowerOff, c_Property_CommPower), $MessageType);
				}
				SetValue($PowerId, $Value);
				Entertainment_Connect($DeviceName, $Value, true);
				Entertainment_SetDeviceControlByDeviceName($DeviceName, c_Control_Muting, false);
		      Entertainment_SetRoomPowerByDeviceName($DeviceName, $Value);
			}
		}
	}
Пример #8
0
	include_once "IPSLogger.inc.php";
	define ("c_LogId", "IPSLogger_SendMail");

	IPSLogger_Trc(c_LogId, 'Execute SendEmail for Messages of IPSLogger');

	$MsgList = GetValue(c_ID_EMailOutMsgList);
	if ($MsgList <> "") {
	   if (c_EMail_Address1 <> "") {
			IPSLogger_Dbg(c_LogId, 'Send ErrorMail to '.c_EMail_Address1);
			SMTP_SendMailEx(c_ID_SmtpDevice, c_EMail_Address1,
			                c_EMail_Subject, $MsgList."\n\n".c_EMail_Signature);
		} else {
			IPSLogger_Dbg(c_LogId, 'Send ErrorMail to default SMTP EMail-Address: ');
		   SMTP_SendMail(c_ID_SmtpDevice, "IP-Symcon Error(s)",  $MsgList."\n\n".c_EMail_Signature);
		}
	   if (c_EMail_Address2 <> "") {
			IPSLogger_Dbg(c_LogId, 'Send ErrorMail to '.c_EMail_Address2);
		   SMTP_SendMailEx(c_ID_SmtpDevice, c_EMail_Address2,
			                c_EMail_Subject, $MsgList."\n\n".c_EMail_Signature);
		}

	   if (c_EMail_Address3 <> "") {
			IPSLogger_Dbg(c_LogId, 'Send ErrorMail to '.c_EMail_Address3);
		   SMTP_SendMailEx(c_ID_SmtpDevice, c_EMail_Address3,
			                c_EMail_Subject, $MsgList."\n\n".c_EMail_Signature);
		}
	}
	IPS_SetScriptTimer(c_ID_ScriptSendMail, 0);		// Clear Timer
	SetValue(c_ID_EMailOutMsgList, '');             // Clear MsgList
	/** @}*/
?>
Пример #9
0
	/** Callback Methode, die beim Sonnenuntergang aufgerufen wird
	 *
	 */
	function IPSTwilight_SunriseEnd() {
		IPSLogger_Dbg(__file__, 'Call to customer specific Function "IPSTwilight_SunriseEnd"');
	}
Пример #10
0
	function CalculateCurrentValues($categoryId_Values, $scriptId_Refresh) {
		IPSLogger_Trc(__file__, 'Calculate Sunrise for current Day');

		$timestamp               = time();
		$sunrise                 = date_sunrise($timestamp, SUNFUNCS_RET_TIMESTAMP, IPSTWILIGHT_LATITUDE, IPSTWILIGHT_LONGITUDE, 90+50/60, date("O")/100);
		$sunset                  = date_sunset ($timestamp, SUNFUNCS_RET_TIMESTAMP, IPSTWILIGHT_LATITUDE, IPSTWILIGHT_LONGITUDE, 90+50/60, date("O")/100);
		$civilTwilightStart      = date_sunrise($timestamp, SUNFUNCS_RET_TIMESTAMP, IPSTWILIGHT_LATITUDE, IPSTWILIGHT_LONGITUDE, 96, date("O")/100);
		$civilTwilightEnd        = date_sunset ($timestamp, SUNFUNCS_RET_TIMESTAMP, IPSTWILIGHT_LATITUDE, IPSTWILIGHT_LONGITUDE, 96, date("O")/100);
		$nauticTwilightStart     = date_sunrise($timestamp, SUNFUNCS_RET_TIMESTAMP, IPSTWILIGHT_LATITUDE, IPSTWILIGHT_LONGITUDE, 102, date("O")/100);
		$nauticTwilightEnd       = date_sunset ($timestamp, SUNFUNCS_RET_TIMESTAMP, IPSTWILIGHT_LATITUDE, IPSTWILIGHT_LONGITUDE, 102, date("O")/100);
		$astronomicTwilightStart = date_sunrise($timestamp, SUNFUNCS_RET_TIMESTAMP, IPSTWILIGHT_LATITUDE, IPSTWILIGHT_LONGITUDE, 108, date("O")/100);
		$astronomicTwilightEnd   = date_sunset ($timestamp, SUNFUNCS_RET_TIMESTAMP, IPSTWILIGHT_LATITUDE, IPSTWILIGHT_LONGITUDE, 108, date("O")/100);

		IPSLogger_Dbg (__file__, "Calculation of Sunrise: ".date("H:i", $sunrise).'  -  '.date("H:i", $sunset));
		IPSLogger_Dbg (__file__, "Calculation of CivilTwilight: ".date("H:i", $civilTwilightStart).' - '.date("H:i", $civilTwilightEnd));
		IPSLogger_Dbg (__file__, "Calculation of NauticTwilight: ".date("H:i", $nauticTwilightStart).' - '.date("H:i", $nauticTwilightEnd));
		IPSLogger_Dbg (__file__, "Calculation of AstronomicTwilight: ".date("H:i", $astronomicTwilightStart).' - '.date("H:i", $astronomicTwilightEnd));

		SetValue( IPS_GetVariableIDByName('SunriseBegin',   $categoryId_Values), date("H:i", $sunrise));
		SetValue( IPS_GetVariableIDByName('SunriseEnd',     $categoryId_Values), date("H:i", $sunset));
		SetValue( IPS_GetVariableIDByName('SunriseDisplay', $categoryId_Values), date("H:i", $sunrise).' - '.date("H:i",$sunset));
		SetLimitedValues('SunriseLimits', 'SunriseBeginLimited', 'SunriseEndLimited', $sunrise, $sunset, $categoryId_Values, $scriptId_Refresh);

		SetValue( IPS_GetVariableIDByName('CivilBegin',   $categoryId_Values), date("H:i", $civilTwilightStart));
		SetValue( IPS_GetVariableIDByName('CivilEnd',     $categoryId_Values), date("H:i", $civilTwilightEnd));
		SetValue( IPS_GetVariableIDByName('CivilDisplay', $categoryId_Values), date("H:i", $civilTwilightStart).' - '.date("H:i",$civilTwilightEnd));
		SetLimitedValues('CivilLimits', 'CivilBeginLimited', 'CivilEndLimited', $civilTwilightStart, $civilTwilightEnd, $categoryId_Values, $scriptId_Refresh);

		SetValue( IPS_GetVariableIDByName('NauticBegin',   $categoryId_Values), date("H:i", $nauticTwilightStart));
		SetValue( IPS_GetVariableIDByName('NauticEnd',     $categoryId_Values), date("H:i", $nauticTwilightEnd));
		SetValue( IPS_GetVariableIDByName('NauticDisplay', $categoryId_Values), date("H:i", $nauticTwilightStart).' - '.date("H:i",$nauticTwilightEnd));
		SetLimitedValues('NauticLimits', 'NauticBeginLimited', 'NauticEndLimited', $nauticTwilightStart, $nauticTwilightEnd, $categoryId_Values, $scriptId_Refresh);

		SetValue( IPS_GetVariableIDByName('AstronomicBegin',   $categoryId_Values), date("H:i", $astronomicTwilightStart));
		SetValue( IPS_GetVariableIDByName('AstronomicEnd',     $categoryId_Values), date("H:i", $astronomicTwilightEnd));
		SetValue( IPS_GetVariableIDByName('AstronomicDisplay', $categoryId_Values), date("H:i", $astronomicTwilightStart).' - '.date("H:i",$astronomicTwilightEnd));
		SetLimitedValues('AstronomicLimits', 'AstronomicBeginLimited', 'AstronomicEndLimited', $astronomicTwilightStart, $astronomicTwilightEnd, $categoryId_Values, $scriptId_Refresh);
	}
Пример #11
0
		/**
		 * @public
		 *
		 * Erzeugt ein Event für eine übergebene Variable, das den IPSMessageHandler beim Auslösen
		 * aufruft.
		 *
		 * @param integer $variableId ID der auslösenden Variable
		 * @param string $eventType Type des Events (OnUpdate oder OnChange)
		 */
		public static function CreateEvent($variableId, $eventType) {
			switch ($eventType) {
				case 'OnChange':
					$triggerType = 1;
					break;
				case 'OnUpdate':
					$triggerType = 0;
					break;
				default:
					throw new IPSMessageHandlerException('Found unknown EventType '.$eventType);
			}
			$eventName = $eventType.'_'.$variableId;
			$scriptId  = IPS_GetObjectIDByIdent('IPSMessageHandler_Event', IPSUtil_ObjectIDByPath('Program.IPSLibrary.app.core.IPSMessageHandler'));
			$eventId   = @IPS_GetObjectIDByIdent($eventName, $scriptId);
			if ($eventId === false) {
				$eventId = IPS_CreateEvent(0);
				IPS_SetName($eventId, $eventName);
				IPS_SetIdent($eventId, $eventName);
				IPS_SetEventTrigger($eventId, $triggerType, $variableId);
				IPS_SetParent($eventId, $scriptId);
				IPS_SetEventActive($eventId, true);
				IPSLogger_Dbg (__file__, 'Created IPSMessageHandler Event for Variable='.$variableId);
			}
		}
	Register_PhpErrorHandler($moduleManager);

	
	// ----------------------------------------------------------------------------------------------------------------------------
	// Some Tests
	// ----------------------------------------------------------------------------------------------------------------------------
	IPSUtils_Include ("IPSLogger.inc.php", "IPSLibrary::app::core::IPSLogger");

	//  Some Test Messages
	IPSLogger_Fat(__file__, 'Test for a Fatal Error');
	IPSLogger_Err(__file__, 'Test for a Error ...');
	IPSLogger_Wrn(__file__, 'Test for a Warning');
	IPSLogger_Not(__file__, 'Test for a Notification with Priority 0 (High)');
	IPSLogger_Not(__file__, 'Test for a Notification with Priority 10 (Low)');
 	IPSLogger_Inf(__file__, 'Test for a Information Message ...');
 	IPSLogger_Dbg(__file__, 'Test for a Debug Message ...');
 	IPSLogger_Com(__file__, 'Test for a Communication Message ...');
 	IPSLogger_Trc(__file__, 'Test for a Trace Message ...');
 	IPSLogger_Tst(__file__, 'Test for a Test Message ...');

	// ------------------------------------------------------------------------------------------------
	function Register_PhpErrorHandler($moduleManager) {
		$file = IPS_GetKernelDir().'scripts\\__autoload.php';

		if (!file_exists($file)) {
			throw new Exception($file.' could NOT be found!', E_USER_ERROR);
		}
		$FileContent = file_get_contents($file);

		$pos = strpos($FileContent, 'IPSLogger_PhpErrorHandler.inc.php');
Пример #13
0
	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);
		}
	}
Пример #14
0
		private function ReceiveCodeVariable($object) {
			$variableId   = (int)$object['Id'];
			$variable     = IPS_GetVariable($variableId);
			$value        = GetValue($variableId);
			$action       = $variable['VariableCustomAction'] ;
			$type         = $variable['VariableValue']['ValueType'];
			$profile      = $variable['VariableCustomProfile'];
			$profileData  = IPS_GetVariableProfile($profile);
			$associations = $profileData['Associations'];

			if ($profile=='' or $action==0) return;

			if (GetValue($this->objectEditId)<>0) {
				SetValue($this->objectEditId, 0);
			}

			switch($type) {
				case 0: // Boolean
					IPSLogger_Dbg(__file__, 'Execute Action '.$action);
					IPS_RunScriptWaitEx($action, array( 'SENDER'=>'WebFront', 'VALUE'=>!$value, 'VARIABLE'=>$variableId, 'REMOTE_ADDR'=>'localhost'));
					break;
				case 1: // Integer
					if ($object['Value']=="") {
						SetValue($this->objectEditId, $variableId);
					} else {
						IPS_RunScriptWaitEx($action, array( 'SENDER'=>'WebFront', 'VALUE'=>(int)$object['Value'], 'VARIABLE'=>$variableId, 'REMOTE_ADDR'=>'localhost'));
					}
					break;
				case 2: // Float
					break;
				case 3: // String
					break;
				default: // Unsupported Datatype
			}
		}