コード例 #1
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);
}
コード例 #2
0
ファイル: module.php プロジェクト: Nall-chan/IPSVoiceRSS
 public function GenerateMediaObjectEx(string $Text, int $MediaID, string $Format, string $Codec, string $Language)
 {
     if ($MediaID == 0) {
         $MediaID = @IPS_GetObjectIDByIdent('Voice', $this->InstanceID);
     }
     if ($MediaID > 0) {
         if (IPS_MediaExists($MediaID) === false) {
             trigger_error('MediaObject not exists.', E_USER_NOTICE);
         }
         return false;
         if (IPS_GetMedia($MediaID)['MediaType'] != 2) {
             trigger_error('Wrong MediaType', E_USER_NOTICE);
         }
         return false;
     }
     $raw = $this->LoadTTSFile($Text, '', 0, $Format, $Codec, $Language, true);
     if ($raw === false) {
         return false;
     }
     if ($MediaID === false) {
         $MediaID = IPS_CreateMedia(2);
         IPS_SetMediaCached($MediaID, true);
         IPS_SetName($MediaID, 'Voice');
         IPS_SetParent($MediaID, $this->InstanceID);
         IPS_SetIdent($MediaID, 'Voice');
     }
     $Filename = 'media' . DIRECTORY_SEPARATOR . $MediaID . '.' . strtolower($Codec);
     IPS_SetMediaFile($MediaID, $Filename, False);
     IPS_SetMediaContent($MediaID, base64_encode($raw));
     IPS_SetInfo($MediaID, $Text);
     return $MediaID;
 }
コード例 #3
0
ファイル: module.php プロジェクト: Vansdan/SymconHUE
  protected function RegisterTimer($ident, $interval, $script) {
    $id = @IPS_GetObjectIDByIdent($ident, $this->InstanceID);

    if ($id && IPS_GetEvent($id)['EventType'] <> 1) {
      IPS_DeleteEvent($id);
      $id = 0;
    }

    if (!$id) {
      $id = IPS_CreateEvent(1);
      IPS_SetParent($id, $this->InstanceID);
      IPS_SetIdent($id, $ident);
    }

    IPS_SetName($id, $ident);
    IPS_SetHidden($id, true);
    IPS_SetEventScript($id, "\$id = \$_IPS['TARGET'];\n$script;");

    if (!IPS_EventExists($id)) throw new Exception("Ident with name $ident is used for wrong object type");

    if (!($interval > 0)) {
      IPS_SetEventCyclic($id, 0, 0, 0, 0, 1, 1);
      IPS_SetEventActive($id, false);
    } else {
      IPS_SetEventCyclic($id, 0, 0, 0, 0, 1, $interval);
      IPS_SetEventActive($id, true);
    }
  }
コード例 #4
0
		/**
		 * @public
		 *
		 * Ermöglicht das Verarbeiten eines Taster Signals
		 *
		 */
		public function ExecuteButton () {
			$device = new IPSShadowing_Device($this->instanceId);
			$movementId = GetValue(IPS_GetObjectIDByIdent(c_Control_Movement, $this->instanceId));
			if ($movementId==c_MovementId_MovingIn or $movementId==c_MovementId_MovingOut or $movementId==c_MovementId_Up or $movementId==c_MovementId_Down) {
				$device->MoveByControl(c_MovementId_Stop);
			} else {
				$device->MoveByControl($this->movementId);
			}
		}
コード例 #5
0
ファイル: module.php プロジェクト: Seb0815/ips4Windows
 private function CreateVariableByIdent($id, $ident, $name, $type, $profile = "")
 {
     $vid = @IPS_GetObjectIDByIdent($ident, $id);
     if ($vid === false) {
         $vid = IPS_CreateVariable($type);
         IPS_SetParent($vid, $id);
         IPS_SetName($vid, $name);
         IPS_SetIdent($vid, $ident);
         if ($profile != "") {
             IPS_SetVariableCustomProfile($vid, $profile);
         }
     }
     return $vid;
 }
