Beispiel #1
0
 public function ApplyChanges()
 {
     //Never delete this line!
     parent::ApplyChanges();
     //Variablenprofil erstellen
     $this->RegisterProfileBooleanEx("HMON.OfflineOnline", "Network", "", "", array(array(false, "Offline", "", 0xff0000), array(true, "Online", "", 0xff00)));
     if ($this->ReadPropertyString("HostName") != "" and $this->ReadPropertyString("HostAdresse") != "") {
         //Status setzen
         $this->SetStatus(102);
         //Variablen erstellen
         $this->RegisterVariableBoolean("HostStatus", "Host - Status", "HMON.OfflineOnline");
         $this->RegisterVariableBoolean("HostBenachrichtigungsFlag", "Tmp");
         IPS_SetHidden($this->GetIDForIdent("HostBenachrichtigungsFlag"), true);
         $this->RegisterVariableInteger("HostLastOnline", "Host - Zuletzt online", "~UnixTimestamp");
         IPS_SetIcon($this->GetIDForIdent("HostLastOnline"), "Calendar");
         //Logging aktivieren
         if ($this->ReadPropertyBoolean("LoggingAktiv") === true) {
             $ArchiveHandlerID = IPS_GetInstanceListByModuleID('{43192F0B-135B-4CE7-A0A7-1475603F3060}')[0];
             AC_SetLoggingStatus($ArchiveHandlerID, $this->GetIDForIdent("HostStatus"), true);
             IPS_ApplyChanges($ArchiveHandlerID);
         } else {
             $ArchiveHandlerID = IPS_GetInstanceListByModuleID('{43192F0B-135B-4CE7-A0A7-1475603F3060}')[0];
             AC_SetLoggingStatus($ArchiveHandlerID, $this->GetIDForIdent("HostStatus"), false);
             IPS_ApplyChanges($ArchiveHandlerID);
         }
         //Timer erstellen
         $this->SetTimerInterval("HMON_UpdateTimer", $this->ReadPropertyInteger("Intervall"));
         $this->SetTimerByIdent_InSekunden("HMON_BenachrichtigungOfflineTimer", false);
         IPS_SetHidden($this->GetIDForIdent("HMON_BenachrichtigungOfflineTimer"), true);
         //Update
         $this->Update();
     } else {
         $this->SetStatus(206);
     }
     //Fehlerhafte Konfiguration melden
     if ($this->ReadPropertyBoolean("PushMsgAktiv") === true and $this->ReadPropertyInteger("WebFrontInstanceID") == "") {
         $this->SetStatus(201);
     }
     if ($this->ReadPropertyBoolean("EMailMsgAktiv") === true and $this->ReadPropertyInteger("SmtpInstanceID") == "") {
         $this->SetStatus(202);
     }
     if ($this->ReadPropertyBoolean("EigenesSkriptAktiv") === true and $this->ReadPropertyInteger("EigenesSkriptID") == "") {
         $this->SetStatus(203);
     }
     if ($this->ReadPropertyBoolean("PushMsgAktiv") === false and $this->ReadPropertyBoolean("EMailMsgAktiv") === false and $this->ReadPropertyBoolean("EigenesSkriptAktiv") === false and $this->ReadPropertyBoolean("OfflineBenachrichtigung") === true) {
         $this->SetStatus(204);
     }
     if ($this->ReadPropertyBoolean("OfflineBenachrichtigung") === false and $this->ReadPropertyBoolean("OnlineBenachrichtigung") === true) {
         $this->SetStatus(205);
     }
 }
Beispiel #2
0
 public function ApplyChanges()
 {
     // Diese Zeile nicht löschen
     parent::ApplyChanges();
     //Variablenprofil anlegen
     if (!IPS_VariableProfileExists("Megabyte")) {
         IPS_CreateVariableProfile("Megabyte", 2);
         IPS_SetVariableProfileValues("Megabyte", 0, 0, 2);
         IPS_SetVariableProfileText("Megabyte", "", " MB");
     }
     if ($this->ReadPropertyString("IPS_Pfad") != "" and $this->ReadPropertyString("Netzwerkkarte") != "") {
         //Variablen erstellen
         $this->RegisterVariableFloat("CPU_idle", "CPU-Auslastung", "Humidity.F", 1);
         $this->RegisterVariableFloat("CPU_volts", "CPU-Spannung", "Volt", 2);
         $this->RegisterVariableFloat("CPU_temp", "CPU-Temperatur", "Temperature", 3);
         $this->RegisterVariableFloat("HDD_total", "Gesamt Speicherplatz", "Megabyte", 4);
         $this->RegisterVariableFloat("HDD_used", "Belegter Speicherplatz", "Megabyte", 5);
         $this->RegisterVariableFloat("HDD_percent", "HDD-Belegung", "Humidity.F", 6);
         $this->RegisterVariableFloat("HDD_symcon", "IPS-Speicherbelegung", "Megabyte", 7);
         $this->RegisterVariableFloat("RAM_total", "Gesamt RAM", "Megabyte", 8);
         $this->RegisterVariableFloat("RAM_used", "Benutzer RAM", "Megabyte", 9);
         $this->RegisterVariableFloat("RAM_percent", "RAM-Auslastung", "Humidity.F", 10);
         $this->RegisterVariableString("System_Info", "System Informationen", "HTMLBox", 11);
         //Timer zeit setzen
         $this->SetTimerInterval("Update", $this->ReadPropertyInteger("UpdateInterval") * 1000);
     } else {
         //Instanz ist inaktiv
         $this->SetStatus(104);
     }
     //Variablen Logging Aktivieren / Deaktivieren
     $archiveHandlerID = IPS_GetInstanceListByModuleID('{43192F0B-135B-4CE7-A0A7-1475603F3060}')[0];
     AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("CPU_idle"), $this->ReadPropertyBoolean("logCPU_idle"));
     AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("CPU_volts"), $this->ReadPropertyBoolean("logCPU_volts"));
     AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("CPU_temp"), $this->ReadPropertyBoolean("logCPU_temp"));
     AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("HDD_total"), $this->ReadPropertyBoolean("logHDD_total"));
     AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("HDD_used"), $this->ReadPropertyBoolean("logHDD_used"));
     AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("HDD_percent"), $this->ReadPropertyBoolean("logHDD_percent"));
     AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("HDD_symcon"), $this->ReadPropertyBoolean("logHDD_symcon"));
     AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("RAM_total"), $this->ReadPropertyBoolean("logRAM_total"));
     AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("RAM_used"), $this->ReadPropertyBoolean("logRAM_used"));
     AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("RAM_percent"), $this->ReadPropertyBoolean("logRAM_percent"));
     IPS_ApplyChanges($archiveHandlerID);
     copy(IPS_GetKernelDir() . "modules/IPS_PI_Monitor/PI_Monitor/Raspi-PGB001.png", IPS_GetKernelDir() . "webfront/user/Raspi-PGB001.png");
 }
Beispiel #3
0
 private function RegisterHook($Hook, $TargetID)
 {
     $ids = IPS_GetInstanceListByModuleID("{015A6EB8-D6E5-4B93-B496-0D3F77AE9FE1}");
     if (sizeof($ids) > 0) {
         $hooks = json_decode(IPS_GetProperty($ids[0], "Hooks"), true);
         $found = false;
         foreach ($hooks as $index => $hook) {
             if ($hook['Hook'] == "/hook/locative") {
                 if ($hook['TargetID'] == $TargetID) {
                     return;
                 }
                 $hooks[$index]['TargetID'] = $TargetID;
                 $found = true;
             }
         }
         if (!$found) {
             $hooks[] = array("Hook" => "/hook/locative", "TargetID" => $TargetID);
         }
         IPS_SetProperty($ids[0], "Hooks", json_encode($hooks));
         IPS_ApplyChanges($ids[0]);
     }
 }
 public function joinZone()
 {
     $joinzonename = GetValueFormatted($this->GetIDForIdent("JoinZone"));
     if ($joinzonename != "Off") {
         $allboseinstances = IPS_GetInstanceListByModuleID("{4836EF46-FF79-4D6A-91C9-FE54F1BDF2DB}");
         foreach ($allboseinstances as $key => $value) {
             $instancename = IPS_GetName($value);
             if ($instancename == $joinzonename) {
                 $zonemasterip = IPS_GetProperty($value, "DeviceIP");
                 $zonemasterid = IPS_GetProperty($value, "DeviceID");
             }
         }
         $zonememberip = $this->ReadPropertyString("DeviceIP");
         $zonememberid = $this->ReadPropertyString("DeviceID");
         // check if masterdevice is on
         $timeout = $this->ReadPropertyString("Timeout");
         $deviceip = $zonemasterip;
         try {
             if ($timeout && Sys_Ping($deviceip, $timeout) != true) {
                 throw new Exception("Device " . $deviceip . " is not available");
             }
             include_once __DIR__ . "/bose_soundtouch_api.php";
             $bosedevice = new BoseSoundTouchAPI($deviceip);
             $result = $bosedevice->getDeviceNowPlayingAPI();
             $devicemode = $result["devicemode"];
             if ($devicemode != "Standby") {
                 $joinzone = $bosedevice->setDeviceZoneAPI($zonemasterip, $zonemasterid, $zonememberip, $zonememberid);
             } else {
                 SetValue($this->GetIDForIdent("JoinZone"), false);
             }
         } catch (Exception $e) {
             echo $e->getMessage();
         }
     }
 }
