예제 #1
0
 public function Schalten($value)
 {
     $proto = $this->ReadPropertyString("protokoll");
     $idValue = IPS_GetVariableIDByName("Status", $this->InstanceID);
     $value = getValue($idValue);
     $cmd = "/usr/local/bin/pilight-send -p {$proto}";
     // 			$idID=IPS_GetCategoryIDByName("ID",$inst);
     // 			$idsId=IPS_GetChildrenIDs($idID);
     // 			foreach($idsId as $ix=>$id) {
     // 				$name=IPS_GetName($id);
     // 				$parm=getValue($id);
     // 				$cmd.=" --$name=$parm";
     // 			}
     $val = $this->ReadPropertyInteger("programcode");
     $cmd .= " --programcode={$val}";
     $val = $this->ReadPropertyInteger("systemcode");
     $cmd .= " --systemcode={$val}";
     if ($value) {
         $value = "-t";
     } else {
         $value = "-f";
     }
     $cmd .= " {$value}";
     // pilight-send -p kaku_switch -i 1 -u 1 -t
     print_r("befehl=" . $cmd . "\n");
     //$rc = trim(@shell_exec("/usr/local/bin/pilight-send -p $proto -i $id -u $unit $value"));
     $retries = $this->ReadPropertyInteger("retries");
     for ($i = 1; $i <= $retries; $i++) {
         $rc = trim(@shell_exec($cmd));
     }
 }
예제 #2
0
function CheckVariable($name, $vartyp, $profile, $parentID)
{
    $InstanzID = @IPS_GetVariableIDByName($name, $parentID);
    if ($InstanzID === false) {
        $InstanzID = IPS_CreateVariable($vartyp);
        IPS_SetName($InstanzID, $name);
        // Instanz benennen
        IPS_SetParent($InstanzID, $parentID);
        IPS_SetVariableCustomProfile($InstanzID, $profile);
    }
    //echo "ID: ".$InstanzID." ".$name."\n";
    return $InstanzID;
}
		/**
		 * @public
		 *
		 * Liefert aktuellen Zustand
		 *
		 * @return boolean aktueller Schaltzustand  
		 */
		public function GetState() {
			GetValue(IPS_GetVariableIDByName('STATE', $this->instanceId));
		}