コード例 #6
0
		/**
		 * @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);
				}
			}
		}
コード例 #7
0
ファイル: IPSUtils.inc.php プロジェクト: KOS-CH/IPSLibrary
	/** ObjektId aus Pfad ermittlen
	 *
	 * Der Befehl ermittelt aus einer Pfadangabe (zB. "IPSLibrary.IPSUtils.IPSUtils.inc.php") die ID des Scriptes
	 *
	 * @param string $path Pfadangabe
	 * @param string $returnFalse wenn true, retouniert die Funktion false wenn das übergebene Object nicht gefunden wurde
	 * @return integer ID des Objektes
	 *
	 */
	function IPSUtil_ObjectIDByPath($path, $returnFalse=false) {
		$categoryList = explode('.',$path);
		if (count($categoryList)==1 and is_numeric($categoryList[0])) {
		   return (int)$categoryList[0];
		}

		$objId    = 0;
		$parentId = 0;
		foreach ($categoryList as $idx=>$category) {
			$objId = @IPS_GetObjectIDByIdent($category, $parentId);
			if ($objId===false) {
				$objId=@IPS_GetObjectIDByName($category, $parentId);
			}
			if ($objId===false) {
				if ($returnFalse) {
					return false;
				} else {
					throw new IPSUtilException('"'.$category.'" could NOT be found while searching for Path '.$path);
				}
			}
			$parentId = $objId;
		}
		return $objId;
	}
コード例 #8
0
		/**
		 * @public
		 *
		 * Liefert aktuellen Zustand
		 *
		 * @return boolean aktueller Schaltzustand
		 */
		public function GetState() {
			if ($this->b_class_multi and ($this->channel > 0))
				$id = @IPS_GetObjectIDByIdent("MultiInstance".$this->channel."Variable",(int)$this->instanceId);
			else
				$id = @IPS_GetObjectIDByIdent("DataVariableBoolean",(int)$this->instanceId);
		   
		   if ($id > 0)
				return GetValue($id);
			else
			   return false;
		}
コード例 #9
0
 /**
  * Create a new EneryDev instance and set its properties
  * @param array $data parsed record
  * @param String $caps String semicolon seperated capabilities of this device
  * @return int new Instance ID
  */
 private function CreateENDevice($data, $caps)
 {
     $instID = 0;
     $class = $data['Class'];
     $Device = $data['Id'];
     $typ = $data['Typ'];
     $ModuleID = $this->module_interfaces['EnergyDev'];
     if (IPS_ModuleExists($ModuleID)) {
         //return $result;
         $this->debug(__FUNCTION__, 'Device:' . $Device);
         $instID = IPS_CreateInstance($ModuleID);
         if ($instID > 0) {
             IPS_SetProperty($instID, 'DeviceID', $Device);
             IPS_SetProperty($instID, 'Class', $class);
             IPS_SetProperty($instID, 'Typ', $typ);
             IPS_SetProperty($instID, 'CapList', $caps);
             IPS_SetProperty($instID, 'Debug', $this->isDebug());
             //follow debug settings from splitter
             IPS_SetName($instID, "{$typ} Device " . $Device);
             $ident = $class . "_" . $typ . "_" . $Device;
             $ident = preg_replace("/\\W/", "_", $ident);
             //nicht-Buchstaben/zahlen entfernen
             IPS_SetIdent($instID, $ident);
             IPS_ConnectInstance($instID, $this->InstanceID);
             IPS_ApplyChanges($instID);
             //set factor
             if (isset($data['CounterFactor'])) {
                 IPS_SetProperty($instID, 'CounterFactor', floatval($data['CounterFactor']));
                 $this->debug(__FUNCTION__, 'Set Counterfactor=' . $data['CounterFactor']);
             }
             //set category
             $cat = $this->GetCategory();
             $pcat = $this->GetParentCategory();
             $ident = preg_replace("/\\W/", "_", $cat);
             //fix naming
             $catid = @IPS_GetObjectIDByIdent($ident, $pcat);
             if ($catid == 0) {
                 $catid = IPS_CreateCategory();
                 IPS_SetName($catid, $cat);
                 if (IPS_SetIdent($catid, $ident) && IPS_SetParent($catid, $pcat)) {
                     IPS_LogMessage($class, "Category {$cat} Ident {$ident} ({$catid}) created");
                 } else {
                     IPS_LogMessage($class, "Category {$cat} Ident {$ident} ({$catid}) FAILED");
                 }
             }
             $this->debug(__FUNCTION__, "Category:{$catid}");
             if (!IPS_SetParent($instID, $catid)) {
                 $this->debug(__FUNCTION__, "SetParent Instance {$instID} to Cat {$catid} failed, Dropping instance");
                 IPS_DeleteInstance($instID);
                 $instID = 0;
             } else {
                 $this->debug(__FUNCTION__, 'New ID:' . $instID);
             }
             //parent
             if (IPS_HasChanges($instID)) {
                 IPS_ApplyChanges($instID);
             }
         } else {
             $this->debug(__FUNCTION__, 'Instance  is not created!');
         }
         //if instID
     }
     //module exists
     return $instID;
 }