Beispiel #5
0
 /** *** WORKAROUND ***
  * SendDataToChildren
  * @param string $JSONString
  */
 protected function SendDataToChildren($JSONString)
 {
     //parent::SendDataToChildren($Data);
     include_once __DIR__ . "/../OneWireLanDevice/module.php";
     $ModuleID_r = IPS_GetInstanceListByModuleID("{21C81179-662C-46E5-BB0E-F3E18EF75637}");
     foreach ($ModuleID_r as $value) {
         $Device = new OneWireLanDevice($value);
         $Device->ReceiveData($JSONString);
     }
 }
Beispiel #6
0
 /**
  * OneWireLan_GetRomID
  * @return string
  */
 public function GetRomID()
 {
     if ($_IPS['SENDER'] != "RunScript") {
         trigger_error("Do not use this function!", E_USER_WARNING);
         return;
     }
     if ($this->ReadPropertyString("ROMId")) {
         trigger_error("ROMId is not empty!", E_USER_WARNING);
         return;
     }
     $ModuleID_r = IPS_GetInstanceListByModuleID("{21C81179-662C-46E5-BB0E-F3E18EF75637}");
     $resultat = $this->SendDataToParent(json_encode(array("DataID" => "{C7DF8BCB-7CF7-4AD9-B636-5A3DEFE4E034}", "Buffer" => "NEW")));
     if ($resultat == "") {
         trigger_error("Interface is closed!", E_USER_WARNING);
         return;
     }
     $Data = json_decode($resultat);
     switch ($this->ReadPropertyInteger("DataType")) {
         case 0:
             foreach ($Data->DS18B20 as $Key => $Value) {
                 $ROMId = $Key;
                 foreach ($ModuleID_r as $ID) {
                     if (IPS_GetProperty($ID, "ROMId") == $Key) {
                         $ROMId = "";
                     }
                 }
                 if ($ROMId != "") {
                     IPS_SetProperty($this->InstanceID, "ROMId", $ROMId);
                     IPS_ApplyChanges($this->InstanceID);
                     echo "New ROMID: " . $ROMId . " found and saved! PLEASE CLOSE THE WINDOW!";
                     return;
                 }
             }
             echo "No New ROMId for DS18B20 found!";
             return;
             break;
         case 2:
             foreach ($Data->DS18S20 as $Key => $Value) {
                 $ROMId = $Key;
                 foreach ($ModuleID_r as $ID) {
                     if (IPS_GetProperty($ID, "ROMId") == $Key) {
                         $ROMId = "";
                     }
                 }
                 if ($ROMId != "") {
                     IPS_SetProperty($this->InstanceID, "ROMId", $ROMId);
                     IPS_ApplyChanges($this->InstanceID);
                     echo "New ROMID: " . $ROMId . " found and saved! PLEASE CLOSE THE WINDOW!";
                     return;
                 }
             }
             echo "No New ROMId for DS18S20 found!";
             return;
             break;
         case 1:
             foreach ($Data->DS2438 as $Key => $Value) {
                 $ROMId = $Key;
                 foreach ($ModuleID_r as $ID) {
                     if (IPS_GetProperty($ID, "ROMId") == $Key) {
                         $ROMId = "";
                     }
                 }
                 if ($ROMId != "") {
                     IPS_SetProperty($this->InstanceID, "ROMId", $ROMId);
                     IPS_ApplyChanges($this->InstanceID);
                     echo "New ROMID: " . $ROMId . " found and saved! PLEASE CLOSE THE WINDOW!";
                     return;
                 }
             }
             echo "No New ROMId for DS2438 found!";
             return;
             break;
     }
 }
 /**
  * Forward weather data to WSDev instances
  * Create one if needed
  * @param array $data
  * @param string $caps
  */
 private function SendWSData($data, $caps)
 {
     //parsing was OK, start distributing
     $this->debug(__FUNCTION__, 'Prepare');
     $class = __CLASS__;
     $id = $data['Id'];
     $typ = $data['Typ'];
     $this->debug(__FUNCTION__, 'GetInstance for Sensor:' . $id);
     $found = false;
     $instID = 0;
     $instances = IPS_GetInstanceListByModuleID($this->module_interfaces['WSDEV']);
     foreach ($instances as $instID) {
         $I = @IPS_GetInstance($instID);
         if ($I && $I['ConnectionID'] == $this->InstanceID) {
             //my child
             $iid = (string) IPS_GetProperty($instID, 'DeviceID');
             $ityp = (string) IPS_GetProperty($instID, 'Typ');
             $iclass = (string) IPS_GetProperty($instID, 'Class');
             //$this->debug(__FUNCTION__, "Check my Device '$id'' with Instance $instID($iid)");
             if ($iid == $id && $iclass == $class && $ityp == $typ) {
                 $this->debug(__FUNCTION__, 'Use existing ID:' . $instID);
                 $found = true;
                 break;
             }
             //if destdevice
         }
         //if
     }
     //for
     if (!$found) {
         //no free instance available, have to create a new one
         if ($this->ReadPropertyBoolean('AutoCreate') == true) {
             //new instance needed
             $instID = $this->CreateWSDevice($data, $caps);
             if ($instID > 0) {
                 //new instance needed
                 $this->debug(__FUNCTION__, 'CREATE Device with Caps: ' . $caps);
                 $found = true;
             }
         } else {
             $this->debug(__FUNCTION__, 'Creating Device ID ' . $id . ' disabled by Property AutoCreate');
             IPS_LogMessage($class, 'Creating Device ID ' . $id . ' disabled by Property AutoCreate');
         }
         //if autocreate
     }
     //if found
     if ($found && $instID > 0) {
         //send record to children
         $json = json_encode(array("DataID" => $this->module_interfaces['WS-RX'], "DeviceID" => $id, "Class" => $class, "Typ" => $typ, "WSData" => $data));
         $this->debug(__FUNCTION__, $json);
         @$this->SendDataToChildren($json);
         $datum = date('Y-m-d H:i:s', time());
         $vid = @$this->GetIDForIdent('LastUpdate');
         if ($vid) {
             SetValueString($vid, $datum);
         }
         $this->log_weather($data);
     }
     //found
 }
 /**
  * Forward Energy data to EnergyDev instances
  * Create one if needed
  * @param $caps string
  * @param $data array
  */
 private function SendENData($caps, $data)
 {
     $this->debug(__FUNCTION__, 'Prepare');
     $datum = date('Y-m-d H:i:s', time());
     $data['Date'] = $datum;
     $Device = $data['Id'];
     $typ = $data['Typ'];
     $branch = $data['Branch'];
     $found = false;
     $instID = 0;
     $class = __CLASS__ . "-EN";
     $instances = IPS_GetInstanceListByModuleID($this->module_interfaces['EnergyDev']);
     foreach ($instances as $instID) {
         $I = IPS_GetInstance($instID);
         $iid = (string) IPS_GetProperty($instID, 'DeviceID');
         $ityp = (string) IPS_GetProperty($instID, 'Typ');
         $iclass = (string) IPS_GetProperty($instID, 'Class');
         //$this->debug(__FUNCTION__, "Check my Device '$Device'' with Instance $instID($iid)");
         if ($I['ConnectionID'] == $this->InstanceID) {
             //my child
             if ($iid == $Device && $iclass == $class && $ityp == $typ) {
                 $this->debug(__FUNCTION__, 'Use existing ID:' . $instID);
                 $found = true;
                 break;
             }
             //if destdevice
         }
         //if
     }
     //for
     if (!$found) {
         //no free instance available, have to create a new one
         if ($this->ReadPropertyBoolean('AutoCreate') == true) {
             //new instance needed
             $this->debug(__FUNCTION__, 'CREATE NEW Energy Device ' . $Device);
             $instID = $this->CreateEnergyDevice($data, $caps);
             $found = true;
         } else {
             $this->debug(__FUNCTION__, "Creating XS1 {$branch} Energy Device " . $Device . ' disabled by Property AutoCreate');
             IPS_LogMessage(__CLASS__, "Creating XS1 {$branch} Energy Device " . $Device . ' disabled by Property AutoCreate');
         }
         //if autocreate
     }
     //if found
     if ($found && $instID > 0) {
         //send record to children
         $json = json_encode(array("DataID" => $this->module_interfaces['EN-RX'], "DeviceID" => $Device, "Typ" => $typ, "Class" => $class, "ENData" => $data));
         $this->debug(__FUNCTION__, "Json:" . $json);
         @$this->SendDataToChildren($json);
     }
     //found
 }
 /**
  * Forward Switch data to SwitchDev instances
  * Create one if needed
  * @param array $data
  */
 private function SendSwitchData($data)
 {
     //parsing was OK, start distributing
     $this->debug(__FUNCTION__, 'Prepare');
     $class = __CLASS__ . "-SW";
     $Device = $data['DeviceID'];
     $typ = $data['Typ'];
     $found = false;
     $instID = 0;
     $caps = "Switch;Dimmer;Timer;FS20;TimerActionCode";
     $instances = IPS_GetInstanceListByModuleID($this->module_interfaces['SwitchDev']);
     foreach ($instances as $instID) {
         $I = IPS_GetInstance($instID);
         $iid = (string) IPS_GetProperty($instID, 'DeviceID');
         $ityp = (string) IPS_GetProperty($instID, 'Typ');
         $iclass = (string) IPS_GetProperty($instID, 'Class');
         $this->debug(__FUNCTION__, "Check my Device '{$Device}'' with Instance {$instID}({$iid})");
         if ($I['ConnectionID'] == $this->InstanceID) {
             //my child
             if ($iid == $Device && $iclass == $class && $ityp == $typ) {
                 $this->debug(__FUNCTION__, 'Use existing ID:' . $instID);
                 $found = true;
                 break;
             }
             //if destdevice
         }
         //if
     }
     //for
     if (!$found) {
         //no free instance available, have to create a new one
         if ($this->ReadPropertyBoolean('AutoCreate') == true) {
             //new instance needed
             $this->debug(__FUNCTION__, 'CREATE NEW Device');
             $instID = $this->CreateSwitchDevice($data, $caps);
             $found = true;
         } else {
             $this->debug(__FUNCTION__, 'Creating FS20 Device ID ' . $Device . ' disabled by Property AutoCreate');
             IPS_LogMessage($class, 'Creating FS20 Device ID ' . $Device . ' disabled by Property AutoCreate');
         }
         //if autocreate
     }
     //if found
     if ($found && $instID > 0) {
         //send record to children
         $json = json_encode(array("DataID" => $this->module_interfaces['SWD-RX'], "DeviceID" => $data['DeviceID'], "Typ" => $data['Typ'], "Class" => $class, "SWData" => $data));
         $this->debug(__FUNCTION__, $json);
         @$this->SendDataToChildren($json);
         $datum = date('Y-m-d H:i:s', time());
         $vid = @$this->GetIDForIdent('LastUpdate');
         if ($vid) {
             SetValueString($vid, $datum);
         }
     }
     //found
 }
 /**
  * Forward weather data to WSDev instances
  * Create one if needed
  * @param $weather_data
  */
 private function SendWSData($weather_data)
 {
     //parsing was OK, start distributing
     $this->debug(__FUNCTION__, 'Prepare');
     $class = __CLASS__;
     $ts = $weather_data['date'];
     $datum = date('Y-m-d H:i:s', $ts);
     foreach ($this->sensors as $Device) {
         if (!isset($weather_data[$Device])) {
             continue;
         }
         $data = array();
         $caps = '';
         $id = $weather_data[$Device]['Id'];
         $typ = $weather_data[$Device]['Typ'];
         $data['Date'] = $datum;
         foreach ($this->fieldlist as $cap) {
             if (isset($weather_data[$Device][$cap])) {
                 $data[$cap] = $weather_data[$Device][$cap];
                 $caps .= ";" . $cap;
             }
         }
         $this->debug(__FUNCTION__, "Sensor: {$id} Caps: {$caps} Prepared Data:" . print_r($data, true));
         $found = false;
         $instID = 0;
         $instances = IPS_GetInstanceListByModuleID($this->module_interfaces['WSDEV']);
         foreach ($instances as $instID) {
             $I = @IPS_GetInstance($instID);
             if ($I && $I['ConnectionID'] == $this->InstanceID) {
                 //my child
                 $iid = (string) IPS_GetProperty($instID, 'DeviceID');
                 $ityp = (string) IPS_GetProperty($instID, 'Typ');
                 $iclass = (string) IPS_GetProperty($instID, 'Class');
                 if ($iid == $Device && $ityp == $typ && $iclass == $class) {
                     $this->debug(__FUNCTION__, 'Use existing ID:' . $instID);
                     $found = true;
                     break;
                 }
                 //if destdevice
             }
             //if
         }
         //for
         if (!$found) {
             //no free instance available, have to create a new one
             if ($this->ReadPropertyBoolean('AutoCreate') == true) {
                 //new instance needed
                 $instID = $this->CreateWSDevice($data, $caps);
                 if ($instID > 0) {
                     //new instance needed
                     $this->debug(__FUNCTION__, 'CREATE Device with Caps: ' . $caps);
                     $found = true;
                 }
             } else {
                 $this->debug(__FUNCTION__, 'Creating Device ID ' . $Device . ' disabled by Property AutoCreate');
                 IPS_LogMessage($class, 'Creating Device ID ' . $Device . ' disabled by Property AutoCreate');
             }
             //if autocreate
         }
         //if found
         if ($found && $instID > 0) {
             //send record to children
             $json = json_encode(array("DataID" => $this->module_interfaces['WS-RX'], "DeviceID" => $Device, "Typ" => $typ, "Class" => $class, "WSData" => $data));
             $this->debug(__FUNCTION__, $json);
             @$this->SendDataToChildren($json);
             $this->log_weather($data);
         }
         //found
     }
     //for
     $this->debug(__FUNCTION__, 'Finished');
 }
 /**
  * Forward data to EnergyDev instances
  * Create one if needed
  * @param array $data
  * @param string $caps
  */
 private function SendEnData($data, $caps)
 {
     //parsing was OK, start distributing
     $this->debug(__FUNCTION__, 'Prepare');
     $class = $data['Class'];
     $id = $data['Id'];
     $typ = $data['Typ'];
     $found = false;
     $instID = 0;
     $instances = IPS_GetInstanceListByModuleID($this->module_interfaces['EnergyDev']);
     foreach ($instances as $instID) {
         $I = IPS_GetInstance($instID);
         $iid = (string) IPS_GetProperty($instID, 'DeviceID');
         $ityp = (string) IPS_GetProperty($instID, 'Typ');
         $iclass = (string) IPS_GetProperty($instID, 'Class');
         if ($I['ConnectionID'] == $this->InstanceID) {
             //my child
             if ($iid == $id && $iclass == $class && $ityp == $typ) {
                 $this->debug(__FUNCTION__, 'Use existing ID:' . $instID);
                 $found = true;
                 break;
             }
             //if destdevice
         }
         //if
     }
     //for
     if (!$found) {
         //no free instance available, have to create a new one
         if ($this->ReadPropertyBoolean('AutoCreate') == true) {
             //new instance needed
             $this->debug(__FUNCTION__, 'CREATE NEW Device');
             $instID = $this->CreateENDevice($data, $caps);
             $found = true;
         } else {
             $this->debug(__FUNCTION__, 'Creating Device ID ' . $id . ' disabled by Property AutoCreate');
             IPS_LogMessage($class, 'Creating Device ID ' . $id . ' disabled by Property AutoCreate');
         }
         //if autocreate
     }
     //if found
     //drop counterfactor from data
     if (isset($data['CounterFactor'])) {
         unset($data['CounterFactor']);
     }
     if ($found && $instID > 0) {
         //send record to children
         $json = json_encode(array("DataID" => $this->module_interfaces['EN-RX'], "DeviceID" => $data['Id'], "Typ" => $data['Typ'], "Class" => $class, "ENData" => $data));
         $this->debug(__FUNCTION__, $json);
         @$this->SendDataToChildren($json);
         $datum = date('Y-m-d H:i:s', time());
         $vid = @$this->GetIDForIdent('LastUpdate');
         if ($vid) {
             SetValueString($vid, $datum);
         }
     }
     //found
 }
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);
}
Beispiel #13
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();
 }