function EncodeVariableData($parentID, $typ)
{
    $var = Buderus($typ, -1, 1);
    if ($var === '0') {
        return true;
    } else {
        $ID = IPS_GetVariableIDByName(Buderus($typ, -1, 0), $parentID);
        $value = GetValueString($ID);
        for ($x = 0; $x < Buderus($typ, -1, 1); $x++) {
            if (Buderus($typ, $x, 0) !== "") {
                switch (Buderus($typ, $x, 1)) {
                    case "Bit":
                        SetValue(CheckVariableTYP(Buderus($typ, $x, 0), 3, "~String", $ID), str_pad(base_convert(ord(hex2bin(substr($value, $x * 2, 2))), 16, 2), 8, "0", STR_PAD_LEFT));
                        break;
                    case "Temp":
                        SetValue(CheckVariableTYP(Buderus($typ, $x, 0), 2, "~Temperature", $ID), ord(hex2bin(substr($value, $x * 2, 2))) * Buderus($typ, $x, 2));
                        break;
                    case "Temp2":
                        SetValue(CheckVariableTYP(Buderus($typ, $x, 0), 2, "~Temperature", $ID), ord(hex2bin(substr($value, $x * 2, 2))) * Buderus($typ, $x, 2) + ord(hex2bin(substr($value, $x * 2 + 1, 2))) * Buderus($typ, $x + 1, 2));
                        $x++;
                        break;
                    case "Temp3":
                        SetValue(CheckVariableTYP(Buderus($typ, $x, 0), 2, "~Temperature", $ID), ord(hex2bin(substr($value, $x * 2, 2))) * Buderus($typ, $x, 2));
                        break;
                    case "Zeit":
                        SetValue(CheckVariableTYP(Buderus($typ, $x, 0), 1, "~Temperature", $ID), ord(hex2bin(substr($value, $x * 2, 2))));
                        //Minutes
                        break;
                    case "Prozent":
                        SetValue(CheckVariableTYP(Buderus($typ, $x, 0), 1, "~Valve", $ID), ord(hex2bin(substr($value, $x * 2, 2))));
                        break;
                    case "Betr":
                        SetValue(CheckVariableTYP(Buderus($typ, $x, 0), 2, "Hours", $ID), (ord(hex2bin(substr($value, $x * 2, 2))) * Buderus($typ, $x, 2) + ord(hex2bin(substr($value, $x * 2 + 1, 2))) * Buderus($typ, $x + 1, 2) + ord(hex2bin(substr($value, $x * 2 + 2, 2))) * Buderus($typ, $x + 2, 2)) / 60);
                        //
                        $x++;
                        $x++;
                        break;
                    case "Betr2":
                        SetValue(CheckVariableTYP(Buderus($typ, $x, 0), 2, "Minutes", $ID), (ord(hex2bin(substr($value, $x * 2, 2))) * Buderus($typ, $x, 2) + ord(hex2bin(substr($value, $x * 2 + 1, 2))) * Buderus($typ, $x + 1, 2) + ord(hex2bin(substr($value, $x * 2 + 2, 2))) * Buderus($typ, $x + 2, 2)) / 60);
                        //
                        $x++;
                        $x++;
                        break;
                    case "Waerme":
                        SetValue(CheckVariableTYP(Buderus($typ, $x, 0), 2, "Waerme", $ID), (ord(hex2bin(substr($value, $x * 2, 2))) * Buderus($typ, $x, 2) + ord(hex2bin(substr($value, $x * 2 + 1, 2))) * Buderus($typ, $x + 1, 2) + ord(hex2bin(substr($value, $x * 2 + 2, 2))) * Buderus($typ, $x + 2, 2)) / 100);
                        //
                        $x++;
                        $x++;
                        break;
                    case "Watt":
                        SetValue(CheckVariableTYP(Buderus($typ, $x, 0), 2, "Watt", $ID), ord(hex2bin(substr($value, $x * 2, 2))) * Buderus($typ, $x, 2) + ord(hex2bin(substr($value, $x + 1, 2))) * Buderus($typ, $x + 1, 2));
                        //
                        $x++;
                        break;
                    case "Flow":
                        SetValue(CheckVariableTYP(Buderus($typ, $x, 0), 2, "Flow", $ID), ord(hex2bin(substr($value, $x * 2, 2))) * Buderus($typ, $x, 2) + ord(hex2bin(substr($value, $x * 2 + 1, 2))) * Buderus($typ, $x + 1, 2));
                        // l/h
                        $x++;
                        break;
                    case "Version":
                        SetValue(CheckVariableTYP(Buderus($typ, $x, 0), 3, "Version", $ID), ord(hex2bin(substr($value, $x * 2, 2))) . "." . ord(hex2bin(substr($value, $x * 2 + 1, 2))));
                        //
                        $x++;
                        break;
                    case "Modul":
                        SetValue(CheckVariableTYP(Buderus($typ, $x, 0), 3, "~String", $ID), Buderus($typ, $x, ord(hex2bin(substr($value, $x * 2, 2))) + 2));
                        break;
                }
            }
        }
    }
}
예제 #5
0
	function get_ControlId($ControlName, $CircleId) {
		$VariableId = IPS_GetVariableIDByName($ControlName, $CircleId);
		if ($VariableId === false) {
			IPSLogger_Err(__file__, "Control '$ControlName' could NOT be found for CircleId=$CircleId");
			exit;
		}
	   
		return $VariableId;
	}
 /**
  * constructor
  *
  * second constructor: create the variable in symcon if it does not exist
  *
  * @param string $name name of the variable
  * @param integer $type IPS datatype
  * @param integer $parent id of the variables parent, this defines where the variable will be created
  * @param mixed $value initially set a variable value
  * @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 integer $aggregationType logging aggregation: 0 = gauge, 1 = counter
  * @param boolean $debug enables / disables debug information
  *
  * @throws Exception if the parameter \$profile is not an IPSVariableProfile datatype
  * @access public
  */
 private function __construct2($name, $type, $parent, $profile = NULL, $enableLogging = false, $archiveId = NULL, $aggregationType = 0, $debug = false)
 {
     if (isset($profile) && !$profile instanceof IPSVariableProfile) {
         throw new Exception("Parameter \$profile must be an instance of IPSVariableProfile! \$name of the variable is '{$name}'");
     }
     $this->name = $name;
     $this->type = $type;
     $this->parent = $parent;
     $this->profile = $profile;
     $this->enableLogging = $enableLogging;
     $this->archiveId = $archiveId;
     $this->aggregationType = $aggregationType;
     $this->debug = $debug;
     $this->id = @IPS_GetVariableIDByName($name, $parent);
     if ($this->id == false) {
         if ($this->debug) {
             echo "INFO - create IPS variable {$name}\n";
         }
         $this->id = IPS_CreateVariable($this->type);
         IPS_SetName($this->id, $name);
         IPS_SetParent($this->id, $parent);
         IPS_SetInfo($this->id, "this variable was created by script " . $_IPS['SELF'] . " which is part of the ips-library (https://github.com/florianprobst/ips-library)");
         if (isset($profile)) {
             IPS_SetVariableCustomProfile($this->id, $profile->getName());
         }
         $this->verifyVariableLogging();
     }
 }
		/**
		 * @public
		 *
		 * Liefert aktuellen Power Zustand des Dimmers
		 *
		 * @return boolean Gerätezustand On/Off des Dimmers
		 */
		public function GetPower() {
			return GetValue(IPS_GetVariableIDByName('LEVEL', $this->instanceId)) > 0;
		}