コード例 #10
0
 protected function UnregisterTimer($Name)
 {
     $id = @IPS_GetObjectIDByIdent($Name, $this->InstanceID);
     if ($id > 0) {
         if (!IPS_EventExists($id)) {
             throw new Exception('Timer not present', E_USER_NOTICE);
         }
         IPS_DeleteEvent($id);
     }
 }
コード例 #11
0
		private function HandleError($result) {
			if ($result==false) {
				$errorMessage = GetValue(IPS_GetObjectIDByIdent(AM_VAR_LASTERROR, $this->instanceId));
				trigger_error($errorMessage);
			}
		}
コード例 #12
0
 protected function RegisterEvent($Name, $Source, $Script)
 {
     $id = @IPS_GetObjectIDByIdent($Name, $this->InstanceID);
     if ($id === false) {
         $id = 0;
     }
     if ($id > 0) {
         if (!IPS_EventExists($id)) {
             throw new Exception("Ident with name " . $Name . " is used for wrong object type", E_USER_WARNING);
         }
         if (IPS_GetEvent($id)['EventType'] != 0) {
             IPS_DeleteEvent($id);
             $id = 0;
         }
     }
     if ($id == 0) {
         $id = IPS_CreateEvent(0);
         IPS_SetParent($id, $this->InstanceID);
         IPS_SetIdent($id, $Name);
     }
     IPS_SetName($id, $Name);
     IPS_SetHidden($id, true);
     IPS_SetEventScript($id, $Script);
     if ($Source > 0) {
         IPS_SetEventTrigger($id, 0, $Source);
         if (!IPS_GetEvent($id)['EventActive']) {
             IPS_SetEventActive($id, true);
         }
     } else {
         IPS_SetEventTrigger($id, 0, 0);
         if (IPS_GetEvent($id)['EventActive']) {
             IPS_SetEventActive($id, false);
         }
     }
 }
コード例 #13
0
	</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:
        include 'IPSModuleManagerGUI_Module.php';
        break;
    case IPSMMG_ACTION_WIZARD:
コード例 #14
0
ファイル: module.php プロジェクト: mcbeyel/IPSLocative
 private function CreateInstanceByIdent($id, $ident, $name, $moduleid = "{485D0419-BE97-4548-AA9C-C083EB82E61E}")
 {
     $iid = @IPS_GetObjectIDByIdent($ident, $id);
     if ($iid === false) {
         $iid = IPS_CreateInstance($moduleid);
         IPS_SetParent($iid, $id);
         IPS_SetName($iid, $name);
         IPS_SetIdent($iid, $ident);
     }
     return $iid;
 }
コード例 #15
0
ファイル: module.php プロジェクト: Nall-chan/IPSSqueezeBox
 protected function SetTimerInterval($Name, $Interval)
 {
     $id = @IPS_GetObjectIDByIdent($Name, $this->InstanceID);
     if ($id === false) {
         throw new Exception('Timer not present');
     }
     if (!IPS_EventExists($id)) {
         throw new Exception('Timer not present');
     }
     $Event = IPS_GetEvent($id);
     if ($Interval < 1) {
         if ($Event['EventActive']) {
             IPS_SetEventActive($id, false);
         }
     } else {
         if ($Event['CyclicTimeValue'] != $Interval) {
             IPS_SetEventCyclic($id, 0, 0, 0, 0, 1, $Interval);
         }
         if (!$Event['EventActive']) {
             IPS_SetEventActive($id, true);
         }
     }
 }