Beispiel #14
0
<?php

include_once "../modules/SymconSonos/Sonos/sonosAccess.php";
// Nothing to do if Instance is Group Coordinator
if (IPS_GetProperty(IPS_GetParent($_IPS["SELF"]), "GroupCoordinator")) {
    return;
}
$groupForcing = IPS_GetProperty(IPS_GetParent($_IPS["SELF"]), "GroupForcing");
$rinconMapping = array();
$allSonosInstances = IPS_GetInstanceListByModuleID("{F6F3A773-F685-4FD2-805E-83FD99407EE8}");
$MemberOfGroupID = @IPS_GetObjectIDByName("MemberOfGroup", IPS_GetParent($_IPS["SELF"]));
$MemberOfGroup = 0;
if ($MemberOfGroupID) {
    $MemberOfGroup = GetValueInteger($MemberOfGroupID);
}
//ensure that all rincons are known
foreach ($allSonosInstances as $key => $SonosID) {
    $rincon = IPS_GetProperty($SonosID, "RINCON");
    if (!$rincon) {
        // Get RINCON
        // Not sure why, but when executed in ApplyChanges of module.php RINCON is not alway set
        $ipAddress = IPS_GetProperty($SonosID, "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)) {
                continue;
            }
            $xmlr = new SimpleXMLElement($result);
            $rincon = str_replace("uuid:", "", $xmlr->device->UDN);
Beispiel #15
0
 /**
  * This function will be available automatically after the module is imported with the module control.
  * Using the custom prefix this function will be callable from PHP and JSON-RPC through:
  *
  * KP_RequestInfo($id);
  *
  */
 public function RequestInfo()
 {
     $locationisday = IPS_GetInstanceListByModuleID("{45E97A63-F870-408A-B259-2933F7EABF74}");
     $locationisday = IPS_GetObjectIDByName('Is Day', $locationisday[0]);
     $IsDay = $this->ReadPropertyBoolean("IsDay");
     if ($IsDay == true and GetValueBoolean($locationisday) == false) {
         return;
     } else {
         $url = $this->ReadPropertyString("url");
         $Ausgabe = file_get_contents("{$url}", "r");
         //AC-Leistung_Aktuell
         $pos1 = strpos($Ausgabe, "aktuell</td>");
         $pos2 = strpos($Ausgabe, "</td>", $pos1 + 20);
         $data = substr($Ausgabe, $pos1 + 65, $pos2 - $pos1 - 65);
         $data1 = (double) $data;
         SetValue($this->GetIDForIdent("ACLeistungAktuell"), $data1);
         //AC_Leistung_Status
         $pos1 = strpos($Ausgabe, "Status</td>");
         $pos2 = strpos($Ausgabe, "</td>", $pos1 + 20);
         $data = substr($Ausgabe, $pos1 + 33, $pos2 - $pos1 - 33);
         SetValue($this->GetIDForIdent("ACLeistungStatus"), $data);
         //Energie_Gesamtertrag
         $pos1 = strpos($Ausgabe, "Gesamtenergie</td>");
         $pos2 = strpos($Ausgabe, "</td>", $pos1 + 30);
         $data = substr($Ausgabe, $pos1 + 70, $pos2 - $pos1 - 70);
         $data1 = (double) $data;
         SetValue($this->GetIDForIdent("Gesamtertrag"), $data1);
         //Energie_Tagesertrag_Aktuell
         $pos1 = strpos($Ausgabe, "Tagesenergie</td>");
         $pos2 = strpos($Ausgabe, "</td>", $pos1 + 20);
         $data = substr($Ausgabe, $pos1 + 70, $pos2 - $pos1 - 70);
         $data1 = (double) $data;
         SetValue($this->GetIDForIdent("Tagesertrag"), $data1);
         //PV_Generator_String1_Spannung
         $pos1 = strpos($Ausgabe, "Spannung</td>", $pos2);
         $pos2 = strpos($Ausgabe, "</td>", $pos1 + 20);
         $data = substr($Ausgabe, $pos1 + 66, $pos2 - $pos1 - 66);
         $data1 = (double) $data;
         SetValue($this->GetIDForIdent("SpannungString1"), $data1);
         //Ausgangsleistung_L1_Spannung
         $pos1 = strpos($Ausgabe, "Spannung</td>", $pos2);
         $pos2 = strpos($Ausgabe, "</td>", $pos1 + 20);
         $data = substr($Ausgabe, $pos1 + 66, $pos2 - $pos1 - 66);
         $data1 = (double) $data;
         SetValue($this->GetIDForIdent("L1Spannung"), $data1);
         //PV_Generator_String1_Strom
         $pos1 = strpos($Ausgabe, "Strom</td>", $pos2);
         $pos2 = strpos($Ausgabe, "</td>", $pos1 + 20);
         $data = substr($Ausgabe, $pos1 + 63, $pos2 - $pos1 - 63);
         $data1 = (double) $data;
         SetValue($this->GetIDForIdent("StromString1"), $data1);
         //Ausgangsleistung_L1_Leistung
         $pos1 = strpos($Ausgabe, "Leistung</td>", $pos2);
         $pos2 = strpos($Ausgabe, "</td>", $pos1 + 20);
         $data = substr($Ausgabe, $pos1 + 66, $pos2 - $pos1 - 66);
         $data1 = (double) $data;
         SetValue($this->GetIDForIdent("L1Leistung"), $data1);
         //PV_Generator_String2_Spannung
         $pos1 = strpos($Ausgabe, "Spannung</td>", $pos2);
         $pos2 = strpos($Ausgabe, "</td>", $pos1 + 20);
         $data = substr($Ausgabe, $pos1 + 66, $pos2 - $pos1 - 66);
         $data1 = (double) $data;
         SetValue($this->GetIDForIdent("SpannungString2"), $data1);
         //Ausgangsleistung_L2_Spannung
         $pos1 = strpos($Ausgabe, "Spannung</td>", $pos2);
         $pos2 = strpos($Ausgabe, "</td>", $pos1 + 20);
         $data = substr($Ausgabe, $pos1 + 66, $pos2 - $pos1 - 66);
         $data1 = (double) $data;
         SetValue($this->GetIDForIdent("L2Spannung"), $data1);
         //PV_Generator_String2_Strom
         $pos1 = strpos($Ausgabe, "Strom</td>", $pos2);
         $pos2 = strpos($Ausgabe, "</td>", $pos1 + 20);
         $data = substr($Ausgabe, $pos1 + 63, $pos2 - $pos1 - 63);
         $data1 = (double) $data;
         SetValue($this->GetIDForIdent("StromString2"), $data1);
         //Ausgangsleistung_L2_Leistung
         $pos1 = strpos($Ausgabe, "Leistung</td>", $pos2);
         $pos2 = strpos($Ausgabe, "</td>", $pos1 + 20);
         $data = substr($Ausgabe, $pos1 + 66, $pos2 - $pos1 - 66);
         $data1 = (double) $data;
         SetValue($this->GetIDForIdent("L2Leistung"), $data1);
         //PV_Generator_String3_Spannung
         $pos1 = strpos($Ausgabe, "Spannung</td>", $pos2);
         $pos2 = strpos($Ausgabe, "</td>", $pos1 + 20);
         $data = substr($Ausgabe, $pos1 + 66, $pos2 - $pos1 - 66);
         $data1 = (double) $data;
         SetValue($this->GetIDForIdent("SpannungString3"), $data1);
         //Ausgangsleistung_L3_Spannung
         $pos1 = strpos($Ausgabe, "Spannung</td>", $pos2);
         $pos2 = strpos($Ausgabe, "</td>", $pos1 + 20);
         $data = substr($Ausgabe, $pos1 + 66, $pos2 - $pos1 - 66);
         $data1 = (double) $data;
         SetValue($this->GetIDForIdent("L3Spannung"), $data1);
         //PV_Generator_String3_Strom
         $pos1 = strpos($Ausgabe, "Strom</td>", $pos2);
         $pos2 = strpos($Ausgabe, "</td>", $pos1 + 20);
         $data = substr($Ausgabe, $pos1 + 63, $pos2 - $pos1 - 63);
         $data1 = (double) $data;
         SetValue($this->GetIDForIdent("StromString3"), $data1);
         //Ausgangsleistung_L3_Leistung
         $pos1 = strpos($Ausgabe, "Leistung</td>", $pos2);
         $pos2 = strpos($Ausgabe, "</td>", $pos1 + 20);
         $data = substr($Ausgabe, $pos1 + 66, $pos2 - $pos1 - 66);
         $data1 = (double) $data;
         SetValue($this->GetIDForIdent("L3Leistung"), $data1);
     }
 }
Beispiel #16
0
 /** *** WORKAROUND ***
  * SendDataToChildren
  * @param string $JSONString
  */
 protected function SendDataToChildren($JSONString)
 {
     //parent::SendDataToChildren($Data);
     include_once __DIR__ . "/../ModbusMasterDevice/module.php";
     $ModuleID_r = IPS_GetInstanceListByModuleID("{3BD8FD26-AFAC-49D4-A9F0-15DE90A41D26}");
     foreach ($ModuleID_r as $value) {
         $Device = new ModBusMasterDevice($value);
         $Device->ReceiveData($JSONString);
     }
 }
Beispiel #17
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
 }
Beispiel #18
0
 private function ReadBatteryStates()
 {
     $InstanzIDsListAll[] = IPS_GetInstanceListByModuleID("{A89F8DFA-A439-4BF1-B7CB-43D047208DDD}");
     // FHT
     $InstanzIDsListAll[] = IPS_GetInstanceListByModuleID("{2FD7576A-D2AD-47EE-9779-A502F23CABB3}");
     // FS20 HMS
     $InstanzIDsListAll[] = IPS_GetInstanceListByModuleID("{EE4A81C6-5C90-4DB7-AD2F-F6BBD521412E}");
     // HomeMatic
     $InstanzIDsListAll[] = IPS_GetInstanceListByModuleID("{101352E1-88C7-4F16-998B-E20D50779AF6}");
     // Z-Wave
     $a = 0;
     $l = 0;
     foreach ($InstanzIDsListAll as $InstanzIDsList) {
         foreach ($InstanzIDsList as $InstanzID) {
             $InstanzHersteller = IPS_GetInstance($InstanzID);
             $InstanzHersteller = $InstanzHersteller["ModuleInfo"]["ModuleName"];
             switch ($InstanzHersteller) {
                 case "FHT":
                     $InstanzHersteller = "FHT";
                     break;
                 case "HMS":
                     $InstanzHersteller = "HMS";
                     break;
                 case "HomeMatic Device":
                     $InstanzHersteller = "HomeMatic";
                     break;
                 case "Z-Wave Module":
                     $InstanzHersteller = "Z-Wave";
                     break;
             }
             //FHT
             $VarID = @IPS_GetObjectIDByIdent('LowBatteryVar', $InstanzID);
             if ($VarID !== false and $InstanzHersteller == "FHT") {
                 $Var = IPS_GetVariable($VarID);
                 $VarLastUpdated = $Var["VariableUpdated"];
                 $VarLastUpdatedDiffSek = time() - $VarLastUpdated;
                 $DeviceID = IPS_GetProperty($InstanzID, "Address");
                 $LowBat = GetValueBoolean($VarID);
                 if ($LowBat === true) {
                     $Batterien_AR["Alle"][$a]["Name"] = $this->Umlaute_Ersetzen(IPS_GetName($InstanzID));
                     if ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr1NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle1TB"));
                         $Batterien_AR["Alle"][$a][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     if ($this->ReadPropertyBoolean("NamenParentObjekt2CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr2NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle2TB"));
                         $Batterien_AR["Alle"][$a][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     if ($this->ReadPropertyBoolean("NamenParentObjekt3CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr3NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle3TB"));
                         $Batterien_AR["Alle"][$a][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     $Batterien_AR["Alle"][$a]["Batterie"] = "LEER";
                     $Batterien_AR["Alle"][$a]["Hersteller"] = $InstanzHersteller;
                     $Batterien_AR["Alle"][$a]["ID"] = $DeviceID;
                     $Batterien_AR["Alle"][$a]["Hersteller_ID"] = $InstanzHersteller . " - " . $DeviceID;
                     $Batterien_AR["Alle"][$a]["LetztesVarUpdateTimestamp"] = $VarLastUpdated;
                     $Batterien_AR["Alle"][$a]["LetztesVarUpdateVorSek"] = $VarLastUpdatedDiffSek;
                     $Batterien_AR["Leer"][$l]["Name"] = $this->Umlaute_Ersetzen(IPS_GetName($InstanzID));
                     if ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr1NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle1TB"));
                         $Batterien_AR["Leer"][$l][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     if ($this->ReadPropertyBoolean("NamenParentObjekt2CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr2NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle2TB"));
                         $Batterien_AR["Leer"][$l][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     if ($this->ReadPropertyBoolean("NamenParentObjekt3CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr3NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle3TB"));
                         $Batterien_AR["Leer"][$l][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     $Batterien_AR["Leer"][$l]["Batterie"] = "LEER";
                     $Batterien_AR["Leer"][$l]["Hersteller"] = $InstanzHersteller;
                     $Batterien_AR["Leer"][$l]["ID"] = $DeviceID;
                     $Batterien_AR["Leer"][$l]["Hersteller_ID"] = $InstanzHersteller . " - " . $DeviceID;
                     $Batterien_AR["Leer"][$l]["LetztesVarUpdateTimestamp"] = $VarLastUpdated;
                     $Batterien_AR["Leer"][$l]["LetztesVarUpdateVorSek"] = $VarLastUpdatedDiffSek;
                     $a++;
                     $l++;
                 } else {
                     $Batterien_AR["Alle"][$a]["Name"] = $this->Umlaute_Ersetzen(IPS_GetName($InstanzID));
                     if ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr1NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle1TB"));
                         $Batterien_AR["Alle"][$a][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     if ($this->ReadPropertyBoolean("NamenParentObjekt2CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr2NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle2TB"));
                         $Batterien_AR["Alle"][$a][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     if ($this->ReadPropertyBoolean("NamenParentObjekt3CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr3NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle3TB"));
                         $Batterien_AR["Alle"][$a][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     $Batterien_AR["Alle"][$a]["Batterie"] = "OK";
                     $Batterien_AR["Alle"][$a]["Hersteller"] = $InstanzHersteller;
                     $Batterien_AR["Alle"][$a]["ID"] = $DeviceID;
                     $Batterien_AR["Alle"][$a]["Hersteller_ID"] = $InstanzHersteller . " - " . $DeviceID;
                     $Batterien_AR["Alle"][$a]["LetztesVarUpdateTimestamp"] = $VarLastUpdated;
                     $Batterien_AR["Alle"][$a]["LetztesVarUpdateVorSek"] = $VarLastUpdatedDiffSek;
                     $a++;
                 }
             }
             //FS20 HMS
             $VarID = @IPS_GetObjectIDByIdent('LowBatteryVar', $InstanzID);
             if ($VarID !== false and $InstanzHersteller == "HMS") {
                 $Var = IPS_GetVariable($VarID);
                 $VarLastUpdated = $Var["VariableUpdated"];
                 $VarLastUpdatedDiffSek = time() - $VarLastUpdated;
                 $DeviceID = IPS_GetProperty($InstanzID, "DeviceID");
                 $LowBat = GetValueBoolean($VarID);
                 if ($LowBat === true) {
                     $Batterien_AR["Alle"][$a]["Name"] = $this->Umlaute_Ersetzen(IPS_GetName($InstanzID));
                     if ($this->ReadPropertyBoolean("NamenParentObjekt") == true) {
                         if ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == true) {
                             $ParentID = $this->ParentIDermitteln("ParentNr1NS", $InstanzID);
                             $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle1TB"));
                             $Batterien_AR["Alle"][$a][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                         }
                     }
                     if ($this->ReadPropertyBoolean("NamenParentObjekt2CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr2NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle2TB"));
                         $Batterien_AR["Alle"][$a][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     if ($this->ReadPropertyBoolean("NamenParentObjekt3CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr3NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle3TB"));
                         $Batterien_AR["Alle"][$a][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     $Batterien_AR["Alle"][$a]["Batterie"] = "LEER";
                     $Batterien_AR["Alle"][$a]["Hersteller"] = $InstanzHersteller;
                     $Batterien_AR["Alle"][$a]["ID"] = $DeviceID;
                     $Batterien_AR["Alle"][$a]["Hersteller_ID"] = $InstanzHersteller . " - " . $DeviceID;
                     $Batterien_AR["Alle"][$a]["LetztesVarUpdateTimestamp"] = $VarLastUpdated;
                     $Batterien_AR["Alle"][$a]["LetztesVarUpdateVorSek"] = $VarLastUpdatedDiffSek;
                     $Batterien_AR["Leer"][$l]["Name"] = $this->Umlaute_Ersetzen(IPS_GetName($InstanzID));
                     if ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr1NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle1TB"));
                         $Batterien_AR["Leer"][$l][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     if ($this->ReadPropertyBoolean("NamenParentObjekt2CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr2NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle2TB"));
                         $Batterien_AR["Leer"][$l][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     if ($this->ReadPropertyBoolean("NamenParentObjekt3CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr3NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle3TB"));
                         $Batterien_AR["Leer"][$l][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     $Batterien_AR["Leer"][$l]["Batterie"] = "LEER";
                     $Batterien_AR["Leer"][$l]["Hersteller"] = $InstanzHersteller;
                     $Batterien_AR["Leer"][$l]["ID"] = $DeviceID;
                     $Batterien_AR["Leer"][$l]["Hersteller_ID"] = $InstanzHersteller . " - " . $DeviceID;
                     $Batterien_AR["Leer"][$l]["LetztesVarUpdateTimestamp"] = $VarLastUpdated;
                     $Batterien_AR["Leer"][$l]["LetztesVarUpdateVorSek"] = $VarLastUpdatedDiffSek;
                     $a++;
                     $l++;
                 } else {
                     $Batterien_AR["Alle"][$a]["Name"] = $this->Umlaute_Ersetzen(IPS_GetName($InstanzID));
                     if ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr1NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle1TB"));
                         $Batterien_AR["Alle"][$a][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     if ($this->ReadPropertyBoolean("NamenParentObjekt2CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr2NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle2TB"));
                         $Batterien_AR["Alle"][$a][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     if ($this->ReadPropertyBoolean("NamenParentObjekt3CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr3NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle3TB"));
                         $Batterien_AR["Alle"][$a][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     $Batterien_AR["Alle"][$a]["Batterie"] = "OK";
                     $Batterien_AR["Alle"][$a]["Hersteller"] = $InstanzHersteller;
                     $Batterien_AR["Alle"][$a]["ID"] = $DeviceID;
                     $Batterien_AR["Alle"][$a]["Hersteller_ID"] = $InstanzHersteller . " - " . $DeviceID;
                     $Batterien_AR["Alle"][$a]["LetztesVarUpdateTimestamp"] = $VarLastUpdated;
                     $Batterien_AR["Alle"][$a]["LetztesVarUpdateVorSek"] = $VarLastUpdatedDiffSek;
                     $a++;
                 }
             }
             //HomeMatic
             $VarID = @IPS_GetObjectIDByIdent('LOWBAT', $InstanzID);
             if ($VarID !== false and $InstanzHersteller == "HomeMatic") {
                 $Var = IPS_GetVariable($VarID);
                 $VarLastUpdated = $Var["VariableUpdated"];
                 $VarLastUpdatedDiffSek = time() - $VarLastUpdated;
                 $DeviceID = substr(IPS_GetProperty($InstanzID, "Address"), 0, -2);
                 $LowBat = GetValueBoolean($VarID);
                 if ($LowBat === true) {
                     $Batterien_AR["Alle"][$a]["Name"] = $this->Umlaute_Ersetzen(IPS_GetName($InstanzID));
                     if ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr1NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle1TB"));
                         $Batterien_AR["Alle"][$a][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     if ($this->ReadPropertyBoolean("NamenParentObjekt2CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr2NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle2TB"));
                         $Batterien_AR["Alle"][$a][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     if ($this->ReadPropertyBoolean("NamenParentObjekt3CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr3NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle3TB"));
                         $Batterien_AR["Alle"][$a][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     $Batterien_AR["Alle"][$a]["Batterie"] = "LEER";
                     $Batterien_AR["Alle"][$a]["Hersteller"] = $InstanzHersteller;
                     $Batterien_AR["Alle"][$a]["ID"] = $DeviceID;
                     $Batterien_AR["Alle"][$a]["Hersteller_ID"] = $InstanzHersteller . " - " . $DeviceID;
                     $Batterien_AR["Alle"][$a]["LetztesVarUpdateTimestamp"] = $VarLastUpdated;
                     $Batterien_AR["Alle"][$a]["LetztesVarUpdateVorSek"] = $VarLastUpdatedDiffSek;
                     $Batterien_AR["Leer"][$l]["Name"] = $this->Umlaute_Ersetzen(IPS_GetName($InstanzID));
                     if ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr1NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle1TB"));
                         $Batterien_AR["Leer"][$l][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     if ($this->ReadPropertyBoolean("NamenParentObjekt2CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr2NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle2TB"));
                         $Batterien_AR["Leer"][$l][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     if ($this->ReadPropertyBoolean("NamenParentObjekt3CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr3NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle3TB"));
                         $Batterien_AR["Leer"][$l][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     $Batterien_AR["Leer"][$l]["Batterie"] = "LEER";
                     $Batterien_AR["Leer"][$l]["Hersteller"] = $InstanzHersteller;
                     $Batterien_AR["Leer"][$l]["ID"] = $DeviceID;
                     $Batterien_AR["Leer"][$l]["Hersteller_ID"] = $InstanzHersteller . " - " . $DeviceID;
                     $Batterien_AR["Leer"][$l]["LetztesVarUpdateTimestamp"] = $VarLastUpdated;
                     $Batterien_AR["Leer"][$l]["LetztesVarUpdateVorSek"] = $VarLastUpdatedDiffSek;
                     $a++;
                     $l++;
                 } else {
                     $Batterien_AR["Alle"][$a]["Name"] = $this->Umlaute_Ersetzen(IPS_GetName($InstanzID));
                     if ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr1NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle1TB"));
                         $Batterien_AR["Alle"][$a][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     if ($this->ReadPropertyBoolean("NamenParentObjekt2CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr2NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle2TB"));
                         $Batterien_AR["Alle"][$a][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     if ($this->ReadPropertyBoolean("NamenParentObjekt3CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr3NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle3TB"));
                         $Batterien_AR["Alle"][$a][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     $Batterien_AR["Alle"][$a]["Batterie"] = "OK";
                     $Batterien_AR["Alle"][$a]["Hersteller"] = $InstanzHersteller;
                     $Batterien_AR["Alle"][$a]["ID"] = $DeviceID;
                     $Batterien_AR["Alle"][$a]["Hersteller_ID"] = $InstanzHersteller . " - " . $DeviceID;
                     $Batterien_AR["Alle"][$a]["LetztesVarUpdateTimestamp"] = $VarLastUpdated;
                     $Batterien_AR["Alle"][$a]["LetztesVarUpdateVorSek"] = $VarLastUpdatedDiffSek;
                     $a++;
                 }
             }
             //Z-Wave
             $VarID = @IPS_GetObjectIDByIdent('BatteryLowVariable', $InstanzID);
             if ($VarID !== false and $InstanzHersteller == "Z-Wave") {
                 $Var = IPS_GetVariable($VarID);
                 $VarLastUpdated = $Var["VariableUpdated"];
                 $VarLastUpdatedDiffSek = time() - $VarLastUpdated;
                 $DeviceID = IPS_GetProperty($InstanzID, "NodeID");
                 $LowBat = GetValueBoolean($VarID);
                 if ($LowBat === true) {
                     $Batterien_AR["Alle"][$a]["Name"] = $this->Umlaute_Ersetzen(IPS_GetName($InstanzID));
                     if ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr1NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle1TB"));
                         $Batterien_AR["Alle"][$a][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     if ($this->ReadPropertyBoolean("NamenParentObjekt2CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr2NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle2TB"));
                         $Batterien_AR["Alle"][$a][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     if ($this->ReadPropertyBoolean("NamenParentObjekt3CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr3NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle3TB"));
                         $Batterien_AR["Alle"][$a][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     $Batterien_AR["Alle"][$a]["Batterie"] = "LEER";
                     $Batterien_AR["Alle"][$a]["Hersteller"] = $InstanzHersteller;
                     $Batterien_AR["Alle"][$a]["ID"] = $DeviceID;
                     $Batterien_AR["Alle"][$a]["Hersteller_ID"] = $InstanzHersteller . " - " . $DeviceID;
                     $Batterien_AR["Alle"][$a]["LetztesVarUpdateTimestamp"] = $VarLastUpdated;
                     $Batterien_AR["Alle"][$a]["LetztesVarUpdateVorSek"] = $VarLastUpdatedDiffSek;
                     $Batterien_AR["Leer"][$l]["Name"] = $this->Umlaute_Ersetzen(IPS_GetName($InstanzID));
                     if ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr1NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle1TB"));
                         $Batterien_AR["Leer"][$l][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     if ($this->ReadPropertyBoolean("NamenParentObjekt2CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr2NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle3TB"));
                         $Batterien_AR["Leer"][$l][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     if ($this->ReadPropertyBoolean("NamenParentObjekt3CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr3NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle3TB"));
                         $Batterien_AR["Leer"][$l][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     $Batterien_AR["Leer"][$l]["Batterie"] = "LEER";
                     $Batterien_AR["Leer"][$l]["Hersteller"] = $InstanzHersteller;
                     $Batterien_AR["Leer"][$l]["ID"] = $DeviceID;
                     $Batterien_AR["Leer"][$l]["Hersteller_ID"] = $InstanzHersteller . " - " . $DeviceID;
                     $Batterien_AR["Leer"][$l]["LetztesVarUpdateTimestamp"] = $VarLastUpdated;
                     $Batterien_AR["Leer"][$l]["LetztesVarUpdateVorSek"] = $VarLastUpdatedDiffSek;
                     $a++;
                     $l++;
                 } else {
                     $Batterien_AR["Alle"][$a]["Name"] = $this->Umlaute_Ersetzen(IPS_GetName($InstanzID));
                     if ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr1NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle1TB"));
                         $Batterien_AR["Alle"][$a][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     if ($this->ReadPropertyBoolean("NamenParentObjekt2CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr2NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle2TB"));
                         $Batterien_AR["Alle"][$a][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     if ($this->ReadPropertyBoolean("NamenParentObjekt3CB") == true) {
                         $ParentID = $this->ParentIDermitteln("ParentNr3NS", $InstanzID);
                         $ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabell3TB"));
                         $Batterien_AR["Alle"][$a][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
                     }
                     $Batterien_AR["Alle"][$a]["Batterie"] = "OK";
                     $Batterien_AR["Alle"][$a]["Hersteller"] = $InstanzHersteller;
                     $Batterien_AR["Alle"][$a]["ID"] = $DeviceID;
                     $Batterien_AR["Alle"][$a]["Hersteller_ID"] = $InstanzHersteller . " - " . $DeviceID;
                     $Batterien_AR["Alle"][$a]["LetztesVarUpdateTimestamp"] = $VarLastUpdated;
                     $Batterien_AR["Alle"][$a]["LetztesVarUpdateVorSek"] = $VarLastUpdatedDiffSek;
                     $a++;
                 }
             }
         }
     }
     if (isset($Batterien_AR)) {
         //Array sortieren, doppelte Einträge entfernen und neu durchnummerieren
         foreach ($Batterien_AR["Alle"] as $nr => $inhalt) {
             $nameALLE[$nr] = strtolower($inhalt["Name"]);
             if ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == true) {
                 $nameParent1ALLE[$nr] = $this->Umlaute_Ersetzen(strtolower($inhalt[$this->ReadPropertyString("NameParentTabelle1TB")]));
             }
             if ($this->ReadPropertyBoolean("NamenParentObjekt2CB") == true) {
                 $nameParent2ALLE[$nr] = $this->Umlaute_Ersetzen(strtolower($inhalt[$this->ReadPropertyString("NameParentTabelle2TB")]));
             }
             if ($this->ReadPropertyBoolean("NamenParentObjekt3CB") == true) {
                 $nameParent3ALLE[$nr] = $this->Umlaute_Ersetzen(strtolower($inhalt[$this->ReadPropertyString("NameParentTabelle3TB")]));
             }
             $batterieALLE[$nr] = strtolower($inhalt["Batterie"]);
             $herstellerALLE[$nr] = strtolower($inhalt["Hersteller"]);
             $idALLE[$nr] = strtolower($inhalt["ID"]);
             $herstelleridALLE[$nr] = strtolower($inhalt["Hersteller_ID"]);
             $lastupdatetsALLE[$nr] = strtolower($inhalt["LetztesVarUpdateTimestamp"]);
             $lastupdatevsALLE[$nr] = strtolower($inhalt["LetztesVarUpdateVorSek"]);
         }
         //Nach was soll das Array sortiert werden?
         if ($this->ReadPropertyString("ArraySortierWert") == "name") {
             array_multisort($nameALLE, SORT_ASC, $Batterien_AR["Alle"]);
         } elseif ($this->ReadPropertyString("ArraySortierWert") == "parentname1") {
             if ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == true) {
                 array_multisort($nameParent1ALLE, SORT_ASC, $Batterien_AR["Alle"]);
             } else {
                 array_multisort($nameALLE, SORT_ASC, $Batterien_AR["Alle"]);
             }
         } elseif ($this->ReadPropertyString("ArraySortierWert") == "parentname2") {
             if ($this->ReadPropertyBoolean("NamenParentObjekt2CB") == true) {
                 array_multisort($nameParent2ALLE, SORT_ASC, $Batterien_AR["Alle"]);
             } else {
                 array_multisort($nameALLE, SORT_ASC, $Batterien_AR["Alle"]);
             }
         } elseif ($this->ReadPropertyString("ArraySortierWert") == "parentname3") {
             if ($this->ReadPropertyBoolean("NamenParentObjekt3CB") == true) {
                 array_multisort($nameParent3ALLE, SORT_ASC, $Batterien_AR["Alle"]);
             } else {
                 array_multisort($nameALLE, SORT_ASC, $Batterien_AR["Alle"]);
             }
         } elseif ($this->ReadPropertyString("ArraySortierWert") == "batterie") {
             array_multisort($batterieALLE, SORT_ASC, $Batterien_AR["Alle"]);
         } elseif ($this->ReadPropertyString("ArraySortierWert") == "hersteller") {
             array_multisort($herstellerALLE, SORT_ASC, $Batterien_AR["Alle"]);
         } elseif ($this->ReadPropertyString("ArraySortierWert") == "id") {
             array_multisort($idALLE, SORT_ASC, $Batterien_AR["Alle"]);
         } elseif ($this->ReadPropertyString("ArraySortierWert") == "letztesupdts") {
             array_multisort($lastupdatetsALLE, SORT_ASC, $Batterien_AR["Alle"]);
         }
         $Batterien_AR["Alle"] = $this->Array_UniqueBySubitem_Sort($Batterien_AR["Alle"], "Hersteller_ID");
         $Batterien_AR["Alle"] = array_merge($Batterien_AR["Alle"]);
         if (isset($Batterien_AR["Leer"])) {
             foreach ($Batterien_AR["Leer"] as $nr => $inhalt) {
                 $nameLEER[$nr] = strtolower($inhalt["Name"]);
                 if ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == true) {
                     $nameParent1LEER[$nr] = $this->Umlaute_Ersetzen(strtolower($inhalt[$this->ReadPropertyString("NameParentTabelle1TB")]));
                 }
                 if ($this->ReadPropertyBoolean("NamenParentObjekt2CB") == true) {
                     $nameParent2LEER[$nr] = $this->Umlaute_Ersetzen(strtolower($inhalt[$this->ReadPropertyString("NameParentTabelle2TB")]));
                 }
                 if ($this->ReadPropertyBoolean("NamenParentObjekt3CB") == true) {
                     $nameParent3LEER[$nr] = $this->Umlaute_Ersetzen(strtolower($inhalt[$this->ReadPropertyString("NameParentTabelle3TB")]));
                 }
                 $batterieLEER[$nr] = strtolower($inhalt["Batterie"]);
                 $herstellerLEER[$nr] = strtolower($inhalt["Hersteller"]);
                 $idLEER[$nr] = strtolower($inhalt["ID"]);
                 $herstelleridLEER[$nr] = strtolower($inhalt["Hersteller_ID"]);
                 $lastupdatetsLEER[$nr] = strtolower($inhalt["LetztesVarUpdateTimestamp"]);
                 $lastupdatevsLEER[$nr] = strtolower($inhalt["LetztesVarUpdateVorSek"]);
             }
             //Nach was soll das Array sortiert werden?
             if ($this->ReadPropertyString("ArraySortierWert") == "name") {
                 array_multisort($nameLEER, SORT_ASC, $Batterien_AR["Leer"]);
             } elseif ($this->ReadPropertyString("ArraySortierWert") == "parentname1") {
                 if ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == true) {
                     array_multisort($nameParent1LEER, SORT_ASC, $Batterien_AR["Leer"]);
                 } else {
                     array_multisort($nameLEER, SORT_ASC, $Batterien_AR["Leer"]);
                 }
             } elseif ($this->ReadPropertyString("ArraySortierWert") == "parentname2") {
                 if ($this->ReadPropertyBoolean("NamenParentObjekt2CB") == true) {
                     array_multisort($nameParent2LEER, SORT_ASC, $Batterien_AR["Leer"]);
                 } else {
                     array_multisort($nameLEER, SORT_ASC, $Batterien_AR["Leer"]);
                 }
             } elseif ($this->ReadPropertyString("ArraySortierWert") == "parentname3") {
                 if ($this->ReadPropertyBoolean("NamenParentObjekt3CB") == true) {
                     array_multisort($nameParent3LEER, SORT_ASC, $Batterien_AR["Leer"]);
                 } else {
                     array_multisort($nameLEER, SORT_ASC, $Batterien_AR["Leer"]);
                 }
             } elseif ($this->ReadPropertyString("ArraySortierWert") == "batterie") {
                 array_multisort($batterieLEER, SORT_ASC, $Batterien_AR["Leer"]);
             } elseif ($this->ReadPropertyString("ArraySortierWert") == "hersteller") {
                 array_multisort($herstellerLEER, SORT_ASC, $Batterien_AR["Leer"]);
             } elseif ($this->ReadPropertyString("ArraySortierWert") == "id") {
                 array_multisort($idLEER, SORT_ASC, $Batterien_AR["Leer"]);
             } elseif ($this->ReadPropertyString("ArraySortierWert") == "letztesupdts") {
                 array_multisort($lastupdatetsLEER, SORT_ASC, $Batterien_AR["Leer"]);
             }
             $Batterien_AR["Leer"] = $this->Array_UniqueBySubitem_Sort($Batterien_AR["Leer"], "Hersteller_ID");
             $Batterien_AR["Leer"] = array_merge($Batterien_AR["Leer"]);
         }
         return $Batterien_AR;
     } else {
         return false;
     }
 }
Beispiel #19
0
 private function getDeviceAddress($deviceName)
 {
     $ret = IPS_GetInstanceListByModuleID("{44D8BE09-743E-484F-A64D-154C4235BE94}");
     $DeviceURL = "";
     $AccessToken = "";
     $retArray = "";
     $SecChannelExp = 0;
     if ($ret == null) {
         echo "Error: ips4WinDeviceRegistration is not implemented! Please create a new instance of ips4WinDeviceRegistration!\n";
     } else {
         if (count($ret) > 1) {
             echo "Error: multiple ips4WinDeviceRegistration found, unsupported installation! Please make sure you have only one instance of ips4WinDeviceRegistration!\n";
         } else {
             $id = $ret[0];
             $objList = IPS_GetChildrenIDs($id);
             //print_r($objList);
             $i = count($objList);
             for ($j = 0; $j < $i; $j++) {
                 $vid = @IPS_GetObjectIDByName("deviceName", $objList[$j]);
                 if ($vid !== false) {
                     if ($deviceName == null) {
                         $device = GetValueString($vid);
                         $vid = @IPS_GetObjectIDByName("SecChannel", $objList[$j]);
                         if ($vid !== false) {
                             $DeviceURL = GetValueString($vid);
                         }
                         $vid = @IPS_GetObjectIDByName("AccessToken", $objList[$j]);
                         if ($vid !== false) {
                             $AccessToken = GetValueString($vid);
                         }
                         $vid = @IPS_GetObjectIDByName("SecChannelExp", $objList[$j]);
                         if ($vid !== false) {
                             $SecChannelExp = GetValueInteger($vid);
                         }
                         if ($retArray == "") {
                             $retArray[0] = explode("###", $device . "###" . $DeviceURL . "###" . $AccessToken . "###" . $SecChannelExp);
                         } else {
                             $retArray[count($retArray)] = explode("###", $device . "###" . $DeviceURL . "###" . $AccessToken . "###" . $SecChannelExp);
                         }
                         $DeviceURL = "";
                         $AccessToken = "";
                         $SecChannelExp = 0;
                     } else {
                         if (strtolower($deviceName) == strtolower(GetValueString($vid))) {
                             $vid = @IPS_GetObjectIDByName("SecChannel", $objList[$j]);
                             if ($vid !== false) {
                                 $DeviceURL = GetValueString($vid);
                             }
                             $vid = @IPS_GetObjectIDByName("AccessToken", $objList[$j]);
                             if ($vid !== false) {
                                 $AccessToken = GetValueString($vid);
                             }
                             $vid = @IPS_GetObjectIDByName("SecChannelExp", $objList[$j]);
                             if ($vid !== false) {
                                 $SecChannelExp = GetValueInteger($vid);
                             }
                             $retArray = array(explode("###", $deviceName . "###" . $DeviceURL . "###" . $AccessToken . "###" . $SecChannelExp));
                             $j = $i;
                         }
                     }
                 }
             }
         }
     }
     return $retArray;
 }
Beispiel #20
0
 public function GetDeviceByUniqueId($uniqueId) {
   $deviceIds = IPS_GetInstanceListByModuleID($this->DeviceGuid());
   foreach($deviceIds as $deviceId) {
     if(IPS_GetProperty($deviceId, 'UniqueId') == $uniqueId) {
       return $deviceId;
     }
   }
 }
 /**
  * Forward data to EnergyDev instances
  * Create one if needed
  * @param $data
  */
 private function SendENData($data)
 {
     //parsing was OK, start distributing
     $this->debug(__FUNCTION__, 'Prepare ' . print_r($data, true));
     $class = __CLASS__;
     if (!isset($data['Id']) || !isset($data['Typ'])) {
         IPS_LogMessage($class, 'Missing Data Id or Typ');
         return;
     }
     $id = $data['Id'];
     $typ = $data['Typ'];
     $caps = '';
     foreach ($this->fieldlist as $cap) {
         if (isset($data[$cap])) {
             $caps .= ";" . $cap;
         }
     }
     $caps = substr($caps, 1);
     $this->debug(__FUNCTION__, "USV {$id} Caps: {$caps} ");
     $found = false;
     $instID = 0;
     $instances = IPS_GetInstanceListByModuleID($this->module_interfaces['EnergyDev']);
     foreach ($instances as $instID) {
         $I = @IPS_GetInstance($instID);
         if ($I && $I['ConnectionID'] == $this->InstanceID) {
             //my child
             $iid = (string) IPS_GetProperty($instID, 'DeviceID');
             $ityp = (string) IPS_GetProperty($instID, 'Typ');
             $iclass = (string) IPS_GetProperty($instID, 'Class');
             if ($iid == $id && $ityp == $typ && $iclass == $class) {
                 $this->debug(__FUNCTION__, 'Use existing ID:' . $instID);
                 $found = true;
                 break;
             }
             //if destdevice
         }
         //if
     }
     //for
     if (!$found) {
         //no free instance available, have to create a new one
         if ($this->ReadPropertyBoolean('AutoCreate') == true) {
             //new instance needed
             $instID = $this->CreateENDevice($data, $caps);
             if ($instID > 0) {
                 //new instance needed
                 $this->debug(__FUNCTION__, 'CREATE Device with Caps: ' . $caps);
                 $found = true;
             }
         } else {
             $this->debug(__FUNCTION__, 'Creating Device ID ' . $id . ' disabled by Property AutoCreate');
             IPS_LogMessage($class, 'Creating Device ID ' . $id . ' disabled by Property AutoCreate');
         }
         //if autocreate
     }
     //if found
     if ($found && $instID > 0) {
         //send record to children
         $json = json_encode(array("DataID" => $this->module_interfaces['EN-RX'], "DeviceID" => $id, "Typ" => $typ, "Class" => $class, "ENData" => $data));
         $this->debug(__FUNCTION__, $json);
         @$this->SendDataToChildren($json);
         $this->log_data($data);
     }
     //found
     $this->debug(__FUNCTION__, 'Finished');
 }
 /**
  * Forward weather data to WSDev instances
  * Create one if needed
  * @param $weather_data
  */
 private function SendWSData($weather_data)
 {
     //parsing was OK, start distributing
     $this->debug(__FUNCTION__, 'Prepare ');
     //$this->debug(__FUNCTION__, 'Data:'. print_r($weather_data, true));
     $dt = $weather_data['date'];
     $datum = date('Y-m-d H:i:s', $dt);
     for ($Device = 0; $Device < self::MAXSENSORS; $Device++) {
         if (!$weather_data['records'][$Device]['typ']) {
             continue;
         }
         $data = array();
         $id = $weather_data['records'][$Device]['id'];
         $typ = $weather_data['records'][$Device]['typ'];
         //$sensor=$weather_data['records'][$Device]['sensor'];
         $temp = $weather_data['records'][$Device]['temp'];
         $hum = $weather_data['records'][$Device]['hum'];
         $data['Id'] = $id;
         $data['Typ'] = $typ;
         $data['Date'] = $datum;
         $caps = "Temp";
         $data['Temp'] = $temp;
         if ($typ == 'T/F') {
             $data['Hum'] = $hum;
             $caps .= ";Hum";
         }
         if ($Device < 9) {
             //innensensor hat keinenbatteryanzeige
             $lost = $weather_data['records'][$Device]['lost'];
             $bat = $weather_data['records'][$Device]['battery'];
             $data["Battery"] = $bat;
             $data["Lost"] = $lost;
             $caps .= ";Battery;Lost";
         }
         if ($Device == 8) {
             $rain = $weather_data['rain'];
             $rainc = $weather_data['rainc'];
             $israining = $weather_data['israining'];
             $wind = $weather_data['wind'];
             $typ = 'Kombisensor';
             $data['Typ'] = $typ;
             $data['Rain'] = $rain;
             $data['RainCounter'] = $rainc;
             $data['IsRaining'] = $israining;
             $data['Wind'] = $wind;
             $caps .= ";Wind;Rain;IsRaining;RainCounter";
         }
         if ($Device == 9) {
             $typ = 'Indoor';
             $press = $weather_data['press'];
             $willi = $weather_data['willi'];
             $data['Typ'] = $typ;
             $data["Press"] = $press;
             $data['Forecast'] = $willi;
             $caps .= ";Hum;Press;Forecast";
         }
         if (strlen($temp) == 0) {
             continue;
             //nothing to send
         }
         //if temp
         //$this->debug(__FUNCTION__, "Sensor:  $id Caps: $caps Data:" . print_r($data, true));
         $found = false;
         $instID = 0;
         $instances = IPS_GetInstanceListByModuleID($this->module_interfaces['WSDEV']);
         foreach ($instances as $instID) {
             $I = @IPS_GetInstance($instID);
             if ($I && $I['ConnectionID'] == $this->InstanceID) {
                 //my child
                 $iid = (string) IPS_GetProperty($instID, 'DeviceID');
                 $ityp = (string) IPS_GetProperty($instID, 'Typ');
                 $class = (string) IPS_GetProperty($instID, 'Class');
                 if ($iid == $Device && $ityp == $typ && $class == __CLASS__) {
                     $this->debug(__FUNCTION__, 'Use existing ID:' . $instID);
                     $found = true;
                     break;
                 }
                 //if destdevice
             }
             //if
         }
         //for
         if (!$found) {
             //no free instance available, have to create a new one
             if ($this->ReadPropertyBoolean('AutoCreate') == true) {
                 //new instance needed
                 $instID = $this->CreateWSDevice($data, $caps);
                 if ($instID > 0) {
                     //new instance needed
                     $this->debug(__FUNCTION__, 'CREATE Device with Caps: ' . $caps);
                     $found = true;
                 }
             } else {
                 $this->debug(__FUNCTION__, 'Creating Device ID ' . $Device . ' disabled by Property AutoCreate');
                 IPS_LogMessage(__CLASS__, 'Creating Device ID ' . $Device . ' disabled by Property AutoCreate');
             }
             //if autocreate
         }
         //if found
         if ($found && $instID > 0) {
             //send record to children
             $json = json_encode(array("DataID" => $this->module_interfaces['WS-RX'], "DeviceID" => $Device, "Typ" => $typ, "Class" => __CLASS__, "WSData" => $data));
             $this->debug(__FUNCTION__, $json);
             @$this->SendDataToChildren($json);
         }
         //found
     }
     //for
     $this->debug(__FUNCTION__, 'Finished');
     $vid = $this->GetIDForIdent('LastUpdate');
     SetValueString($vid, $datum);
 }
    $GewerkCat = GetOrCreateCategoryByName(0, "Gewerke");
} else {
    $parent = @IPS_GetObject($GewerkCat);
    if ($parent === false) {
        die("Manuelle Angabe der ID für Gewerke nicht vorhanden!");
    }
}
if ($ScriptCat == 0) {
    $ScriptCat = GetOrCreateCategoryByName(0, "Aktions-Scripte");
} else {
    $parent = @IPS_GetObject($ScriptCat);
    if ($parent === false) {
        die("Manuelle Angabe der ID für Scripte nicht vorhanden!");
    }
}
$HMDevices = IPS_GetInstanceListByModuleID("{EE4A81C6-5C90-4DB7-AD2F-F6BBD521412E}");
$HMAdresses = array();
foreach ($HMDevices as $HMDevice) {
    $HMAdresses[] = IPS_GetProperty($HMDevice, "Address");
}
foreach ($HMCcuAddress as $Key) {
    $HMParent = $HMSockets[$Key];
    if (IPS_GetInstance($HMParent)['InstanceStatus'] != 102) {
        if (IPS_GetInstance($HMParent)['InstanceStatus'] >= 200) {
            if (@IPS_ApplyChanges($HMSocket) === false) {
                echo "Homematic-Socket (" . IPS_GetName($HMParent) . ") mit der InstanzID " . $HMParent . " konnte nicht reaktiviert werden." . PHP_EOL;
            }
        }
        if (IPS_GetInstance($HMParent)['InstanceStatus'] != 102) {
            echo "Homematic-Socket (" . IPS_GetName($HMParent) . ") mit der InstanzID " . $HMParent . " ist nicht aktiv." . PHP_EOL;
            echo "  Überspinge alle Geräte dieser CCU" . PHP_EOL;
Beispiel #24
0
 private function UpdateInfo()
 {
     $ret = "";
     $ModulInstanzID = IPS_GetInstanceListByModuleID("{B8A5067A-AFC2-3798-FEDC-BCD02A45615E}")[0];
     // Nach Updates für alle Module suchen (bis auf die Ausnahmen)
     $result = MC_GetModuleList($ModulInstanzID);
     foreach ($result as $Modulname) {
         if (in_array($Modulname, $this->EigenerModulName) === true) {
             $ModulInfoAR = @MC_GetModuleRepositoryInfo($ModulInstanzID, $Modulname);
             if ($ModulInfoAR["ModuleLocalCommit"] != $ModulInfoAR["ModuleRemoteCommit"]) {
                 $ret = "Eine neue Version ist verf&uumlgbar";
                 IPS_LogMessage("ownCloud-Modul", "Eine neue Version ist verfügbar!");
                 $this->Logging("Eine neue Version ist verfügbar!");
                 $this->SetValueBoolean("NeuesUpdate", true);
             } else {
                 $this->SetValueBoolean("NeuesUpdate", false);
             }
         }
     }
     return $ret;
 }