예제 #8
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);
예제 #9
0
<?php

$macList = array(array("Name" => "Mein Device 1", "MAC" => "11:22:33:44:55:66"), array("Name" => "Mein Device 2", "MAC" => "11:22:33:44:55:66", "PresentVarID" => 12345));
// Eine weitere Lockup Tabelle für die Accesspoints und deren Alias.
$apList = array(array("Name" => "Dachboden", "MAC" => "24:a4:3c:be:32:3e"), array("Name" => "Flur unten", "MAC" => "24:a4:3c:a2:ed:38"), array("Name" => "Garten", "MAC" => "24:a4:3c:a2:f0:a6"));
// ----------------------------------------------------------------------------------
// Ab hier dann bitte nichts mehr ändern
// ----------------------------------------------------------------------------------
include_once "../modules/KH_UniFi/UniFi/orga.php";
$parentID = IPS_GetParent($_IPS["SELF"]);
$htmlBoxID = IPS_GetVariableIDByName("ClientHTMLBox", $parentID);
$clientList = UniFi_GetClients($parentID);
$scriptResult = "";
echo print_r($clientList);
if (is_object($clientList)) {
    foreach ($clientList->data as $client) {
        echo print_r($client);
        $scriptResult .= "<tr style='height:20px;font-size:12px;'>";
        // Name über MACNummer rausfinden.
        // Nicht alle Geräte senden anständig ihren Namen mit. Deswegen über Liste arbeiten
        $clientName = "";
        foreach ($macList as $key => $entry) {
            if ($entry["MAC"] == $client->mac) {
                $clientName = $entry["Name"];
                break;
            }
        }
        // War nicht in Liste!
        if ($clientName == "") {
            $clientName = $client->hostname;
        }
	SetVariableConstant ("NP_ID_CDTRACKNAV",      $cdTrackNavId,           'NetPlayer_IDs.inc.php', 'IPSLibrary::app::modules::NetPlayer');
	SetVariableConstant ("NP_ID_RADIOLIST",       $radioListId,            'NetPlayer_IDs.inc.php', 'IPSLibrary::app::modules::NetPlayer');
	SetVariableConstant ("NP_ID_RADIONAV",        $radioNavId,             'NetPlayer_IDs.inc.php', 'IPSLibrary::app::modules::NetPlayer');
	SetVariableConstant ("NP_ID_SOURCE",          $sourceId,               'NetPlayer_IDs.inc.php', 'IPSLibrary::app::modules::NetPlayer');
	SetVariableConstant ('"NP_ID_CONTROL"',       $controlId,              'NetPlayer_IDs.inc.php', 'IPSLibrary::app::modules::NetPlayer');

	// Installation of Components
	IPSUtils_Include ("NetPlayer_Constants.inc.php",     "IPSLibrary::app::modules::NetPlayer");
	IPSUtils_Include ("NetPlayer_Configuration.inc.php", "IPSLibrary::config::modules::NetPlayer");

	$params = explode(',',NETPLAYER_COMPONENT);
	if ($params[0] == 'IPSComponentPlayer_Mediaplayer') {
	   if (!is_numeric($params[1])) {
	      $pathItems = explode('.',$params[1]);
	      $mediaPlayerName = $pathItems[count($pathItems)-1];
	      unset($pathItems[count($pathItems)-1]);
	      $path = implode('.', $pathItems);
			$categoryId  = CreateCategoryPath($path);

			// Create MediaPlayer
   		$mediaPlayerInstanceId   = CreateMediaPlayer($mediaPlayerName, $categoryId, 0);
   		$mediaPlayerTitel        = IPS_GetVariableIDByName('Titel', $mediaPlayerInstanceId);

   		// Register Message Handler
			IPSMessageHandler::RegisterOnChangeEvent($mediaPlayerTitel/*Var*/, 'IPSComponentPlayer_MediaPlayer,'.$mediaPlayerInstanceId, 'IPSModulePlayer_NetPlayer');
	   }
	}


  /** @}*/
?>
예제 #11
0
 public function ApplyChanges()
 {
     $ipAddress = $this->ReadPropertyString("IPAddress");
     if ($ipAddress) {
         $curl = curl_init();
         curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => 'http://' . $ipAddress . ':1400/xml/device_description.xml'));
         $result = curl_exec($curl);
         if (!curl_exec($curl)) {
             die('Error: "' . curl_error($curl) . '" - Code: ' . curl_errno($curl));
         }
     }
     //Never delete this line!
     parent::ApplyChanges();
     // Start create profiles
     $this->RegisterProfileIntegerEx("Status.SONOS", "Information", "", "", array(array(0, "Prev", "", -1), array(1, "Play", "", -1), array(2, "Pause", "", -1), array(3, "Stop", "", -1), array(4, "Next", "", -1), array(5, "Transition", "", -1)));
     $this->RegisterProfileInteger("Volume.SONOS", "Intensity", "", " %", 0, 100, 1);
     $this->RegisterProfileInteger("Tone.SONOS", "Intensity", "", " %", -10, 10, 1);
     $this->RegisterProfileInteger("Balance.SONOS", "Intensity", "", " %", -100, 100, 1);
     $this->RegisterProfileIntegerEx("Switch.SONOS", "Information", "", "", array(array(0, "Off", "", 0xff0000), array(1, "On", "", 0xff00)));
     //Build Radio Station Associations according to user settings
     if (!IPS_VariableProfileExists("Radio.SONOS")) {
         $this->UpdateRadioStations();
     }
     // Build Group Associations according Sonos Instance settings
     $allSonosInstances = IPS_GetInstanceListByModuleID("{F6F3A773-F685-4FD2-805E-83FD99407EE8}");
     $GroupAssociations = array(array(0, "none", "", -1));
     foreach ($allSonosInstances as $key => $SonosID) {
         if (@IPS_GetProperty($SonosID, "GroupCoordinator")) {
             $GroupAssociations[] = array($SonosID, IPS_GetName($SonosID), "", -1);
         }
     }
     if (IPS_VariableProfileExists("Groups.SONOS")) {
         IPS_DeleteVariableProfile("Groups.SONOS");
     }
     $this->RegisterProfileIntegerEx("Groups.SONOS", "Network", "", "", $GroupAssociations);
     // End Create Profiles
     // Start Register variables and Actions
     // 1) general availabe
     $this->RegisterVariableString("nowPlaying", "nowPlaying", "", 20);
     $this->RegisterVariableInteger("Radio", "Radio", "Radio.SONOS", 21);
     $this->RegisterVariableInteger("Status", "Status", "Status.SONOS", 29);
     $this->RegisterVariableInteger("Volume", "Volume", "Volume.SONOS", 30);
     $this->EnableAction("Radio");
     $this->EnableAction("Status");
     $this->EnableAction("Volume");
     // 2) Add/Remove according to feature activation
     // create link list for deletion of liks if target is deleted
     $links = array();
     foreach (IPS_GetLinkList() as $key => $LinkID) {
         $links[] = array('LinkID' => $LinkID, 'TargetID' => IPS_GetLink($LinkID)['TargetID']);
     }
     // 2a) Bass
     if ($this->ReadPropertyBoolean("BassControl")) {
         $this->RegisterVariableInteger("Bass", "Bass", "Tone.SONOS", 36);
         $this->EnableAction("Bass");
     } else {
         $this->removeVariableAction("Bass", $links);
     }
     // 2b) Treble
     if ($this->ReadPropertyBoolean("TrebleControl")) {
         $this->RegisterVariableInteger("Treble", "Treble", "Tone.SONOS", 37);
         $this->EnableAction("Treble");
     } else {
         $this->removeVariableAction("Treble", $links);
     }
     // 2c) Mute
     if ($this->ReadPropertyBoolean("MuteControl")) {
         $this->RegisterVariableInteger("Mute", "Mute", "Switch.SONOS", 31);
         $this->EnableAction("Mute");
     } else {
         $this->removeVariableAction("Mute", $links);
     }
     // 2d) Loudness
     if ($this->ReadPropertyBoolean("LoudnessControl")) {
         $this->RegisterVariableInteger("Loudness", "Loudness", "Switch.SONOS", 35);
         $this->EnableAction("Loudness");
     } else {
         $this->removeVariableAction("Loudness", $links);
     }
     // 2e) Balance
     if ($this->ReadPropertyBoolean("BalanceControl")) {
         $this->RegisterVariableInteger("Balance", "Balance", "Balance.SONOS", 38);
         $this->EnableAction("Balance");
     } else {
         $this->removeVariableAction("Balance", $links);
     }
     // 2f Sleeptimer
     if ($this->ReadPropertyBoolean("SleeptimerControl")) {
         $this->RegisterVariableInteger("Sleeptimer", "Sleeptimer", "", 39);
     } else {
         $this->removeVariable("Sleeptimer", $links);
     }
     // 2g Playlists
     if ($this->ReadPropertyBoolean("PlaylistControl")) {
         if (!IPS_VariableProfileExists("Playlist.SONOS")) {
             $this->RegisterProfileIntegerEx("Playlist.SONOS", "Database", "", "", array());
         }
         $this->RegisterVariableInteger("Playlist", "Playlist", "Playlist.SONOS", 22);
         $this->EnableAction("Playlist");
     } else {
         $this->removeVariable("Playlist", $links);
     }
     // 2h) GroupVolume, GroupMembers, MemberOfGroup
     if ($this->ReadPropertyBoolean("GroupCoordinator")) {
         IPS_SetHidden($this->RegisterVariableString("GroupMembers", "GroupMembers", "", 10), true);
         $this->RegisterVariableInteger("GroupVolume", "GroupVolume", "Volume.SONOS", 11);
         $this->EnableAction("GroupVolume");
         $this->removeVariableAction("MemberOfGroup", $links);
     } else {
         $this->RegisterVariableInteger("MemberOfGroup", "MemberOfGroup", "Groups.SONOS", 12);
         $this->EnableAction("MemberOfGroup");
         $this->removeVariableAction("GroupVolume", $links);
         $this->removeVariable("GroupMembers", $links);
     }
     // 2i) Hide/unhide MemberOfGroup depending on presence of GroupCoordinators
     if (sizeof($GroupAssociations) === 1) {
         // hide MemberOfGroup
         foreach ($allSonosInstances as $key => $SonosID) {
             $GroupingID = @IPS_GetVariableIDByName("MemberOfGroup", $SonosID);
             if ($GroupingID) {
                 IPS_SetHidden($GroupingID, true);
             }
         }
     } else {
         // unhide MemberOfGroup
         foreach ($allSonosInstances as $key => $SonosID) {
             $GroupingID = @IPS_GetVariableIDByName("MemberOfGroup", $SonosID);
             if ($GroupingID) {
                 IPS_SetHidden($GroupingID, false);
             }
         }
     }
     // End Register variables and Actions
     // Start add scripts for regular status and grouping updates
     // 1) _updateStatus
     $statusScriptID = @$this->GetIDForIdent("_updateStatus");
     if ($statusScriptID === false) {
         $statusScriptID = $this->RegisterScript("_updateStatus", "_updateStatus", file_get_contents(__DIR__ . "/_updateStatus.php"), 98);
     } else {
         IPS_SetScriptContent($statusScriptID, file_get_contents(__DIR__ . "/_updateStatus.php"));
     }
     IPS_SetHidden($statusScriptID, true);
     IPS_SetScriptTimer($statusScriptID, 5);
     // 2) _updateGrouping
     $groupingScriptID = @$this->GetIDForIdent("_updateGrouping");
     if ($groupingScriptID === false) {
         $groupingScriptID = $this->RegisterScript("_updateGrouping", "_updateGrouping", file_get_contents(__DIR__ . "/_updateGrouping.php"), 99);
     } else {
         IPS_SetScriptContent($groupingScriptID, file_get_contents(__DIR__ . "/_updateGrouping.php"));
     }
     IPS_SetHidden($groupingScriptID, true);
     IPS_SetScriptTimer($groupingScriptID, 300);
     // End add scripts for regular status and grouping updates
 }