コード例 #16
0
 /**
  * Create a new EnergyDev instance and set its properties
  * @param array $data parsed record
  * @param String $caps String semicolon seperated capabilities of this device
  * @return int new Instance ID
  */
 private function CreateEnergyDevice($data, $caps)
 {
     $instID = 0;
     $Device = $data['Id'];
     $typ = $data['Typ'];
     $name = $data['Name'];
     $branch = $data['Branch'];
     unset($data['Branch']);
     if (!$name) {
         $name = "XS1 {$branch} {$Device}";
     }
     $class = __CLASS__ . "-EN";
     //$host = $this->GetHost();
     $ModuleID = $this->module_interfaces['EnergyDev'];
     if (IPS_ModuleExists($ModuleID)) {
         //return $result;
         $this->debug(__FUNCTION__, 'Device:' . $Device);
         $instID = IPS_CreateInstance($ModuleID);
         if ($instID > 0) {
             IPS_SetProperty($instID, 'DeviceID', $Device);
             IPS_SetProperty($instID, 'Class', $class);
             IPS_SetProperty($instID, 'Typ', $typ);
             IPS_SetProperty($instID, 'CapList', $caps);
             IPS_SetProperty($instID, 'Debug', $this->isDebug());
             //follow debug settings from splitter
             IPS_SetName($instID, "XS1 {$branch} '{$name}'");
             $ident = $class . "_" . $branch . "_{$Device}";
             $ident = preg_replace("/\\W/", "_", $ident);
             //nicht-Buchstaben/zahlen entfernen
             IPS_SetIdent($instID, $ident);
             IPS_ConnectInstance($instID, $this->InstanceID);
             IPS_ApplyChanges($instID);
             //set category
             $cat = $this->GetCategory() . " {$branch}" . "s";
             $pcat = $this->GetParentCategory();
             $ident = preg_replace("/\\W/", "_", $cat);
             //fix naming
             $catid = @IPS_GetObjectIDByIdent($ident, $pcat);
             if ($catid == 0) {
                 $catid = IPS_CreateCategory();
                 IPS_SetName($catid, $cat);
                 if (IPS_SetIdent($catid, $ident) && IPS_SetParent($catid, $pcat)) {
                     IPS_LogMessage($class, "Category {$cat} Ident {$ident} ({$catid}) created");
                 } else {
                     IPS_LogMessage($class, "Category {$cat} Ident {$ident} ({$catid}) FAILED");
                 }
             }
             $this->debug(__FUNCTION__, "Category:{$catid}");
             if (!IPS_SetParent($instID, $catid)) {
                 $this->debug(__FUNCTION__, "SetParent Instance {$instID} to Cat {$catid} failed, Dropping instance");
                 IPS_DeleteInstance($instID);
                 $instID = 0;
             } else {
                 $this->debug(__FUNCTION__, 'New ID:' . $instID);
             }
             //if instID
         } else {
             $this->debug(__FUNCTION__, 'Instance  is not created!');
         }
     }
     //module exists
     return $instID;
 }
