function IPSWatering_Log($Msg) {
		$id_LogMessages = IPSUtil_ObjectIDByPath('Program.IPSLibrary.data.modules.IPSWatering.Log.LogMessages');
		$id_LogId       = IPSUtil_ObjectIDByPath('Program.IPSLibrary.data.modules.IPSWatering.Log.LogId');

		$Msg          = htmlentities($Msg, ENT_COMPAT, 'ISO-8859-1');
		$Msg          = str_replace("\n", "<BR>", $Msg);

		$MsgList      = GetValue($id_LogMessages);
		$TablePrefix  = '<table width="100%" style="font-family:courier; font-size:10px;">';
		$CurrentMsgId = GetValue($id_LogId)+1;
		SetValue($id_LogId, $CurrentMsgId);

	      //2010-12-03 22:09 Msg ...
		   $Out =  '<tr id="'.$CurrentMsgId.'" style="color:#FFFFFF;">';
		   $Out .=    '<td>'.date('Y-m-d H:i').'</td>';
		   $Out .=    '<td>'.$Msg.'</td>';
		   $Out .= '</tr>';


			//<table><tr><td>....</tr></table>
			if (strpos($MsgList, '</table>') === false) {
			   $MsgList = "";
			} else {
			   $StrTmp      = '<tr id="'.($CurrentMsgId-c_LogMessage_Count+1).'"';
				if (strpos($MsgList, $StrTmp)===false) {
				   $StrPos = strlen($TablePrefix);
			   } else {
					$StrPos      = strpos($MsgList, $StrTmp);
			   }
				$StrLen      = strlen($MsgList) - strlen('</table>') - $StrPos;
				$MsgList     = substr($MsgList, $StrPos, $StrLen);
			}
			SetValue($id_LogMessages, $TablePrefix.$MsgList.$Out.'</table>');
	}
		/**
		 * @public
		 *
		 * Initialisierung eines IPSComponentShutter_EIB Objektes
		 *
		 * @param integer $instanceId1 InstanceId des EIB Devices 
		 * @param integer $instanceId2 InstanceId 2 des EIB Devices (Richtungs Relais für den Fall das normale EIB Switches verwendet werden)
		 * @param boolean $reverseControl Richtungs Schalter (default=false)
		 */
		public function __construct($instanceId1, $instanceId2='', $reverseControl=false) {
			$this->instanceId1     = IPSUtil_ObjectIDByPath($instanceId1);
			if ($this->instanceId2<>'') {
				$this->instanceId2     = IPSUtil_ObjectIDByPath($instanceId2);
			}
			$this->reverseControl  = $reverseControl;
		}
		/**
		 * @public
		 *
		 * Initialisierung eines IPSComponentShutter_FS20 Objektes
		 *
		 * @param integer $instanceId InstanceId des FS20 Devices
		 */
		public function __construct($instanceId) {
			$this->instanceId = IPSUtil_ObjectIDByPath($instanceId);
			$this->isRunningId  = @IPS_GetObjectIDByIdent('isrunning', $this->instanceId);
			if($this->isRunningId===false) {
				$this->isRunningId = IPS_CreateVariable(0);
				IPS_SetParent($this->isRunningId, $this->instanceId);
				IPS_SetName($this->isRunningId, 'IsRunning');
				IPS_SetIdent($this->isRunningId, 'isrunning');
				IPS_SetInfo($this->isRunningId, "This Variable was created by Script IPSComponentShutter_FS20");
			}
		}
		/**
		 * @public
		 *
		 * Ermöglicht die Synchronisation der aktuellen Position der Beschattung
		 *
		 * @param string $position Aktuelle Position der Beschattung (Wertebereich 0-100)
		 */
		public function SyncPosition($position, IPSComponentShutter $componentToSync) {
			$componentParamsToSync = $componentToSync->GetComponentParams();
			$deviceConfig          = get_ShadowingConfiguration();
			foreach ($deviceConfig as $deviceIdent=>$deviceData) {
				$componentConfig       = IPSComponent::CreateObjectByParams($deviceData[c_Property_Component]);
				$componentParamsConfig = $componentConfig->GetComponentParams();
				if ($componentParamsConfig==$componentParamsToSync) {
					$categoryIdDevices = IPSUtil_ObjectIDByPath('Program.IPSLibrary.data.modules.IPSShadowing.Devices');
					$deviceId = IPS_GetObjectIDByIdent($deviceIdent, $categoryIdDevices);

					$device = new IPSShadowing_Device($deviceId);
					$device->MoveByEvent($position);
				}
			}
		}
		/**
		 * @public
		 *
		 * Initialisierung eines IPSComponentSwitch_ZW_Basic Objektes
		 *
		 * @param integer $instanceId InstanceId des Z-Wave Devices
		 */
		public function __construct($instanceId, $channel=0) {
			$this->instanceId = IPSUtil_ObjectIDByPath($instanceId);
			// Bei Multiinstanz fähigen Schalter gleich den Kanal merken
			$this->channel = (int)$channel;
			//Ermittlung der unterstützten Klassen
			$classes = ZW_GetNodeClasses((int)$instanceId);
			foreach ($classes as $class) {
				switch ((int)$class){
					case 32:
						$this->b_class_basic = true;
						break;
					case 37:
						$this->b_class_switch = true;
						break;
					case 96:
						$this->b_class_multi = true;
						break;
				}
			}

		}
		/**
		 * @public
		 *
		 * Initialisierung eines IPSComponentShutter_Homematic Objektes
		 *
		 * @param integer $instanceId InstanceId des Homematic Devices
		 * @param boolean $reverseControl Reverse Ansteuerung des Devices
		 */
		public function __construct($instanceId, $reverseControl=false) {
			$this->instanceId     = IPSUtil_ObjectIDByPath($instanceId);
			$this->reverseControl = $reverseControl;
		}
	/** 
	 * Schreiben von Wetterdaten anhand des Namens
	 *
	 * @param string $name Name der Variablen
	 * @param string $value Wert der geschrieben werden soll
	 */
	function IPSWeatherFAT_SetValue($name, $value) {
		$categoryId_Weather = IPSUtil_ObjectIDByPath('Program.IPSLibrary.data.modules.Weather.IPSWeatherForcastAT');
		$variableId         = IPS_GetObjectIDByIdent($name, $categoryId_Weather);
		SetValue($variableId, $value);
	}