예제 #12
0
<?php

include_once "../modules/KH_UniFi/UniFi/orga.php";
$parentID = IPS_GetParent($_IPS["SELF"]);
$wlanList = UniFi_GetWLANConfig($parentID);
$setWLANID = IPS_GetScriptIDByName("setWLAN", $parentID);
foreach ($wlanList->data as $wlan) {
    $ident = $wlan->_id;
    $rootCatID = CreateCategory("WLAN", "WLAN", $parentID);
    $catID = CreateCategory($wlan->name, $ident, $rootCatID);
    CreateVariable("ID", 3, $wlan->_id, $ident . "_id", $catID);
    CreateVariable("Enabled", 0, $wlan->enabled, $ident . "_enabled", $catID);
    $enabledID = IPS_GetVariableIDByName("Enabled", $catID);
    IPS_SetVariableCustomAction($enabledID, $setWLANID);
    IPS_SetVariableCustomProfile($enabledID, "~Switch");
    CreateVariable("Security", 3, $wlan->security, $ident . "_security", $catID);
}
		/**
		 * @public
		 *
		 * Liefert Position des gerade abgespielten Tracks
		 *
		 * @return string Position des Titels der gerade abgespielt wird
		 */
		public function GetTrackPosition() {
			return GetValue(IPS_GetVariableIDByName('Titelposition',$this->instanceId));
		}