コード例 #17
0
	/** 
	 * 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);
	}
コード例 #18
0
ファイル: module.php プロジェクト: Vansdan/SymconHUE
  public function SetValue($key, $value) {
    $stateId = IPS_GetObjectIDByIdent('STATE', $this->InstanceID);
    $cmId = IPS_GetObjectIDByIdent('COLOR_MODE', $this->InstanceID);
    $ctId = @IPS_GetObjectIDByIdent('COLOR_TEMPERATURE', $this->InstanceID);
    $briId = IPS_GetObjectIDByIdent('BRIGHTNESS', $this->InstanceID);
    $satId = @IPS_GetObjectIDByIdent('SATURATION', $this->InstanceID);
    $hueId = @IPS_GetObjectIDByIdent('HUE', $this->InstanceID);
    $colorId = @IPS_GetObjectIDByIdent('COLOR', $this->InstanceID);

    $stateValue = GetValueBoolean($stateId);
    $cmValue = $cmId ? GetValueInteger($cmId) : 0;
    $ctValue = $ctId ? (500 - round(347 * GetValueInteger($ctId) / 100)) : 0;
    $briValue = round(GetValueInteger($briId)*2.54);
    $satValue = $satId ? round(GetValueInteger($satId)*2.54) : 0;
    $hueValue = $hueId ? GetValueInteger($hueId) : 0;
    $colorValue = $colorId ? GetValueInteger($colorId) : 0;

    switch ($key) {
      case 'STATE':
        $stateNewValue = $value;
        break;
      case 'COLOR':
        $colorNewValue = $value;
        $stateNewValue = true;
        $hex = str_pad(dechex($value), 6, 0, STR_PAD_LEFT);
        $hsv = $this->HEX2HSV($hex);
        SetValueInteger($colorId, $value);
        $hueNewValue = $hsv['h'];
        $briNewValue = $hsv['v'];
        $satNewValue = $hsv['s'];
        $cmNewValue = 0;
        break;
      case 'BRIGHTNESS':
        $briNewValue = $value;
        $stateNewValue = true;
        if (IPS_GetProperty($this->InstanceID, 'LightFeatures') != 3) {
          if ($cmValue == '0') {
            $newHex = $this->HSV2HEX($hueValue, $satValue, $briNewValue);
            SetValueInteger($colorId, hexdec($newHex));
            $hueNewValue = $hueValue;
            $satNewValue = $satValue;
          } else {
            $ctNewValue = $ctValue;
          }
        }
        break;
      case 'SATURATION':
        $cmNewValue = 0;
        $satNewValue = $value;
        $stateNewValue = true;
        $newHex = $this->HSV2HEX($hueValue, $satNewValue, $briValue);
        SetValueInteger($colorId, hexdec($newHex));
        $hueNewValue = $hueValue;
        $briNewValue = $briValue;
        break;
      case 'COLOR_TEMPERATURE':
        $cmNewValue = 1;
        $ctNewValue = $value;
        $briNewValue = $briValue;
        break;
      case 'COLOR_MODE':
        $cmNewValue = $value;
        $stateNewValue = true;
        if ($cmNewValue == 1) {
          $ctNewValue = $ctValue;
          IPS_SetHidden($colorId, true);
          IPS_SetHidden($ctId, false);
          IPS_SetHidden($satId, true);
        } else {
          $hueNewValue = $hueValue;
          $satNewValue = $satValue;
          $briNewValue = $briValue;
          $newHex = $this->HSV2HEX($hueValue, $satValue, $briValue);
          SetValueInteger($colorId, hexdec($newHex));
          IPS_SetHidden($colorId, false);
          IPS_SetHidden($ctId, true);
          IPS_SetHidden($satId, false);
        }
        break;
    }

    $changes = array();
    if (isset($stateNewValue)) {
      SetValueBoolean($stateId, $stateNewValue);
      $changes['on'] = $stateNewValue;
    }
    if (isset($hueNewValue)) {
      SetValueInteger($hueId, $hueNewValue);
      $changes['hue'] = $hueNewValue;
    }
    if (isset($satNewValue)) {
      SetValueInteger($satId, round($satNewValue * 100 / 254));
      $changes['sat'] = $satNewValue;
    }
    if (isset($briNewValue)) {
      SetValueInteger($briId, round($briNewValue * 100 / 254));
      $changes['bri'] = $briNewValue;
    }
    if (isset($ctNewValue)) {
      SetValueInteger($ctId, 100 - round(($ctNewValue - 153) * 100 / 347));
      $changes['ct'] = $ctNewValue;
    }
    if (isset($cmNewValue)) {
      SetValueInteger($cmId, $cmNewValue);
      $changes['colormode'] = $cmNewValue == 1 ? 'ct' : 'hs';
    }

    $lightId = $this->ReadPropertyInteger("LightId");
    return HUE_Request($this->GetBridge(), "/lights/$lightId/state", $changes);
  }
コード例 #19
0
		/**
		 * @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);
			}
		}
コード例 #20
0
ファイル: module.php プロジェクト: geelife/IPS_NZBGet
 public function ImportVersionInfo()
 {
     if (!$this->VariableExists("Version")) {
         $createdVariableId = $this->RegisterVariableString($this->ReadPropertyString("NzbIdentPrefix") . "Version", "Version");
     }
     SetValueString(IPS_GetObjectIDByIdent($this->ReadPropertyString("NzbIdentPrefix") . "Version", $this->InstanceID), $this->GetVersion());
 }
コード例 #21
0
ファイル: module.php プロジェクト: BayaroX/BY_HostMonitor
 protected function SetTimerByIdent_InSekunden($ident, $Sekunden)
 {
     $eid = @IPS_GetObjectIDByIdent($ident, $this->InstanceID);
     if ($eid === false) {
         $eid = IPS_CreateEvent(1);
         IPS_SetParent($eid, $this->InstanceID);
         IPS_SetName($eid, $ident);
         IPS_SetIdent($eid, $ident);
         IPS_SetEventScript($eid, 'HMON_Benachrichtigung($_IPS[\'TARGET\'], false, true);');
         IPS_SetInfo($eid, "this timer was created by script #" . $_IPS['SELF']);
     }
     if ($Sekunden === false) {
         IPS_SetEventActive($eid, false);
         return $eid;
     } else {
         IPS_SetEventCyclicTimeFrom($eid, intval(date("H", time() + $Sekunden)), intval(date("i", time() + $Sekunden)), intval(date("s", time() + $Sekunden)));
         IPS_SetEventActive($eid, true);
         return $eid;
     }
 }
コード例 #22
0
		/**
		 * @public
		 *
		 * Stop
		 */
		public function Stop() {
			if(GetValue($this->isRunningId)) {
				$value = GetValue(IPS_GetObjectIDByIdent("StatusVariable", $this->instanceId));
				FS20_SwitchMode($this->instanceId, $value);
				SetValue($this->isRunningId, false);
			}
		}