Beispiel #8
0
	function get_CirclyIdByCircleIdent($CircleIdent, $ParentId=null) {
		if ($ParentId==null) {
			$ParentId = IPSUtil_ObjectIDByPath('Program.IPSLibrary.data.modules.IPSWatering');
		}
		$CirclyId = IPS_GetCategoryIDByName($CircleIdent, $ParentId);

		return $CirclyId;
	}
	/**
	 * Refresh der IPSModuleManager GUI
	 *
	 */
	function IPSModuleManagerGUI_Refresh() {
		$baseId  = IPSUtil_ObjectIDByPath('Program.IPSLibrary.data.modules.IPSModuleManagerGUI');
		$variableIdHTML = IPS_GetObjectIDByIdent(IPSMMG_VAR_HTML, $baseId);
		SetValue($variableIdHTML, GetValue($variableIdHTML));
	}
		/**
		 * @public
		 *
		 * Initialisierung eines IPSComponentSwitch_1WireD2408 Objektes
		 *
		 * @param integer $instanceId InstanceId des 1WireD2408 Devices
		 * @param integer $channelId Kanal des 1WireD2408 Devices
		 */
		public function __construct($instanceId, $channelId) {
			$this->instanceId = IPSUtil_ObjectIDByPath($instanceId);
			$this->channelId  = (int)$channelId;
		}
		/**
		 * @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);
			}
		}

		</script>

	</head>
	<body >
		<a href="#" onClick=trigger_button('Refresh','','')>Refresh</a> |
		<a href="#" onClick=trigger_button('Overview','','')>&Uuml;bersicht</a> |
		<a href="#" onClick=trigger_button('Logs','','')>Log File's</a> |
		<a href="#" onClick=trigger_button('Updates','','')>Update's</a> |
		<a href="#" onClick=trigger_button('NewModule','','')>Neues Modul</a>
		<BR>
		<BR>
		<?php 
IPSUtils_Include("IPSModuleManagerGUI.inc.php", "IPSLibrary::app::modules::IPSModuleManagerGUI");
$baseId = IPSUtil_ObjectIDByPath('Program.IPSLibrary.data.modules.IPSModuleManagerGUI');
$action = GetValue(IPS_GetObjectIDByIdent(IPSMMG_VAR_ACTION, $baseId));
$module = GetValue(IPS_GetObjectIDByIdent(IPSMMG_VAR_MODULE, $baseId));
$info = GetValue(IPS_GetObjectIDByIdent(IPSMMG_VAR_INFO, $baseId));
$processing = !IPSModuleManagerGUI_GetLock();
if (!$processing) {
    IPSModuleManagerGUI_ReleaseLock();
}
switch ($action) {
    case IPSMMG_ACTION_OVERVIEW:
        include 'IPSModuleManagerGUI_Overview.php';
        break;
    case IPSMMG_ACTION_UPDATES:
        include 'IPSModuleManagerGUI_Updates.php';
        break;
    case IPSMMG_ACTION_MODULE:
		/**
		 * @public
		 *
		 * Initialisierung eines IPSModuleSensor_IPSShadowing Objektes
		 *
		 * @param integer $instanceId InstanceId des Homematic Devices
		 * @param boolean $movementId Movement Command
		 */
		public function __construct($instanceId, $movementId) {
			$this->instanceId = IPSUtil_ObjectIDByPath($instanceId);
			$this->movementId = $movementId;
		}
		/**
		 * @public
		 *
		 * Die Funktion registriert ein ScriptFile anhand des Filenames und Directory Pfades in IPS
		 *
		 * @param string $file Name des Script Files
		 */
		public function UnregisterScriptByFilename($file) {
			$scriptPath = $this->GetScriptPathByFileName($file);
			$scriptName = $this->GetScriptNameByFileName($file);
			$this->logHandler->Debug("Search Script $scriptPath.$scriptName");
			$pathId = IPSUtil_ObjectIDByPath($scriptPath, true);
			$scriptId = @IPS_GetObjectIDByIdent(Get_IdentByName($scriptName), $pathId);
			if ($scriptId!==false) {
				$this->logHandler->Debug("Unegister Script $scriptName in $scriptPath (File=$file)");
			   IPS_DeleteScript($scriptId, true);
			}
		}