예제 #14
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;}
	}
예제 #15
0
function Variable_GetOrSet($name, $parent, $value)
{
    global $Logging;
    $VarID = @IPS_GetVariableIDByName($name, $parent);
    if (!$VarID) {
        if ($name == "Name" or $name == "Marke" or $name == "ID" or $name == "Anschrift") {
            $VarID = IPS_CreateVariable(3);
        } elseif ($name == "Geöffnet_von" or $name == "Geöffnet_bis") {
            $VarID = IPS_CreateVariable(3);
            $ProfilName = "GeoffnetVonBis_Tankstelle_TK";
            if (!IPS_VariableProfileExists($ProfilName)) {
                IPS_CreateVariableProfile($ProfilName, 3);
                IPS_SetVariableProfileText($ProfilName, "", " Uhr");
                IPS_SetVariableProfileIcon($ProfilName, "Clock");
            }
            IPS_SetVariableCustomProfile($VarID, $ProfilName);
        } elseif ($name == "Geöffnet") {
            $VarID = IPS_CreateVariable(0);
            $ProfilName = "Geoeffnet_Tankstelle_TK";
            if (!IPS_VariableProfileExists($ProfilName)) {
                IPS_CreateVariableProfile($ProfilName, 0);
                IPS_SetVariableProfileAssociation($ProfilName, 0, "Geschlossen", "", -1);
                IPS_SetVariableProfileAssociation($ProfilName, 1, "Geöffnet", "", -1);
                IPS_SetVariableProfileIcon($ProfilName, "Information");
            }
            IPS_SetVariableCustomProfile($VarID, $ProfilName);
        } elseif ($name == "Distanz") {
            $VarID = IPS_CreateVariable(2);
            $ProfilName = "Distanz_Tankstelle_TK";
            if (!IPS_VariableProfileExists($ProfilName)) {
                IPS_CreateVariableProfile($ProfilName, 2);
                IPS_SetVariableProfileText($ProfilName, "", "km");
                IPS_SetVariableProfileDigits($ProfilName, 1);
                IPS_SetVariableProfileIcon($ProfilName, "Distance");
            }
            IPS_SetVariableCustomProfile($VarID, $ProfilName);
        } elseif ($name == "Preis" or $name == "Preis_E5" or $name == "Preis_E10" or $name == "Preis_Diesel") {
            if ($value === NULL) {
                return;
            }
            $VarID = IPS_CreateVariable(2);
            $ProfilName = "Euro_Tankstelle_TK";
            if (!IPS_VariableProfileExists($ProfilName)) {
                IPS_CreateVariableProfile($ProfilName, 2);
                IPS_SetVariableProfileText($ProfilName, "", "€");
                IPS_SetVariableProfileDigits($ProfilName, 3);
                IPS_SetVariableProfileIcon($ProfilName, "Euro");
            }
            IPS_SetVariableCustomProfile($VarID, $ProfilName);
            if ($Logging) {
                $ArchiveHandlerID = IPS_GetInstanceListByModuleID('{43192F0B-135B-4CE7-A0A7-1475603F3060}')[0];
                AC_SetLoggingStatus($ArchiveHandlerID, $VarID, true);
                IPS_ApplyChanges($ArchiveHandlerID);
            }
        }
        IPS_SetName($VarID, $name);
        IPS_SetParent($VarID, $parent);
    }
    SetValue($VarID, $value);
}
예제 #16
0
 protected function DoBlutdruck($ModulID, $data)
 {
     $diastolic = 0;
     $systolic = 0;
     $pulse = 0;
     $CatID = @IPS_GetCategoryIDByName("Blutdruck", $ModulID);
     if ($CatID === false) {
         return;
     }
     $time = @$data['measuregrps'][0]['date'];
     $data = @$data['measuregrps'][0]['measures'];
     if (count($data) != 3) {
         $this->Logging("Fehler bei DoBlutdruck " . count($data));
         //return;
     }
     $id = @IPS_GetVariableIDByName("DatumUhrzeit", $CatID);
     if ($id > 0) {
         $old = GetValueInteger($id);
         if ($old == $time) {
             // keine neue Daten
             return false;
         }
         SetValueInteger($id, $time);
     }
     foreach ($data as $messung) {
         $val = $messung['value'];
         if ($messung['type'] == 9) {
             $diastolic = $val;
         }
         if ($messung['type'] == 10) {
             $systolic = $val;
         }
         if ($messung['type'] == 11) {
             $pulse = $val;
         }
     }
     $id = IPS_GetVariableIDByName("Diastolic", $CatID);
     if ($id > 0) {
         SetValueInteger($id, $diastolic);
     }
     $id = IPS_GetVariableIDByName("Systolic", $CatID);
     if ($id > 0) {
         SetValueInteger($id, $systolic);
     }
     $id = IPS_GetVariableIDByName("Puls", $CatID);
     if ($id > 0) {
         SetValueInteger($id, $pulse);
     }
 }