コード例 #23
0
	/**
	 * 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));
	}
コード例 #24
0
 /**
  * Create a new WSDev instance and set its properties
  * @param array $data parsed record
  * @param String $caps String semicolon seperated capabilities of this device
  * @return int new Instance ID
  */
 private function CreateWSDevice($data, $caps)
 {
     $instID = 0;
     $Device = $data['Id'];
     $typ = $data['Typ'];
     $ModuleID = $this->module_interfaces['WSDEV'];
     if (IPS_ModuleExists($ModuleID)) {
         //return $result;
         $this->debug(__FUNCTION__, "Create Device {$Device},Type {$typ}");
         $instID = IPS_CreateInstance($ModuleID);
         if ($instID > 0) {
             IPS_ConnectInstance($instID, $this->InstanceID);
             //Parents are ourself!
             IPS_SetProperty($instID, 'DeviceID', $Device);
             IPS_SetProperty($instID, 'Class', __CLASS__);
             IPS_SetProperty($instID, 'Typ', $typ);
             IPS_SetProperty($instID, 'CapList', $caps);
             IPS_SetProperty($instID, 'Debug', $this->isDebug());
             //follow debug settings from splitter
             switch ($Device) {
                 case 0:
                 case $Device < 8:
                     IPS_SetName($instID, 'Sensor ' . $Device);
                     break;
                 case 8:
                     IPS_SetName($instID, 'KombiSensor');
                     break;
                 case 9:
                     IPS_SetName($instID, 'InnenSensor');
                     break;
                 default:
                     IPS_SetName($instID, "unknown Sensor('" . strToHex($Device) . "')");
                     break;
             }
             //switch
             $ident = __CLASS__ . "_WS_{$Device}";
             $ident = preg_replace("/\\W/", "_", $ident);
             //nicht-Buchstaben/zahlen entfernen
             IPS_SetIdent($instID, $ident);
             IPS_ApplyChanges($instID);
             $cat = $this->GetCategory();
             $pcat = $this->GetParentCategory();
             $ident = preg_replace("/\\W/", "_", $cat);
             //nicht-Buchstaben/zahlen entfernen
             $catid = @IPS_GetObjectIDByIdent($ident, $pcat);
             if ($catid == 0) {
                 $catid = IPS_CreateCategory();
                 IPS_SetName($catid, $cat);
                 if (IPS_SetIdent($catid, $ident) && IPS_SetParent($catid, $pcat)) {
                     IPS_LogMessage(__CLASS__, "Category {$cat} Ident {$ident} ({$catid}) created");
                 } else {
                     IPS_LogMessage(__CLASS__, "Category {$cat} Ident {$ident} ({$catid}) FAILED");
                 }
             }
             $this->debug(__FUNCTION__, "Category:{$catid}");
             if (!IPS_SetParent($instID, $catid)) {
                 $this->debug(__FUNCTION__, "SetParent to Cat {$catid} failed");
             }
             $this->debug(__FUNCTION__, 'New ID:' . $instID);
             //if instID
             //set willi profile for forecast
             $vid = @IPS_GetObjectIDByIdent('Forecast', $instID);
             if ($vid > 0) {
                 IPS_SetVariableCustomProfile($vid, "WS300_Willi");
             }
         } else {
             $this->debug(__FUNCTION__, 'Instance  is not created!');
         }
     }
     //module exists
     return $instID;
 }
コード例 #25
0
 /**
  * Create a new EnergyDev instance and set its properties
  * @param array $data parsed record
  * @param String $caps String semicolon seperated capabilities of this device
  * @return int new Instance ID
  */
 private function CreateENDevice($data, $caps)
 {
     $instID = 0;
     $Device = $data['Id'];
     $typ = $data['Typ'];
     $ModuleID = $this->module_interfaces['EnergyDev'];
     if (IPS_ModuleExists($ModuleID)) {
         //return $result;
         $this->debug(__FUNCTION__, "Create Device {$Device},Type {$typ}");
         $instID = IPS_CreateInstance($ModuleID);
         if ($instID > 0) {
             IPS_ConnectInstance($instID, $this->InstanceID);
             //Parents are ourself!
             IPS_SetProperty($instID, 'DeviceID', $Device);
             IPS_SetProperty($instID, 'Class', __CLASS__);
             IPS_SetProperty($instID, 'Typ', $typ);
             IPS_SetProperty($instID, 'CapList', $caps);
             IPS_SetProperty($instID, 'Debug', $this->isDebug());
             //follow debug settings from splitter
             IPS_SetName($instID, "{$typ} ID {$Device}");
             $ident = __CLASS__ . "_EN_{$Device}";
             $ident = preg_replace("/\\W/", "_", $ident);
             //nicht-Buchstaben/zahlen entfernen
             IPS_SetIdent($instID, $ident);
             IPS_ApplyChanges($instID);
             $cat = $this->GetCategory();
             $pcat = $this->GetParentCategory();
             $ident = preg_replace("/\\W/", "_", $cat);
             //nicht-Buchstaben/zahlen entfernen
             $catid = @IPS_GetObjectIDByIdent($ident, $pcat);
             if ($catid == 0) {
                 $catid = IPS_CreateCategory();
                 IPS_SetName($catid, $cat);
                 if (IPS_SetIdent($catid, $ident) && IPS_SetParent($catid, $pcat)) {
                     IPS_LogMessage(__CLASS__, "Category {$cat} Ident {$ident} ({$catid}) created");
                 } else {
                     IPS_LogMessage(__CLASS__, "Category {$cat} Ident {$ident} ({$catid}) FAILED");
                 }
             }
             $this->debug(__FUNCTION__, "Category:{$catid}");
             if (!IPS_SetParent($instID, $catid)) {
                 $this->debug(__FUNCTION__, "SetParent to Cat {$catid} failed");
             }
             $this->debug(__FUNCTION__, 'New ID:' . $instID);
             //if instID
         } else {
             $this->debug(__FUNCTION__, 'Instance  is not created!');
         }
     }
     //module exists
     return $instID;
 }
