Esempio n. 1
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;
}
Esempio n. 2
0
     echo "Gerät mit der Addresse " . (string) $Channel['Address'] . " hat keine Datenpunkte." . PHP_EOL;
     echo "  Gerät mit Namen '" . utf8_decode((string) $Channel['Name']) . "' wird wieder gelöscht." . PHP_EOL;
     echo "--------------------------------------------------------------------" . PHP_EOL;
     IPS_DeleteInstance($HMDevice);
     continue;
 }
 $DeviceHidden = true;
 foreach ($Childs as $Var) {
     $Obj = IPS_GetObject($Var);
     if (array_key_exists($Obj['ObjectIdent'], $Mapping)) {
         $Name = sprintf($Mapping[$Obj['ObjectIdent']]['Name Raum'], utf8_decode((string) $Channel['Name']), utf8_decode((string) $Channel->Room[0]['Name']));
         //				    $Name = 		$NameMappingRoom[$Obj['ObjectIdent']];
         IPS_SetName($Var, $Name);
         // Profil ändern, wenn nicht leer im Mapping
         if ($Mapping[$Obj['ObjectIdent']]['Profil'] != '') {
             if (!@IPS_SetVariableCustomProfile($Var, $Mapping[$Obj['ObjectIdent']]['Profil'])) {
                 echo "Fehler bei Gerät mit der Addresse " . (string) $Channel['Address'] . " und Datenpunkt " . $Obj['ObjectIdent'] . PHP_EOL;
                 echo "  Profil '" . $Mapping[$Obj['ObjectIdent']]['Profil'] . "' konnte nicht zugewiesen werden." . PHP_EOL;
                 echo "--------------------------------------------------------------------" . PHP_EOL;
             }
         }
         if (IPS_GetVariable($Var)['VariableAction'] > 0) {
             // Standardaktion möglich
             if ($Mapping[$Obj['ObjectIdent']]['Action'] === true) {
                 IPS_SetVariableCustomAction($Var, 0);
             } elseif ($Mapping[$Obj['ObjectIdent']]['Action'] === false) {
                 IPS_SetVariableCustomAction($Var, 1);
             }
         } else {
             if ($Mapping[$Obj['ObjectIdent']]['Action'] === true) {
                 echo "Gerät mit der Addresse " . (string) $Channel['Address'] . " hat keine Standardaktion," . PHP_EOL;
Esempio n. 3
0
 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;
 }
Esempio n. 4
0
 private function ReceiveCMDData(TXB_Command_Data $ATData)
 {
     $ReplyATDataID = $this->GetIDForIdent('ReplyATData');
     $ReplyATData = $ATData->ToJSONString('');
     if (!$this->lock('ReplyATData')) {
         throw new Exception('ReplyATData is locked');
     }
     //         SendData('AT_Command_Responde('+XB_ATCommandToString(ATData.ATCommand)+')',ATData.data);
     SetValueString($ReplyATDataID, $ReplyATData);
     $this->unlock('ReplyATData');
     if ($ATData->Status != TXB_Command_Status::XB_Command_OK) {
         return;
     }
     switch ($ATData->ATCommand) {
         case TXB_AT_Command::XB_AT_D0:
         case TXB_AT_Command::XB_AT_D1:
         case TXB_AT_Command::XB_AT_D2:
         case TXB_AT_Command::XB_AT_D3:
         case TXB_AT_Command::XB_AT_D4:
         case TXB_AT_Command::XB_AT_D5:
         case TXB_AT_Command::XB_AT_D6:
         case TXB_AT_Command::XB_AT_D7:
         case TXB_AT_Command::XB_AT_P0:
         case TXB_AT_Command::XB_AT_P1:
         case TXB_AT_Command::XB_AT_P2:
             // Neuen Wert darstellen und Variable anlegen und Schaltbar machen wenn Value 4 oder 5 sonst nicht schaltbar
             if (strlen($ATData->Data) != 1) {
                 return;
             }
             switch (ord($ATData->Data)) {
                 case 0:
                 case 1:
                     $VarID = @$this->GetIDForIdent($ATData->ATCommand);
                     if ($VarID != 0) {
                         $this->DisableAction($ATData->ATCommand);
                         IPS_SetVariableCustomProfile($VarID, '');
                     }
                     break;
                 case 2:
                     $VarID = $this->RegisterVariableInteger('A' . $ATData->ATCommand, 'A' . $ATData->ATCommand);
                     if ($VarID != 0) {
                         $this->DisableAction($ATData->ATCommand);
                         IPS_SetVariableCustomProfile($VarID, '');
                     }
                     break;
                 case 3:
                     $VarID = $this->RegisterVariableBoolean($ATData->ATCommand, $ATData->ATCommand);
                     $this->DisableAction($ATData->ATCommand);
                     IPS_SetVariableCustomProfile($VarID, '');
                     break;
                 case 4:
                     $VarID = $this->RegisterVariableBoolean($ATData->ATCommand, $ATData->ATCommand);
                     IPS_SetVariableCustomProfile($VarID, '~Switch');
                     $this->EnableAction($ATData->ATCommand);
                     SetValueBoolean($VarID, false);
                     break;
                 case 5:
                     $VarID = $this->RegisterVariableBoolean($ATData->ATCommand, $ATData->ATCommand);
                     IPS_SetVariableCustomProfile($VarID, '~Switch');
                     $this->EnableAction($ATData->ATCommand);
                     SetValueBoolean($VarID, true);
                     break;
             }
             break;
         case TXB_AT_Command::XB_AT_IS:
             //                if not fDelayTimerActive then
             $IOSample = new TXB_API_IO_Sample();
             $IOSample->Status = TXB_Receive_Status::XB_Receive_Packet_Acknowledged;
             $IOSample->Sample = $ATData->Data;
             $this->DecodeIOSample($IOSample);
             break;
     }
 }
 /**
  * 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();
     }
 }
Esempio n. 6
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);
}
Esempio n. 7
0
 /**
  * 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;
 }
 /**
  * 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;
 }
Esempio n. 9
0
  public function ApplyData($data) {
    $data = (array)$data;
    $state = (array)$data['state'];

    /*
     * Properties
     */

    $dirty = false;

    $modelid = utf8_decode((string)$data['modelid']);
    $type = utf8_decode((string)$data['type']);
    $name = utf8_decode((string)$data['name']);
    if (IPS_GetProperty($this->InstanceID, 'ModelId') != $modelid) {
      IPS_SetProperty($this->InstanceID, 'ModelId', $modelid);
      $dirty = true;
    }
    if (IPS_GetProperty($this->InstanceID, 'Type') != $type) {
      IPS_SetProperty($this->InstanceID, 'Type', $type);
      $dirty = true;
    }
    if (IPS_GetName($this->InstanceID) != $name) {
      IPS_SetName($this->InstanceID, $name);
      $dirty = true;
    }

    // Setze den Modus
    if (isset($state['ct']) && isset($state['hue'])) {
      // HUE+CT Lamp
      $lightFeature = 0;
    } elseif(isset($state['hue'])) {
      // HUE Lamp
      $lightFeature = 1;
    } elseif(isset($state['ct'])) {
      // CT Lamp
      $lightFeature = 2;
    } else {
      // Lux Lamp
      $lightFeature = 3;
    }

    if (IPS_GetProperty($this->InstanceID, 'LightFeatures') != $lightFeature) {
      IPS_SetProperty($this->InstanceID, 'LightFeatures', $lightFeature);
      $dirty = true;
    }

    if ($dirty) IPS_ApplyChanges($this->InstanceID);

    /*
     * Variables
     */

    $stateId = $this->RegisterVariableBoolean("STATE", "Zustand", "~Switch");
    $this->EnableAction("STATE");
    IPS_SetPosition($stateId, 1);

    $cmId = $this->RegisterVariableInteger("COLOR_MODE", "Modus", "ColorModeSelect.Hue");
    $this->EnableAction("COLOR_MODE");
    IPS_SetPosition($cmId, 2);
    IPS_SetIcon($cmId, 'ArrowRight');

    $briId = $this->RegisterVariableInteger("BRIGHTNESS", "Helligkeit", "~Intensity.100");
    $this->EnableAction("BRIGHTNESS");
    IPS_SetIcon($briId, 'Sun');
    IPS_SetPosition($briId, 5);

    if ($lightFeature == 0 || $lightFeature == 1) {
      $hueId = $this->RegisterVariableInteger("HUE", "Hue");
      IPS_SetHidden($hueId, true);
    } else {
      $delete = @IPS_GetObjectIDByIdent("HUE", $this->InstanceID);
      if ($delete !== false) IPS_DeleteVariable($delete);
    }

    if ($lightFeature == 0) {
      IPS_SetVariableCustomProfile($cmId, 'ColorModeSelect.Hue');
      IPS_SetHidden($cmId, false);
    } else {
      IPS_SetHidden($cmId, true);
    }

    if ($lightFeature == 0 || $lightFeature == 2) {
      $ctId = $this->RegisterVariableInteger("COLOR_TEMPERATURE", "Farbtemperatur", "~Intensity.100");
      $this->EnableAction("COLOR_TEMPERATURE");
      IPS_SetIcon($ctId, 'Bulb');
      IPS_SetPosition($ctId, 4);
    } else {
      $delete = @IPS_GetObjectIDByIdent("COLOR_TEMPERATURE", $this->InstanceID);
      if ($delete !== false) IPS_DeleteVariable($delete);
    }

    if ($lightFeature == 0 || $lightFeature == 1) {
      $colorId = $this->RegisterVariableInteger("COLOR", "Farbe", "~HexColor");
      $this->EnableAction("COLOR");
      IPS_SetPosition($colorId, 3);
      IPS_SetIcon($colorId, 'Bulb');

      $satId = $this->RegisterVariableInteger("SATURATION", utf8_decode("Sättigung"), "~Intensity.100");
      $this->EnableAction("SATURATION");
      IPS_SetIcon($satId, 'Intensity');
      IPS_SetPosition($satId, 6);

    } else {
      $delete = @IPS_GetObjectIDByIdent("COLOR", $this->InstanceID);
      if ($delete !== false) IPS_DeleteVariable($delete);
      $delete = @IPS_GetObjectIDByIdent("SATURATION", $this->InstanceID);
      if ($delete !== false) IPS_DeleteVariable($delete);
    }

    /*
     * Values
     */

    SetValueBoolean($stateId, $state['on']);
    SetValueInteger($briId, round($state['bri'] * 100 / 254));
    if (@$satId) SetValueInteger($satId, round($state['sat'] * 100 / 254));
    if (@$hueId) SetValueInteger($hueId, $state['hue']);
    if (@$ctId) SetValueInteger($ctId, 100 - round(( $state['ct'] - 153) * 100 / 347));

    switch (@$state['colormode']) {
      case 'xy':
      case 'hs':
        $hex = $this->HSV2HEX($state['hue'], $state['sat'], $state['bri']);
        SetValueInteger($colorId, hexdec($hex));
        IPS_SetHidden($colorId, false);
        IPS_SetHidden($satId, false);
        if (@$ctId) IPS_SetHidden($ctId, true);
        if (@$cmId) SetValueInteger($cmId, 0);
        break;
      case 'ct':
        if(@$colorId) IPS_SetHidden($colorId, true);
        if(@$satId) IPS_SetHidden($satId, true);
        IPS_SetHidden($ctId, false);
        SetValueInteger($cmId, 1);
        break;
    }
  }
Esempio n. 10
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);
}
Esempio n. 11
0
 public function ApplyChanges()
 {
     //Never delete this line!
     parent::ApplyChanges();
     $ArchivID = IPS_GetInstanceListByModuleID("{43192F0B-135B-4CE7-A0A7-1475603F3060}");
     $ArchivID = $ArchivID[0];
     $this->RegisterProfile(1, "WITHINGS_M_Groesse", "Gauge", "", " cm");
     $this->RegisterProfile(1, "WITHINGS_M_Puls", "Graph", "", " bpm");
     $this->RegisterProfile(2, "WITHINGS_M_Kilo", "", "", " kg", false, false, false, 1);
     $this->RegisterProfile(2, "WITHINGS_M_Prozent", "", "", " %", false, false, false, 1);
     $this->RegisterProfile(2, "WITHINGS_M_BMI", "", "", " kg/m²", false, false, false, 1);
     $this->RegisterProfile(1, "WITHINGS_M_Blutdruck", "", "", " mmHg");
     $this->RegisterProfileGender("WITHINGS_M_Gender", "", "", "", array(array(0, "maennlich", "", 0xff), array(1, "weiblich", "", 0xff0000)));
     $id = $this->RegisterVariableString("name", "Name", "~String", 0);
     $id = $this->RegisterVariableInteger("gender", "Geschlecht", "WITHINGS_M_Gender", 2);
     $id = $this->RegisterVariableString("birthdate", "Geburtstag", "~String", 1);
     $id = $this->RegisterVariableInteger("height", "Groesse", "WITHINGS_M_Groesse", 3);
     $parent = IPS_GetParent($id);
     $CatID = false;
     if ($this->ReadPropertyBoolean("BloodMeasures") == true) {
         $CatID = $this->CreateKategorie("Blutdruck", $parent);
         if ($CatID === false) {
             throw new Exception("Kategorie Blutdruck nicht definiert");
         }
         $VariablenID = @IPS_GetVariableIDByName("Diastolic", $CatID);
         if ($VariablenID === false) {
             $id = $this->RegisterVariableInteger("diastolicblood", "Diastolic", "WITHINGS_M_Blutdruck", 2);
             IPS_SetParent($id, $CatID);
         }
         $VariablenID = @IPS_GetVariableIDByName("Systolic", $CatID);
         if ($VariablenID === false) {
             $id = $this->RegisterVariableInteger("systolicblood", "Systolic", "WITHINGS_M_Blutdruck", 1);
             IPS_SetParent($id, $CatID);
         }
         $VariablenID = @IPS_GetVariableIDByName("Puls", $CatID);
         if ($VariablenID === false) {
             $id = $this->RegisterVariableInteger("heartpulse", "Puls", "WITHINGS_M_Puls", 3);
             IPS_SetParent($id, $CatID);
         }
         $VariablenID = @IPS_GetVariableIDByName("DatumUhrzeit", $CatID);
         if ($VariablenID === false) {
             $id = $this->RegisterVariableInteger("timestamp", "DatumUhrzeit", "~UnixTimestamp", 0);
             IPS_SetParent($id, $CatID);
         }
     }
     $logging = $this->ReadPropertyBoolean("BloodLogging");
     if ($CatID) {
         if ($logging) {
             $this->Logging("BloodLogging wird eingeschaltet");
         } else {
             $this->Logging("BloodLogging wird ausgeschaltet");
         }
         $id = IPS_GetVariableIDByName("Diastolic", $CatID);
         if (AC_GetLoggingStatus($ArchivID, $id) != $logging) {
             AC_SetLoggingStatus($ArchivID, $id, $logging);
             IPS_ApplyChanges($ArchivID);
         }
         $id = IPS_GetVariableIDByName("Systolic", $CatID);
         if (AC_GetLoggingStatus($ArchivID, $id) != $logging) {
             AC_SetLoggingStatus($ArchivID, $id, $logging);
             IPS_ApplyChanges($ArchivID);
         }
         $id = IPS_GetVariableIDByName("Puls", $CatID);
         if (AC_GetLoggingStatus($ArchivID, $id) != $logging) {
             AC_SetLoggingStatus($ArchivID, $id, $logging);
             IPS_ApplyChanges($ArchivID);
         }
         $status = $this->ReadPropertyBoolean("BloodVisible");
         $this->KategorieEnable($parent, "Blutdruck", $status);
     }
     $CatID = false;
     if ($this->ReadPropertyBoolean("BodyMeasures") == true) {
         $CatID = $this->CreateKategorie("Waage", $parent);
         if ($CatID === false) {
             throw new Exception("Kategorie Waage nicht definiert");
         }
         $VariablenID = @IPS_GetVariableIDByName("DatumUhrzeit", $CatID);
         if ($VariablenID === false) {
             $id = $this->RegisterVariableInteger("timestamp", "DatumUhrzeit", "~UnixTimestamp", 0);
             IPS_SetParent($id, $CatID);
         }
         $VariablenID = @IPS_GetVariableIDByName("Gewicht", $CatID);
         if ($VariablenID === false) {
             $id = $this->RegisterVariableFloat("weight", "Gewicht", "WITHINGS_M_Kilo", 1);
             IPS_SetParent($id, $CatID);
         }
         $VariablenID = @IPS_GetVariableIDByName("Fettfrei Anteil", $CatID);
         if ($VariablenID === false) {
             $id = $this->RegisterVariableFloat("fatfree", "Fettfrei Anteil", "WITHINGS_M_Kilo", 3);
             IPS_SetParent($id, $CatID);
         }
         $VariablenID = @IPS_GetVariableIDByName("Fett Anteil", $CatID);
         if ($VariablenID === false) {
             $id = $this->RegisterVariableFloat("fatmassweight", "Fett Anteil", "WITHINGS_M_Kilo", 2);
             IPS_SetParent($id, $CatID);
         }
         $VariablenID = @IPS_GetVariableIDByName("Fett Prozent", $CatID);
         if ($VariablenID === false) {
             $id = $this->RegisterVariableFloat("fatradio", "Fett Prozent", "WITHINGS_M_Prozent", 4);
             IPS_SetParent($id, $CatID);
         }
         $VariablenID = @IPS_GetVariableIDByName("BMI", $CatID);
         if ($VariablenID === false) {
             $id = $this->RegisterVariableFloat("bmi", "BMI", "WITHINGS_M_BMI", 5);
             IPS_SetParent($id, $CatID);
         } else {
             @IPS_SetVariableCustomProfile($VariablenID, "WITHINGS_M_BMI");
         }
         if ($this->ReadPropertyBoolean("BodyPuls") == true) {
             $VariablenID = @IPS_GetVariableIDByName("Puls", $CatID);
             if ($VariablenID === false) {
                 $id = $this->RegisterVariableInteger("heartpulse", "Puls", "WITHINGS_M_Puls", 3);
                 IPS_SetParent($id, $CatID);
             }
         }
     }
     $logging = $this->ReadPropertyBoolean("BodyLogging");
     if ($CatID) {
         if ($logging) {
             $this->Logging("BodyLogging wird eingeschaltet");
         } else {
             $this->Logging("BodyLogging wird ausgeschaltet");
         }
         $id = IPS_GetVariableIDByName("Gewicht", $CatID);
         if (AC_GetLoggingStatus($ArchivID, $id) != $logging) {
             AC_SetLoggingStatus($ArchivID, $id, $logging);
             IPS_ApplyChanges($ArchivID);
         }
         $id = IPS_GetVariableIDByName("Fettfrei Anteil", $CatID);
         if (AC_GetLoggingStatus($ArchivID, $id) != $logging) {
             AC_SetLoggingStatus($ArchivID, $id, $logging);
             IPS_ApplyChanges($ArchivID);
         }
         $id = IPS_GetVariableIDByName("Fett Anteil", $CatID);
         if (AC_GetLoggingStatus($ArchivID, $id) != $logging) {
             AC_SetLoggingStatus($ArchivID, $id, $logging);
             IPS_ApplyChanges($ArchivID);
         }
         $id = IPS_GetVariableIDByName("Fett Prozent", $CatID);
         if (AC_GetLoggingStatus($ArchivID, $id) != $logging) {
             AC_SetLoggingStatus($ArchivID, $id, $logging);
             IPS_ApplyChanges($ArchivID);
         }
         $id = IPS_GetVariableIDByName("BMI", $CatID);
         if (AC_GetLoggingStatus($ArchivID, $id) != $logging) {
             AC_SetLoggingStatus($ArchivID, $id, $logging);
             IPS_ApplyChanges($ArchivID);
         }
         $id = @IPS_GetVariableIDByName("Puls", $CatID);
         if ($id > 0) {
             if (AC_GetLoggingStatus($ArchivID, $id) != $logging) {
                 AC_SetLoggingStatus($ArchivID, $id, $logging);
                 IPS_ApplyChanges($ArchivID);
             }
         }
     }
     $status = $this->ReadPropertyBoolean("BodyVisible");
     $this->KategorieEnable($parent, "Waage", $status);
     //Timer erstellen
     $this->SetTimerInterval("WIT_UpdateTimer", $this->ReadPropertyInteger("Intervall"));
     //Update
     $this->Update();
 }