Beispiel #15
0
	function LimitValues($NameLimits, &$TimeStart, &$TimeEnd) {
		$categoryId_Values = IPSUtil_ObjectIDByPath('Program.IPSLibrary.data.modules.Weather.IPSTwilight.Values');
		$Limits = GetValue(IPS_GetVariableIDByName($NameLimits, $categoryId_Values));

		//                   01234567890123456789012
		// Format or Limits: xx:xx-xx:xx/yy:yy-yy:yy
		$TimeStartMin =  mktime(substr($Limits,0,2),  substr($Limits,3,2), 0, date('m',$TimeStart), date('d',$TimeStart), date('Y',$TimeStart));
		$TimeStartMax =  mktime(substr($Limits,6,2),  substr($Limits,9,2), 0, date('m',$TimeStart), date('d',$TimeStart), date('Y',$TimeStart));
		$TimeEndMin   =  mktime(substr($Limits,12,2), substr($Limits,15,2),0, date('m',$TimeEnd),   date('d',$TimeEnd),   date('Y',$TimeEnd));
		$TimeEndMax   =  mktime(substr($Limits,18,2), substr($Limits,21,2),0, date('m',$TimeEnd),   date('d',$TimeEnd),   date('Y',$TimeEnd));
		if ($TimeStart > $TimeStartMax) { $TimeStart= $TimeStartMax;}
		if ($TimeStart < $TimeStartMin) { $TimeStart= $TimeStartMin;}
		if ($TimeEnd > $TimeEndMax) { $TimeEnd= $TimeEndMax;}
		if ($TimeEnd < $TimeEndMin and date('H', $TimeEnd)=='00') { $TimeEnd= $TimeEndMax;}
		if ($TimeEnd < $TimeEndMin and $TimeEnd > $TimeStart) { $TimeEnd= $TimeEndMin;}
	}
		/**
		 * @public
		 *
		 * Initialisierung eines IPSComponentSwitch_Homematic Objektes
		 *
		 * @param integer $instanceId InstanceId des Homematic Devices
		 */
		public function __construct($instanceId) {
			$this->instanceId = IPSUtil_ObjectIDByPath($instanceId);
		}
		/**
		 * @public
		 *
		 * Initialisierung des IPSComponentAVControl_AudioMax
		 *
		 * @param integer $instanceId InstanceId des AudioMax
		 */
		public function __construct($instanceId) {
			$this->instanceId = (int)$instanceId;
			if ($this->instanceId==null) {
				$this->instanceId = IPSUtil_ObjectIDByPath('Program.IPSLibrary.data.hardware.AudioMax.AudioMax_Server');
			}
		}
	include_once "IPSWatering.inc.php";

   $CircleName         = IPS_GetName($_IPS['EVENT']);
   $categoryId_Circles = IPSUtil_ObjectIDByPath('Program.IPSLibrary.data.modules.IPSWatering.WaterCircles');
   $CircleId           = IPS_GetCategoryIDByName($CircleName, $categoryId_Circles);
   $ControlId          = get_ControlId(c_Control_Active, $CircleId);

	$WaterConfig = get_WateringConfiguration();

	// Wert von Bewässerungs Sensor ermitteln
	$SensorLimit = GetValue(get_ControlId(c_Control_Sensor, $CircleId));
	$SensorValue = false;
	if (array_key_exists(c_Property_Sensor, $WaterConfig[$CircleName])) {
		$SensorPath  = $WaterConfig[$CircleName][c_Property_Sensor];
		if ($SensorPath <> '') {
			$SensorId    = IPSUtil_ObjectIDByPath($SensorPath);
			if ($SensorId===false) {
			   IPSLogger_Wrn(__file__, "Specified Sensor '$SensorPath' could NOT be found");
			} else {
				$SensorValue = GetValue($SensorId);
			}
		}
	}

	if ($SensorValue===false and $SensorLimit>0) {
		IPSLogger_Err(__file__, "Rainfall Sensor NOT defined for Circle '$CircleName'");
		Exit;
	}

	// Bewässerung Starten
	if ($SensorLimit > 0 and $SensorValue!==false and $SensorLimit<=$SensorValue) {
				$id_IOComPort = CreateSerialPort('EDIP_'.$configData[EDIP_CONFIG_NAME], $configData[EDIP_CONFIG_COMPORT], 115200, 1, 8, 'None',0, $IgnoreIOPortInstanceError);
			}
			// Create Register Variable
			$registerIdConfig = $configData[EDIP_CONFIG_REGISTER];
			if ($registerIdConfig==null) {
			   if ($id_IOComPort==null) {
			      throw new IPSConfigHandlerException('Register Variable and ComPort not defined !!!');
			   }
				$registerIdConfig = CreateRegisterVariable($configData[EDIP_CONFIG_NAME].'_Register', $CategoryIdHW, $id_ScriptReceive, $id_IOComPort);
			}
			// Create Root Category
			if (!is_numeric($configData[EDIP_CONFIG_ROOT])) {
			   CreateCategoryPath($configData[EDIP_CONFIG_ROOT]);
			}
			
			SetValue($id_Register, IPSUtil_ObjectIDByPath($registerIdConfig));
			SetValue($id_Root,     IPSUtil_ObjectIDByPath($configData[EDIP_CONFIG_ROOT]));
			SetValue($id_Current,  IPSUtil_ObjectIDByPath($configData[EDIP_CONFIG_ROOT]));
			SetValue($id_value,    0);
		} else {
		   echo "Register/Root Ids NOT assigned... \n";
		}
	}

	CreateTimer_CyclicBySeconds ('Timer', $id_ScriptTimer, EDIP_CONFIG_REFRESHTIMER);

	SetVariableConstant ("EDIP_ID_PROGRAM",    $CategoryIdData,   'IPSEDIP_IDs.inc.php', 'IPSLibrary::app::hardware::IPSEDIP');
	SetVariableConstant ("EDIP_ID_EVENTSCRIPT",$id_ScriptEvent,   'IPSEDIP_IDs.inc.php', 'IPSLibrary::app::hardware::IPSEDIP');

	/** @}*/
?>