コード例 #26
0
 /**
  * ModBusMaster_WriteCoil
  * @param boolean $Value
  * @return boolean
  */
 public function WriteCoil($Value)
 {
     if ($this->ReadPropertyBoolean("ReadOnly")) {
         trigger_error("Address is marked as read-only!", E_USER_WARNING);
         return;
     }
     if ($this->ReadPropertyInteger("DataType") === 0) {
         $resultat = $this->SendDataToParent(json_encode(array("DataID" => "{A3419A88-C83B-49D7-8706-D3AFD596DFBB}", "FC" => "5", "Address" => $this->ReadPropertyInteger("Address"), "Data" => $Value)));
         if ($this->ReadPropertyInteger("SwitchDuration") > 0 and $Value) {
             $eid = @IPS_GetObjectIDByIdent("SwitchDuration", $this->InstanceID);
             if ($eid === false) {
                 $eid = 0;
             } else {
                 if (IPS_GetEvent($eid)['EventType'] != 1) {
                     IPS_DeleteEvent($eid);
                     $eid = 0;
                 }
             }
             if ($eid == 0) {
                 $eid = IPS_CreateEvent(1);
                 IPS_SetParent($eid, $this->InstanceID);
                 IPS_SetIdent($eid, "SwitchDuration");
                 IPS_SetName($eid, "SwitchDuration");
                 IPS_SetHidden($eid, true);
                 IPS_SetEventScript($eid, "ModBusMaster_WriteCoil(\$_IPS['TARGET'], false);IPS_SetEventActive(\$_IPS['EVENT'],false);");
             }
             IPS_SetEventCyclicTimeFrom($eid, date("H"), date("i"), date("s"));
             IPS_SetEventCyclic($eid, 0, 0, 0, 0, 1, $this->ReadPropertyInteger("SwitchDuration"));
             IPS_SetEventActive($eid, true);
         }
         return $resultat;
     } else {
         trigger_error("Invalid DataType!", E_USER_WARNING);
     }
 }
コード例 #27
0
function GetOrCreateScript($parent, $ident)
{
    $ObjId = @IPS_GetObjectIDByIdent($ident, $parent);
    if ($ObjId === false) {
        $ObjId = IPS_CreateScript(0);
        IPS_SetParent($ObjId, $parent);
        IPS_SetIdent($ObjId, $ident);
        IPS_SetName($ObjId, $ident);
        IPS_SetScriptContent($ObjId, ScriptContent($ident));
    }
    return $ObjId;
}
コード例 #28
0
ファイル: module.php プロジェクト: Charykun/SymconOneWireLan
 /**
  * RegisterVariableByParent
  * @param integer $ParentID
  * @param string $Ident
  * @param string $Name
  * @param integer $Type
  * @param string $Profile
  * @param integer $Position
  * @return integer
  */
 private function RegisterVariableByParent($ParentID, $Ident, $Name, $Type, $Profile = "", $Position = 0)
 {
     if ($Profile !== "") {
         //prefer system profiles
         if (IPS_VariableProfileExists("~" . $Profile)) {
             $Profile = "~" . $Profile;
         }
         if (!IPS_VariableProfileExists($Profile)) {
             throw new Exception("Profile with name " . $Profile . " does not exist");
         }
     }
     //search for already available variables with proper ident
     $vid = @IPS_GetObjectIDByIdent($Ident, $ParentID);
     //properly update variableID
     if ($vid === false) {
         $vid = 0;
     }
     //we have a variable with the proper ident. check if it fits
     if ($vid > 0) {
         //check if we really have a variable
         if (!IPS_VariableExists($vid)) {
             throw new Exception("Ident with name " . $Ident . " is used for wrong object type");
         }
         //bail out
         //check for type mismatch
         if (IPS_GetVariable($vid)["VariableType"] != $Type) {
             //mismatch detected. delete this one. we will create a new below
             IPS_DeleteVariable($vid);
             //this will ensure, that a new one is created
             $vid = 0;
         }
     }
     //we need to create one
     if ($vid === 0) {
         $vid = IPS_CreateVariable($Type);
         //configure it
         IPS_SetParent($vid, $ParentID);
         IPS_SetIdent($vid, $Ident);
         IPS_SetName($vid, $Name);
         IPS_SetPosition($vid, $Position);
         //IPS_SetReadOnly($vid, true);
     }
     //update variable profile. profiles may be changed in module development.
     //this update does not affect any custom profile choices
     IPS_SetVariableCustomProfile($vid, $Profile);
     return $vid;
 }
コード例 #29
0
	 *
	 * Timer Script
	 *
	 * @file          IPSEDIP_Timer.ips.php
	 * @author        Andreas Brauneis
	 * @version
	 * Version 2.50.1, 31.01.2012<br/>
	 *
	 * Dieses Script wird vom internen Timer aufgerufen, um die visualisierten Daten wieder neu
	 * anzuzeigen.
	 * Voraussetzung für den Refresh mit Timer ist, dass der Konfigurations Parameter EDIP_CONFIG_REFRESHMETHOD
	 * auf dem Wert EDIP_REFRESHMETHOD_TIMER steht.
	 *
	 */

	include_once "IPSEDIP.class.php";

	foreach (IPSEDIP_GetConfiguration() as $configId=>$configData) {
		if ($configData[EDIP_CONFIG_REFRESHMETHOD]==EDIP_REFRESHMETHOD_TIMER or
			$configData[EDIP_CONFIG_REFRESHMETHOD]==EDIP_REFRESHMETHOD_BOTH) {
			$instanceClass = $configData[EDIP_CONFIG_CLASSNAME];
			$instanceId    = IPS_GetObjectIDByIdent($configId, EDIP_ID_PROGRAM);

			include_once $instanceClass.'.class.php';
			$edip = new $instanceClass($instanceId);
			$edip->RefreshDisplay();
		}
	}

	/** @}*/
?>
コード例 #30
0
ファイル: module.php プロジェクト: mcbeyel/SymconSonos
 public function SetGroup($groupCoordinator)
 {
     if ($this->ReadPropertyBoolean("GroupCoordinator")) {
         return;
     }
     $ip = $this->ReadPropertyString("IPAddress");
     $timeout = $this->ReadPropertyString("TimeOut");
     if ($timeout && Sys_Ping($ip, $timeout) != true) {
         throw new Exception("Sonos Box " . $ip . " is not available");
     }
     // get variable of coordinator members to be updated
     if ($groupCoordinator) {
         $groupMembersID = @IPS_GetObjectIDByIdent("GroupMembers", $groupCoordinator);
         $uri = "x-rincon:" . IPS_GetProperty($groupCoordinator, "RINCON");
     } else {
         $groupMembersID = @IPS_GetObjectIDByIdent("GroupMembers", GetValue($this->GetIDForIdent("MemberOfGroup")));
         $uri = "";
     }
     // update coordinator members
     SetValue($this->GetIDForIdent("MemberOfGroup"), $groupCoordinator);
     if ($groupMembersID) {
         $currentMembers = explode(",", GetValueString($groupMembersID));
         $currentMembers = array_filter($currentMembers, function ($v) {
             return $v != "";
         });
         $currentMembers = array_filter($currentMembers, function ($v) {
             return $v != $this->InstanceID;
         });
         if ($groupCoordinator) {
             $currentMembers[] = $this->InstanceID;
         }
         SetValueString($groupMembersID, implode(",", $currentMembers));
     }
     // Set relevant variables to hidden/unhidden
     if ($groupCoordinator) {
         $hidden = true;
     } else {
         $hidden = false;
     }
     IPS_SetHidden($this->GetIDForIdent("nowPlaying"), $hidden);
     IPS_SetHidden($this->GetIDForIdent("Radio"), $hidden);
     IPS_SetHidden($this->GetIDForIdent("Playlist"), $hidden);
     IPS_SetHidden($this->GetIDForIdent("Status"), $hidden);
     IPS_SetHidden($this->GetIDForIdent("Sleeptimer"), $hidden);
     include_once __DIR__ . "/sonosAccess.php";
     (new SonosAccess($ip))->SetAVTransportURI($uri);
 }