protected function SetValueString($Ident, $Value) { $ID = $this->GetIDForIdent($Ident); if (GetValueString($ID) != $Value) { SetValueString($ID, strval($Value)); return true; } return false; }
private function SetValueString($Ident, $value) { $id = $this->GetIDForIdent($Ident); if (GetValueString($id) != $value) { SetValueString($id, $value); return true; } return false; }
public function ReadService() { $serviceData = $this->request('/web/subservices'); if ($serviceData) { $serviceName = utf8_decode((string)$serviceData->e2service->e2servicename); $serviceReference = utf8_decode((string)$serviceData->e2service->e2servicereference); if ($serviceName == 'N/A') $serviceName = ''; if ($serviceReference == 'N/A') $serviceReference = ''; SetValueString($this->GetIDForIdent('SERVICE_REFERENCE'), $serviceReference); SetValueString($this->GetIDForIdent('SERVICE_NAME'), $serviceName); } }
function SetVariable($VarID, $Type, $Value) { switch ($Type) { case 0: // boolean SetValueBoolean($VarID, $Value); break; case 1: // integer SetValueInteger($VarID, $Value); break; case 2: // float SetValueFloat($VarID, $Value); break; case 3: // string SetValueString($VarID, $Value); break; } }
public function ReceiveData($JSONString) { $data = json_decode($JSONString); IPS_LogMessage('Logamatic <- Gateway:', bin2hex(utf8_decode($data->Buffer))); $monitorID = $this->GetIDForIdent('Monitordaten'); $EinstellParID = $this->GetIDForIdent('EinstellPar'); $stream = bin2hex(utf8_decode($data->Buffer)); $datentyp = substr($stream, 0, 2); $bus = substr($stream, 4, 2); $modultyp = substr($stream, 8, 2); switch ($datentyp) { case 'a5': // A5 Statusmeldung IPS_LogMessage('Buderus Logamatic', 'ECO-CAN Adresse ' . $bus . ' is alive'); return true; case 'a7': // A7 Monitordaten Normalmodus IPS_LogMessage('Buderus Logamatic', 'Monitordaten ECO-CAN Adresse ' . $bus . ' Normalmodus :' . $stream); EncodeMonitorNormalData($stream, $this->InstanceID, chr($this->ReadPropertyString('Bus'))); break; case 'a9': // A9 Kennung für einstellbare Parameter $head = GetValueString($EinstellParID); $EinstellPar = $head . $stream; SetValueString($EinstellParID, $EinstellPar); break; case 'aa': // AA Einstellbare Parameter komplett übertragen IPS_LogMessage('Buderus Logamatic', 'Einstellbare Parameter ECO-CAN Adresse ' . $bus . ' komplett :' . strlen(GetValueString($EinstellParID)) . ' Bytes'); EncodeEinstellParData(GetValueString($EinstellParID), $this->InstanceID, chr($this->ReadPropertyString('Bus'))); $data = chr(Command::Normalmodus) . chr($this->ReadPropertyString('Bus')) . chr(Command::NUL) . chr(Command::NUL); $this->SendDataToParent($data); // Umschalten in Normalmodus senden break; case 'ab': // AB Monitordaten Direktmodus $head = GetValueString($monitorID); $Monitordaten = $head . $stream; SetValueString($monitorID, $Monitordaten); break; case 'ac': // AC Monitordaten komplett übertragen //$monitordaten = GetValueString($monitorID); IPS_LogMessage('Buderus Logamatic:', 'Monitordaten ECO-CAN Adresse ' . $bus . ' komplett :' . strlen(GetValueString($monitorID)) . ' Bytes\\n'); EncodeMonitorDirektData(GetValueString($monitorID), $this->InstanceID, chr($this->ReadPropertyString('Bus'))); $data = chr(Command::Normalmodus) . chr($this->ReadPropertyString('Bus')) . chr(Command::NUL) . chr(Command::NUL); $this->SendDataToParent($data); // Umschalten in Normalmodus senden break; case 'ad': // AD Datenblock empfangen IPS_LogMessage('Buderus Logamatic', 'Datenblock ' . $stream); break; } $stream = ''; return true; }
/** * 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 }
public function SetGroup($groupCoordinator) { if ($this->ReadPropertyBoolean("GroupCoordinator")) { return; } $ip = $this->ReadPropertyString("IPAddress"); $timeout = $this->ReadPropertyString("TimeOut"); if ($timeout && Sys_Ping($ip, $timeout) != true) { throw new Exception("Sonos Box " . $ip . " is not available"); } // get variable of coordinator members to be updated if ($groupCoordinator) { $groupMembersID = @IPS_GetObjectIDByIdent("GroupMembers", $groupCoordinator); $uri = "x-rincon:" . IPS_GetProperty($groupCoordinator, "RINCON"); } else { $groupMembersID = @IPS_GetObjectIDByIdent("GroupMembers", GetValue($this->GetIDForIdent("MemberOfGroup"))); $uri = ""; } // update coordinator members SetValue($this->GetIDForIdent("MemberOfGroup"), $groupCoordinator); if ($groupMembersID) { $currentMembers = explode(",", GetValueString($groupMembersID)); $currentMembers = array_filter($currentMembers, function ($v) { return $v != ""; }); $currentMembers = array_filter($currentMembers, function ($v) { return $v != $this->InstanceID; }); if ($groupCoordinator) { $currentMembers[] = $this->InstanceID; } SetValueString($groupMembersID, implode(",", $currentMembers)); } // Set relevant variables to hidden/unhidden if ($groupCoordinator) { $hidden = true; } else { $hidden = false; } IPS_SetHidden($this->GetIDForIdent("nowPlaying"), $hidden); IPS_SetHidden($this->GetIDForIdent("Radio"), $hidden); IPS_SetHidden($this->GetIDForIdent("Playlist"), $hidden); IPS_SetHidden($this->GetIDForIdent("Status"), $hidden); IPS_SetHidden($this->GetIDForIdent("Sleeptimer"), $hidden); include_once __DIR__ . "/sonosAccess.php"; (new SonosAccess($ip))->SetAVTransportURI($uri); }
private function WaitForResponse($APIData_Command) { $ReplyAPIDataID = $this->GetIDForIdent('ReplyAPIData'); for ($i = 0; $i < 300; $i++) { if (GetValueString($ReplyAPIDataID) === '') { IPS_Sleep(5); } else { if ($this->lock('ReplyAPIData')) { $ret = GetValueString($ReplyAPIDataID); SetValueString($ReplyAPIDataID, ''); $this->unlock('ReplyAPIData'); $JSON = json_decode($ret); $APIData = new ISCP_API_Data(); $APIData->GetDataFromJSONObject($JSON); if ($APIData_Command == $APIData->APICommand) { return $APIData; } else { $i = $i - 100; if ($i < 0) { $i = 0; } } } } } if ($this->lock('ReplyAPIData')) { SetValueString($ReplyAPIDataID, ''); $this->unlock('ReplyAPIData'); } return false; }
/** * 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); }
/** * 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 }
/** * parsing incoming data along capabilities * @param array $data */ private function ParseData($data) { // $caps = $this->GetCaps(); //$this->debug(__FUNCTION__,print_r($this->all_caps,true)); foreach (array_keys($caps) as $cap) { $ident = $caps[$cap]; $vid = @$this->GetIDForIdent($ident); if ($vid == 0) { $this->debug(__FUNCTION__, "Cap {$cap} Ident {$ident}: Variable missed"); continue; } if (!isset($data[$cap])) { continue; } $s = $data[$cap]; switch ($cap) { //Integer case 'Hum': //hum //hum case 'RainCounter': //raincounter //raincounter case 'Press': //pressure //pressure case 'Forecast': //willi //willi case 'UV': //UVIndex //UVIndex case 'Light': //Brightness //Brightness case 'Level': //level //level case 'TS': //TimeStamp //TimeStamp case 'Lost': //lost //lost case 'Signal': if (strlen($s) == 0) { continue; } $iv = (int) $s; SetValueInteger($vid, $iv); break; //float //float case 'Temp': //temp //temp case 'Wind': //wind //wind case 'WindChill': //wind //wind case 'WindGust': //wind //wind case 'WindDir': //wind //wind case 'Rain': //rain //rain case 'RainDaily': //rain this day //rain this day case 'RainHourly': //rain 1h //rain 1h case 'RainLastDay': //rain 24h if (strlen($s) == 0) { continue; } $fv = (double) $s; SetValueFloat($vid, $fv); break; //String //String case 'Name': // $st = utf8_decode($s); SetValueString($vid, $st); break; //special //special case 'IsRaining': //israining if ($s == 'YES') { SetValueBoolean($vid, true); $s = "Its Raining"; } else { SetValueBoolean($vid, false); $s = "{$cap}({$vid}): No Rain"; } break; //special //special case 'Storm': //israining if ($s == 'YES') { //is reversed SetValueBoolean($vid, false); $s = "Its Storm"; } else { SetValueBoolean($vid, true); $s = "OK"; } break; case 'Battery': //battery $state = !preg_match("/LOW|WARN/i", $s); //reversed SetValueBoolean($vid, $state); break; default: $this->debug(__FUNCTION__, "{$cap} not handled"); } $this->debug(__FUNCTION__, "{$cap}:({$vid})" . $s); } }
function EncodeMonitorNormalData($Monitordaten, $ID, $Bus) { $Bus = 1; $array = str_split($Monitordaten, 24); for ($x = 0; $x < count($array); $x++) { if (substr($array[$x], 0, 2) == 'a7') { $typ = ord(hex2bin(substr($array[$x], 8, 2))); if ($Bus === ord(hex2bin(substr($array[$x], 4, 2)))) { IPS_LogMessage('Buderus Logamatic', 'ECO-CAN Adresse ' . $Bus . ' Array: ' . $array[$x]); $offset = ord(hex2bin(substr($array[$x], 12, 2))); $substring = substr($array[$x], 16, 2); IPS_LogMessage('Buderus Logamatic', 'ECO-CAN Adresse ' . $Bus . ' Data: ' . $typ . ' : ' . $offset . ' : ' . $substring); $var = CheckVariable($typ, -1, 0, $ID); $value = GetValueString($var); $newvalue = substr_replace($value, $substring, $offset * 2, 2); SetValueString($var, $newvalue); EncodeVariableData($ID, $typ); } else { IPS_LogMessage('Logamatic Gateway', 'EncodeMonitorNormalData für falsche Bus-Adresse'); } } } return true; }
private function SetValueString($Ident, $value) { $id = $this->GetIDForIdent($Ident); if (GetValueString($id) != $value) { SetValueString($id, $value); } }
protected function SetValueString($Ident, $value) { $id = $this->GetIDForIdent($Ident); SetValueString($id, $value); }
public function ProcessData() { $error = false; $Content = ""; //CommandList processing $CommandListString = ""; if ($this->Debug) { echo "working on CommandList..."; } foreach ($this->CommandList as $key => $value) { $temp = implode("#=#", $value); if (strlen($CommandListString) > 0) { $CommandListString = $CommandListString . "#+#" . $key . "#-#" . $temp; } else { $CommandListString = $key . "#-#" . $temp; } if (!isset($this->FeedbackList[$key])) { echo "Error, missing Feedback entry for Command '" . $key . "'\n"; $error = true; } if (!isset($this->ExampleList[$key])) { echo "Error, missing Example entry for Command '" . $key . "'\n"; $error = true; } } //echo "CommandListString:".$CommandListString."\n"; if ($this->Debug) { echo "processed!\n"; } //FeedbackList processiong $FeedbackListString = ""; if ($this->Debug) { echo "working on FeedbackList..."; } foreach ($this->FeedbackList as $key => $value) { if (strlen($FeedbackListString) > 0) { $FeedbackListString = $FeedbackListString . "#+#" . $key . "#-#" . $value; } else { $FeedbackListString = $key . "#-#" . $value; } } if ($this->Debug) { echo "...processed!\n"; } //ExampleList processiong $ExampleListString = ""; if ($this->Debug) { echo "working on ExampleListString..."; } foreach ($this->ExampleList as $key => $value) { if (strlen($ExampleListString) > 0) { $ExampleListString = $ExampleListString . "#+#" . $key . "#-#" . $value; } else { $ExampleListString = $key . "#-#" . $value; } } if ($this->Debug) { echo "processed!\n"; } //PhraseList processing $PhraseListString = ""; if ($this->Debug) { echo "working on PhraseList..."; } foreach ($this->PhraseList as $key => $value) { $temp = implode("#=#", $value); if (strlen($PhraseListString) > 0) { $PhraseListString = $PhraseListString . "#+#" . $key . "#-#" . $temp; } else { $PhraseListString = $key . "#-#" . $temp; } } if ($this->Debug) { echo "processed!\n"; } if ($error) { SetValueString($this->id, ""); echo "Error while processing data - nothing written!\n"; } else { $Content = $CommandListString . "#*#" . $FeedbackListString . "#*#" . $ExampleListString . "#*#" . $PhraseListString; $Content = $this->convertForOutput($Content); SetValueString($this->InstanceID, $Content); echo "Data successful written\n"; if (IPS_ModuleExists("{44D8BE09-743E-484F-A64D-154C4235BE94}")) { ips4WNS_sendRawNotification(0, null, "ips4Windows#CortanaRefresh"); } } }
/** * 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 }
protected function DoUser($ModulID, $data) { $Tage = array("Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"); $Vorname = $data['firstname']; $Nachname = $data['lastname']; $Name = $Vorname . " " . $Nachname; $Geschlecht = $data['gender']; $Geburtstag = date('d.m.Y', $data['birthdate']); $Tag = $Tage[date("w", $data['birthdate'])]; $Geburtstag = $Tag . " " . $Geburtstag; $id = @IPS_GetVariableIDByName("Name", $ModulID); if ($id > 0) { $v = GetValueString($id); if ($v != $Name) { SetValueString($id, $Name); } } $id = @IPS_GetVariableIDByName("Geburtstag", $ModulID); if ($id > 0) { $v = GetValueString($id); if ($v != $Geburtstag) { SetValueString($id, $Geburtstag); } } $id = @IPS_GetVariableIDByName("Geschlecht", $ModulID); if ($id > 0) { $v = GetValueInteger($id); if ($v != $Geschlecht) { SetValueInteger($id, $Geschlecht); } } }
/** * handle incoming data along capabilities * @param array $data */ private function ParseData($data) { // $this->debug(__FUNCTION__, 'Parse'); $caps = $this->GetCaps(); foreach (array_keys($caps) as $cap) { $ident = $caps[$cap]; $vid = @$this->GetIDForIdent($ident); if ($vid == 0) { $this->debug(__FUNCTION__, "Cap {$cap} Ident {$ident}: Variable missed"); continue; } if (!isset($data[$cap])) { continue; } $s = $data[$cap]; $this->debug(__FUNCTION__, "Handle {$cap} ({$vid}) = {$s}"); switch ($cap) { //boolean types case 'Alert': //Status $state = $s != 'YES'; //reversed display SetValueBoolean($vid, $state); break; //Counter types with factor //Counter types with factor case 'Counter': $iv = (int) $s; switch ($this->GetType()) { case 'EMWZ': $last = GetValueInteger($vid); $opid = $this->GetIDForIdent('OCounter'); if ($opid) { $offset = GetValueInteger($opid); if ($last > $iv) { $offset += 65535; $this->debug(__FUNCTION__, "EMWZ:Increase Offset by 65535: {$offset}"); SetValueInteger($opid, $offset); } $iv = $iv + $offset; } else { $this->debug(__FUNCTION__, "EMWZ:No vid for OCounter"); } $pvid = $this->GetIDForIdent('TPower'); if ($pvid) { $factor = $this->GetCounterFactor(); if ($factor == 0) { $factor = 150; } $val = $iv * (1 / $factor); //counter%ticks pro kw SetValueFloat($pvid, $val); $this->debug(__FUNCTION__, "EMWZ:TPower:({$pvid})=" . $val . "F:{$factor}(" . $this->GetCounterFactor() . ")"); } else { $this->debug(__FUNCTION__, "EMWZ:No vid for TPower"); } break; case 'EMEM': $last = GetValueInteger($vid); $opid = $this->GetIDForIdent('OCounter'); if ($opid) { $offset = GetValueInteger($opid); if ($last > $iv) { $offset += 65535; $this->debug(__FUNCTION__, "EMEM:Increase Offset by 65535: {$offset}"); SetValueInteger($opid, $offset); } $iv = $iv + $offset; } else { $this->debug(__FUNCTION__, "EMEM:No vid for OCounter"); } $pvid = $this->GetIDForIdent('TPower'); if ($pvid) { $factor = $this->GetCounterFactor(); if ($factor == 0) { $factor = 100; } $val = $iv * (1 / $factor); //counter%ticks pro kw SetValueFloat($pvid, $val); $this->debug(__FUNCTION__, "EMEM:TPower:({$pvid})=" . $val . "F:{$factor}(" . $this->GetCounterFactor() . ")"); } else { $this->debug(__FUNCTION__, "EMEM:No vid for TPower"); } break; case 'EMGZ': $pvid = $this->GetIDForIdent('TGas'); if ($pvid) { $factor = $this->GetCounterFactor(); if ($factor == 0) { $factor = 100; } $val = $iv * (1 / $factor); //Counter%ticks pro m3 SetValueFloat($pvid, $val); $this->debug(__FUNCTION__, "EMGZ:TGas:({$pvid})=" . $val . "F:{$factor}(" . $this->GetCounterFactor() . ")"); } else { $this->debug(__FUNCTION__, "EMGZ:No vid for TGas"); } break; } SetValueInteger($vid, $iv); break; case 'ACounter': $iv = (int) $s; switch ($this->GetType()) { case 'EMWZ': $pvid = $this->GetIDForIdent('APower'); if ($pvid) { $factor = $this->GetCounterFactor(); if ($factor == 0) { $factor = 150; } $val = $iv * (1 / $factor) * 1000; //W statt KW SetValueFloat($pvid, $val); $this->debug(__FUNCTION__, "EMWZ:APower:({$pvid})=" . $val . "F:{$factor}(" . $this->GetCounterFactor() . ")"); } else { $this->debug(__FUNCTION__, "EMWZ:No vid for APower"); } break; case 'EMEM': $pvid = $this->GetIDForIdent('APower'); if ($pvid) { $factor = $this->GetCounterFactor(); if ($factor == 0) { $factor = 100; } $val = $iv * (1 / $factor) * 1000; //W statt KW SetValueFloat($pvid, $val); $this->debug(__FUNCTION__, "EMEM:APower:({$pvid})=" . $val . "F:{$factor}(" . $this->GetCounterFactor() . ")"); } else { $this->debug(__FUNCTION__, "EMEM:No vid for APower"); } break; case 'EMGZ': $pvid = $this->GetIDForIdent('AGas'); if ($pvid) { $factor = $this->GetCounterFactor(); if ($factor == 0) { $factor = 100; } $val = $iv * (1 / $factor); //m3 SetValueFloat($pvid, $val); $this->debug(__FUNCTION__, "EMGZ:AGas:({$pvid})=" . $val . " F:{$factor}(" . $this->GetCounterFactor() . ")"); } else { $this->debug(__FUNCTION__, "EMGZ:No vid for AGas"); } break; } SetValueInteger($vid, $iv); break; case 'PCounter': $iv = (int) $s; switch ($this->GetType()) { case 'EMWZ': $pvid = $this->GetIDForIdent('PPower'); if ($pvid) { $factor = $this->GetCounterFactor(); if ($factor == 0) { $factor = 150; } $val = $iv * (1 / $factor) * 1000; //W statt KW SetValueFloat($pvid, $val); $this->debug(__FUNCTION__, "EMWZ:PPower:({$pvid})=" . $val . "F:{$factor}(" . $this->GetCounterFactor() . ")"); } else { $this->debug(__FUNCTION__, "EMWZ:No vid for PPower"); } break; case 'EMEM': $pvid = $this->GetIDForIdent('PPower'); if ($pvid) { $factor = $this->GetCounterFactor(); if ($factor == 0) { $factor = 100; } $val = $iv * (1 / $factor) * 1000; //W statt KW SetValueFloat($pvid, $val); $this->debug(__FUNCTION__, "EMEM:PPower:({$pvid})=" . $val . " F:{$factor}(" . $this->GetCounterFactor() . ")"); } else { $this->debug(__FUNCTION__, "EMEM:No vid for PPower"); } break; case 'EMGZ': $pvid = $this->GetIDForIdent('PGas'); if ($pvid) { $factor = $this->GetCounterFactor(); if ($factor == 0) { $factor = 100; } $val = $iv * (1 / $factor); //m3 SetValueFloat($pvid, $val); $this->debug(__FUNCTION__, "EMGZ:PGas:({$pvid})=" . $val . " F:{$factor}(" . $this->GetCounterFactor() . ")"); } else { $this->debug(__FUNCTION__, "EMGZ:No vid for PGas"); } break; } SetValueInteger($vid, $iv); break; //int types //int types case 'Signal': //RSSI //RSSI case 'LoadPct': //Load in Pct //Load in Pct case 'Charged': //Charged in Pct //Charged in Pct case 'OCounter': //old counter //old counter case 'TS': //Timestamp $iv = (int) $s; SetValueInteger($vid, $iv); break; //float types with factor //float types with factor case 'AGas': //Actual //Actual case 'TGas': //Total //Total case 'PGas': //Peak //Peak case 'APower': //Actual //Actual case 'PPower': //Peak //Peak case 'TPower': //Total //Total case 'AWater': //Actual //Actual case 'TWater': //Total //Total case 'PWater': //Peak $fv = (double) $s; $factor = $this->GetCounterFactor(); $val = $fv * $factor; SetValueFloat($vid, $val); break; //float types //float types case 'VoltIn': //InputVolt //InputVolt case 'VoltOut': //Output Volt //Output Volt case 'Nominal': //Nominal Power //Nominal Power case 'Watt': //Absolute Load //Absolute Load case 'Freq': //Frequency //Frequency case 'TimeLeft': //TimeLeft $fv = (double) $s; SetValueFloat($vid, $fv); break; //string types //string types case 'Name': case 'Status': $st = utf8_decode($s); SetValueString($vid, $st); break; default: $this->debug(__FUNCTION__, "{$cap} not handled"); } //switch $this->debug(__FUNCTION__, "{$cap}:({$vid})=" . $s); } //for }
public function ReceiveData($JSONString) { $data = json_decode($JSONString); //IPS_LogMessage('ReceiveDataFrom???:'.$this->InstanceID, print_r($data,1)); $this->CheckParents(); if ($this->Mode === false) { trigger_error("Wrong IO-Parent", E_USER_WARNING); // echo "Wrong IO-Parent"; return false; } $bufferID = $this->GetIDForIdent("BufferIN"); // Empfangs Lock setzen if (!$this->lock("ReceiveLock")) { trigger_error("ReceiveBuffer is locked", E_USER_NOTICE); return false; // throw new Exception("ReceiveBuffer is locked",E_USER_NOTICE); } // Datenstream zusammenfügen $head = GetValueString($bufferID); SetValueString($bufferID, ''); // Stream in einzelne Pakete schneiden $stream = $head . utf8_decode($data->Buffer); if ($this->Mode == ISCPSplitter::LAN) { $minTail = 24; $start = strpos($stream, 'ISCP'); if ($start === false) { IPS_LogMessage('ISCP Gateway', 'LANFrame without ISCP'); $stream = ''; } elseif ($start > 0) { IPS_LogMessage('ISCP Gateway', 'LANFrame start not with ISCP'); $stream = substr($stream, $start); } //Paket suchen if (strlen($stream) < $minTail) { IPS_LogMessage('ISCP Gateway', 'LANFrame to short'); SetValueString($bufferID, $stream); $this->unlock("ReceiveLock"); return; } $header_len = ord($stream[6]) * 256 + ord($stream[7]); $frame_len = ord($stream[10]) * 256 + ord($stream[11]); // IPS_LogMessage('ISCP Gateway', 'LANFrame info ' . $header_len. '+'. $frame_len . ' Bytes.'); if (strlen($stream) < $header_len + $frame_len) { IPS_LogMessage('ISCP Gateway', 'LANFrame must have ' . $header_len . '+' . $frame_len . ' Bytes. ' . strlen($stream) . ' Bytes given.'); SetValueString($bufferID, $stream); $this->unlock("ReceiveLock"); return; } $header = substr($stream, 0, $header_len); $frame = substr($stream, $header_len, $frame_len); //EOT wegschneiden von reschts, aber nur wenn es einer der letzten drei zeichen ist $end = strrpos($frame, chr(0x1a)); if ($end >= $frame_len - 3) { $frame = substr($frame, 0, $end); } //EOT wegschneiden von reschts, aber nur wenn es einer der letzten drei zeichen ist $end = strrpos($frame, chr(0xd)); if ($end >= $frame_len - 3) { $frame = substr($frame, 0, $end); } //EOT wegschneiden von reschts, aber nur wenn es einer der letzten drei zeichen ist $end = strrpos($frame, chr(0xa)); if ($end >= $frame_len - 3) { $frame = substr($frame, 0, $end); } // IPS_LogMessage('ISCP Gateway', 'LAN $header:' . $header); // IPS_LogMessage('ISCP Gateway', 'LAN $frame:' . $frame); // 49 53 43 50 // ISCP // 00 00 00 10 // HEADERLEN // 00 00 00 0B // DATALEN // 01 00 00 00 // Version // 21 31 4E 4C // !1NL // 53 43 2D 50 // SC-P // 1A 0D 0A // EOT CR LF $tail = substr($stream, $header_len + $frame_len); if ($this->eISCPVersion != ord($header[12])) { $frame = false; trigger_error("Wrong eISCP Version", E_USER_NOTICE); } } else { $minTail = 6; $start = strpos($stream, '!'); if ($start === false) { IPS_LogMessage('ISCP Gateway', 'eISCP Frame without !'); $stream = ''; } elseif ($start > 0) { IPS_LogMessage('ISCP Gateway', 'eISCP Frame do not start with !'); $stream = substr($stream, $start); } //Paket suchen $end = strpos($stream, chr(0x1a)); if ($end === false or strlen($stream) < $minTail) { IPS_LogMessage('ISCP Gateway', 'eISCP Frame to short'); SetValueString($bufferID, $stream); $this->unlock("ReceiveLock"); return; } $frame = substr($stream, $start, $end - $start); // Ende wieder in den Buffer werfen $tail = ltrim(substr($stream, $end)); } if ($tail === false) { $tail = ''; } SetValueString($bufferID, $tail); $this->unlock("ReceiveLock"); if ($frame !== false) { $this->DecodeData($frame); } // Ende war länger als 6 / 23 ? Dann nochmal Packet suchen. if (strlen($tail) >= $minTail) { $this->ReceiveData(json_encode(array('Buffer' => ''))); } return true; }
/** * handle incoming data along capabilities * @param array $data */ private function ParseData($data) { // $caps = $this->GetCaps(); //$this->debug(__FUNCTION__,print_r($this->all_caps,true)); foreach (array_keys($caps) as $cap) { $ident = $caps[$cap]; $vid = @$this->GetIDForIdent($ident); if ($vid == 0) { $this->debug(__FUNCTION__, "Cap {$cap} Ident {$ident}: Variable missed"); continue; } if (!isset($data[$cap])) { continue; } $s = $data[$cap]; switch ($cap) { //integer case 'TS': //Timestamp //Timestamp case 'Signal': //RSSI //RSSI case 'Timer': //Duration code //Duration code case 'Dimmer': //intensity 100% //intensity 100% case 'Shutter': //intensity 100% $iv = (int) $s; SetValueInteger($vid, $iv); break; //String //String case 'Name': //Duration code $st = utf8_decode($s); SetValueString($vid, $st); break; //special //special case 'Switch': //Status $state = $this->SwitchStatus($s); SetValueBoolean($vid, $state); break; case 'Lock': //Status $state = preg_match("/YES|CLOSE|OK/i", $s); //reversed SetValueBoolean($vid, $state); break; case 'Alert': //Status $state = !preg_match("/YES|ALERT/i", $s); //reversed SetValueBoolean($vid, $state); break; case 'Battery': //battery $state = !preg_match("/LOW|WARN/i", $s); //reversed SetValueBoolean($vid, $state); break; case 'FS20': //fs20 mode decoding $state = false; $intensity = 0; $timer = 0; $acode = ''; $actioncode = ''; $code = utf8_decode($s); $this->debug(__FUNCTION__, "FS20 Code " . strToHex($code)); $action = $code[0]; $ext = ord($code[1]); $tvid = @$this->GetIDForIdent($caps['Timer']); $dvid = @$this->GetIDForIdent($caps['Dimmer']); $swid = @$this->GetIDForIdent($caps['Switch']); $avid = @$this->GetIDForIdent($caps['TimerActionCode']); $this->debug(__FUNCTION__, "FS20 Vars S:{$swid},D:{$dvid},T:{$tvid},A:{$avid}"); if ($dvid) { $intensity = GetValueInteger($dvid); } if ($swid) { $state = GetValueBoolean($swid); } if ($tvid) { $timer = GetValueInteger($tvid); } if ($avid) { $acode = GetValueString($avid); } $ac = ord($action) & 0x1f; $timed = ($action & 0x20) > 0; $this->debug(__FUNCTION__, "FS20 AC:" . $ac . "PrevD:{$intensity}, PrevS:" . ($state ? "On" : "Off")); switch ($ac) { case 0: //off if ($timed) { $actioncode = 'Switch:Off'; } else { $state = false; } break; case $ac < 0xf: //Dim to value $intensity = FHZ_helper::fs20_intensity_percent($action & 0xf); $state = true; if ($timed) { $actioncode = 'Switch:Off'; } break; case 0x10: //on full $state = true; $intensity = 100; if ($timed) { $actioncode = 'Switch:Off'; } break; case 0x11: //on with old value $state = true; if ($intensity == 0) { $intensity = 100; } if ($timed) { $actioncode = 'Switch:Off'; } break; case 0x12: $state = !GetValueBoolean($swid); //toggle break; case 0x13: //dimup $steps = FHZ_helper::fs20_intensity_steps($intensity); $intensity = FHZ_helper::fs20_intensity_percent($steps + 1); $state = true; break; case 0x14: //dimdown if ($intensity == 0) { $intensity = 100; } $steps = FHZ_helper::fs20_intensity_steps($intensity); $intensity = FHZ_helper::fs20_intensity_percent($steps - 1); if ($intensity == 0) { $state = false; } break; case 0x18: //off-for-timer $state = 'Off'; $actioncode = 'Switch:On'; break; case 0x19: //on-for-timer than out $state = true; $actioncode = 'Switch:Off'; break; case 0x1a: //on-old-for-timer than out $state = true; $actioncode = 'Switch:Off'; break; case 0x1c: //ramp-on-time (time to reach the desired dim value on dimmers) $state = true; $actioncode = "Dimmer:{$intensity}"; break; case 0x1d: //ramp-off-time (time to reach the off state on dimmers) $actioncode = 'Switch:Off;Dimmer:0'; break; case 0x1e: //on-old-for-timer-prev", // old val for timer, then go to prev. state $actioncode = "Switch:" . ($state ? 'On' : 'Off'); $state = true; break; case 0x1f: //on-100-for-timer-prev", // 100% for timer, then go to previous state //new intensity will be the old one $action = "Switch:" . ($state ? 'On' : 'Off') . ";Dimmer:{$intensity}"; $intensity = 100; $state = true; break; case 0x15: //dimupdown, no value changes //dimupdown, no value changes case 0x16: //Set Timer //Set Timer case 0x17: //nop //nop case 0x1b: //rese break; } $new_timer = FHZ_helper::fs20_times($ext); $this->debug(__FUNCTION__, "State:" . ($state ? "ON" : "OFF") . ", Dimmer:{$intensity}%,Timer: {$new_timer},ActionCode: '{$actioncode}'"); //state if ($swid) { SetValueBoolean($swid, $state); } //dimmer if ($dvid) { SetValueInteger($dvid, $intensity); } //timer if ($tvid) { $this->SetTimerInterval('DeviceTimer', $new_timer * 1000); SetValueInteger($tvid, $new_timer); } //action if ($avid && $acode != $actioncode) { SetValueString($avid, $actioncode); } //log $actiontext = FHZ_helper::$fs20_codes[strToHex($action)]; if ($ext > 0) { $actiontext .= ', Timer:' . $timer; } $text = sprintf('%s (%s)', $actiontext, strToHex($code)); if ($vid) { SetValueString($vid, $text); } $this->debug(__FUNCTION__, "Action:" . $text); break; default: $this->debug(__FUNCTION__, "{$cap} not handled"); } $this->debug(__FUNCTION__, "{$cap}:({$vid})" . $s); } }
$sleeptimer = $sonos->GetSleeptimer(); if ($sleeptimer) { $SleeptimerArray = explode(":", $sonos->GetSleeptimer()); $SleeptimerMinutes = $SleeptimerArray[0] * 60 + $SleeptimerArray[1]; if ($SleeptimerArray[2]) { $SleeptimerMinutes = $SleeptimerMinutes + 1; } } else { $SleeptimerMinutes = 0; } SetValueInteger(IPS_GetObjectIDByName("Sleeptimer", IPS_GetParent($_IPS["SELF"])), $SleeptimerMinutes); } } $nowPlaying = GetValueString(IPS_GetObjectIDByName("nowPlaying", IPS_GetParent($_IPS["SELF"]))); if ($actuallyPlaying != $nowPlaying) { SetValueString(IPS_GetObjectIDByName("nowPlaying", IPS_GetParent($_IPS["SELF"])), $actuallyPlaying); } } // Set Group Volume if (IPS_GetProperty(IPS_GetParent($_IPS["SELF"]), "GroupCoordinator")) { $groupMembers = GetValueString(IPS_GetObjectIDByName("GroupMembers", IPS_GetParent($_IPS["SELF"]))); $groupMembersArray = array(); if ($groupMembers) { $groupMembersArray = array_map("intval", explode(",", $groupMembers)); } $groupMembersArray[] = IPS_GetParent($_IPS["SELF"]); $GroupVolume = 0; foreach ($groupMembersArray as $key => $ID) { $GroupVolume += GetValueInteger(IPS_GetObjectIDByName("Volume", $ID)); } SetValueInteger(IPS_GetObjectIDByName("GroupVolume", IPS_GetParent($_IPS["SELF"])), intval(round($GroupVolume / sizeof($groupMembersArray))));
private function WaitForResponse() { $ReplyATDataID = $this->GetIDForIdent('ReplyATData'); for ($i = 0; $i < 500; $i++) { if (GetValueString($ReplyATDataID) === '') { IPS_Sleep(10); } else { if ($this->lock('ReplyATData')) { $ret = GetValueString($ReplyATDataID); SetValueString($ReplyATDataID, ''); $this->unlock('ReplyATData'); $JSON = json_decode($ret); $ATData = new TXB_Command_Data(); $ATData->GetDataFromJSONObject($JSON); return $ATData; } return false; } } return false; }
public function ImportVersionInfo() { if (!$this->VariableExists("Version")) { $createdVariableId = $this->RegisterVariableString($this->ReadPropertyString("NzbIdentPrefix") . "Version", "Version"); } SetValueString(IPS_GetObjectIDByIdent($this->ReadPropertyString("NzbIdentPrefix") . "Version", $this->InstanceID), $this->GetVersion()); }
/** * Set status variable Buffer * @param String $val */ protected function SetBuffer($val) { $id = $this->GetIDForIdent('Buffer'); SetValueString($id, $val); }
public function ReceiveData($JSONString) { $data = json_decode($JSONString); // IPS_LogMessage('ReceiveDataFromSerialPort:'.$this->InstanceID, print_r($data,1)); $bufferID = $this->GetIDForIdent("BufferIN"); // Empfangs Lock setzen if (!$this->lock("ReceiveLock")) { throw new Exception("ReceiveBuffer is locked"); } // Datenstream zusammenfügen $head = GetValueString($bufferID); SetValueString($bufferID, ''); // Stream in einzelne Pakete schneiden $stream = $head . utf8_decode($data->Buffer); $start = strpos($stream, chr(0x7e)); //Anfang suchen if ($start === false) { // IPS_LogMessage('XBeeZigBee Gateway', 'Frame without 0x7e'); $stream = ''; } elseif ($start > 0) { // IPS_LogMessage('XBeeZigBee Gateway', 'Frame do not start with 0x7e'); $stream = substr($stream, $start); } //Paket suchen if (strlen($stream) < 5) { // IPS_LogMessage('XBeeZigBee Gateway', 'Frame to short'); SetValueString($bufferID, $stream); $this->unlock("ReceiveLock"); return; } $len = ord($stream[1]) * 256 + ord($stream[2]); if (strlen($stream) < $len + 4) { // IPS_LogMessage('XBeeZigBee Gateway', 'Frame must have ' . $len . ' Bytes. ' . strlen($stream) . ' Bytes given.'); SetValueString($bufferID, $stream); $this->unlock("ReceiveLock"); return; } $packet = substr($stream, 3, $len + 1); // Ende wieder in den Buffer werfen $tail = substr($stream, $len + 4); if ($tail === false) { $tail = ''; } SetValueString($bufferID, $tail); $this->unlock("ReceiveLock"); $this->DecodeData($packet); // Ende war länger als 4 ? Dann nochmal Packet suchen. if (strlen($tail) > 4) { $this->ReceiveData(json_encode(array('Buffer' => ''))); } return true; }
private function WriteResponse($Command, $Value) { if (is_array($Command)) { $Command = implode(' ', $Command); } if (is_array($Value)) { $Value = implode(' ', $Value); } $EventID = $this->GetIDForIdent('WaitForResponse'); if (!GetValueBoolean($EventID)) { return false; } $BufferID = $this->GetIDForIdent('BufferOUT'); if ($Command == GetValueString($BufferID)) { if ($this->lock('BufferOut')) { SetValueString($BufferID, trim($Value)); SetValueBoolean($EventID, false); $this->unlock('BufferOut'); return true; } return 'Error on write ResponseBuffer'; } return false; }
public function ReceiveData($JSONString) { // *************** Daten zusammen tragen ************ $data = json_decode($JSONString); $BufferID = $this->GetIDForIdent("BufferIN"); $DatasetID = $this->GetIDForIdent("Dataset"); $SensorenID = $this->GetIDForIdent("Sensoren"); $Head = GetValueString($BufferID); // holt sich die gespeicherten Restdaten aus der Variablen $dazu = utf8_decode($data->Buffer); // holen des neuen $all = $Head.$dazu; // setzt alle zusammen // *************** Datensatz separieren ************* $Startsequenz = chr(0x0D).chr(0x0A).chr(0x0D).chr(0x0A); // damit fängt der Datensatz an $Datasets = explode ($Startsequenz, $all); // Nun zerlegen wir den Senf und basteln ein Array $AnzahlDatasets = count ($Datasets); if ($AnzahlDatasets > 1) // checkt ob ein vollständiger da ist { SetValueString($BufferID, $Datasets[1]); // schreibt die Reste wieder zurück SetValueString($DatasetID, $Datasets[0]); // schreibt vollständigen Datensatz in Dataset, kann später wieder raus // ab hier zerlegen wir das Dataset 0 // *************** Datensatz verarbeiten ************ $AnzahlSensoren = substr_count($Datasets[0], 'ROM'); // hier zählen wir wieviele Sensoren vorhanden sind SetValueInteger($SensorenID, $AnzahlSensoren); // und füllen damit die Variable $Sensoren = $Datasets[0]; $Startsequenz1 = "ROM = "; // damit fängt der Datensatz an $Ende1nachZeichen = 21; // und ist xx Zeichen lang $Sensordaten[0] = explode ($Startsequenz1, $Sensoren); $SensorkorrROM = "Hardware ID des 1-W Bausteines"; $Sensordaten[0][0] = $SensorkorrROM; $SensorkorrROM = $Sensordaten[0][1]; $SensorkorrROM = substr($SensorkorrROM, 0, $Ende1nachZeichen); $Sensordaten[0][1] = $SensorkorrROM; $SensorkorrROM = $Sensordaten[0][2]; $SensorkorrROM = substr($SensorkorrROM, 0, $Ende1nachZeichen); $Sensordaten[0][2] = $SensorkorrROM; $SensorkorrROM = $Sensordaten[0][3]; $SensorkorrROM = substr($SensorkorrROM, 0, $Ende1nachZeichen); $Sensordaten[0][3] = $SensorkorrROM; SetValueString($this->GetIDForIdent("Sensor1_ROM"), $Sensordaten[0][1]); // und füllen damit die Variable, und dann Befüllen aus dem Array SetValueString($this->GetIDForIdent("Sensor2_ROM"), $Sensordaten[0][2]); // und füllen damit die Variable, und dann Befüllen aus dem Array SetValueString($this->GetIDForIdent("Sensor3_ROM"), $Sensordaten[0][3]); // und füllen damit die Variable, und dann Befüllen aus dem Array $Startsequenz2 = "Chip = "; // damit fängt der Datensatz an $Ende2nachZeichen = 8; // und ist xx Zeichen lang $Sensordaten[1] = explode ($Startsequenz2, $Sensoren); $SensorkorrROM = "Typ des 1-W Bausteines"; $Sensordaten[1][0] = $SensorkorrROM; $SensorkorrROM = $Sensordaten[1][1]; $SensorkorrROM = substr($SensorkorrROM, 0, $Ende2nachZeichen); $Sensordaten[1][1] = $SensorkorrROM; $SensorkorrROM = $Sensordaten[1][2]; $SensorkorrROM = substr($SensorkorrROM, 0, $Ende2nachZeichen); $Sensordaten[1][2] = $SensorkorrROM; $SensorkorrROM = $Sensordaten[1][3]; $SensorkorrROM = substr($SensorkorrROM, 0, $Ende2nachZeichen); $Sensordaten[1][3] = $SensorkorrROM; SetValueString($this->GetIDForIdent("Sensor1_Typ"), $Sensordaten[1][1]); // und füllen damit die Variable, und dann Befüllen aus dem Array SetValueString($this->GetIDForIdent("Sensor2_Typ"), $Sensordaten[1][2]); // und füllen damit die Variable, und dann Befüllen aus dem Array SetValueString($this->GetIDForIdent("Sensor3_Typ"), $Sensordaten[1][3]); // und füllen damit die Variable, und dann Befüllen aus dem Array $Startsequenz3 = "Temperature = "; // damit fängt der Datensatz an $Ende3nachZeichen = 5; // und ist xx Zeichen lang $Sensordaten[2] = explode ($Startsequenz3, $Sensoren); $SensorkorrROM = "Temperatur des 1-W Bausteines in Celsius"; $Sensordaten[2][0] = $SensorkorrROM; $SensorkorrROM = $Sensordaten[2][1]; $SensorkorrROM = substr($SensorkorrROM, 0, $Ende3nachZeichen); $Sensordaten[2][1] = $SensorkorrROM; $SensorkorrROM = $Sensordaten[2][2]; $SensorkorrROM = substr($SensorkorrROM, 0, $Ende3nachZeichen); $Sensordaten[2][2] = $SensorkorrROM; $SensorkorrROM = $Sensordaten[2][3]; $SensorkorrROM = substr($SensorkorrROM, 0, $Ende3nachZeichen); $Sensordaten[2][3] = $SensorkorrROM; SetValueFloat($this->GetIDForIdent("Sensor1_Temp"), $Sensordaten[2][1]); // und füllen damit die Variable, und dann Befüllen aus dem Array SetValueFloat($this->GetIDForIdent("Sensor2_Temp"), $Sensordaten[2][2]); // und füllen damit die Variable, und dann Befüllen aus dem Array SetValueFloat($this->GetIDForIdent("Sensor3_Temp"), $Sensordaten[2][3]); // und füllen damit die Variable, und dann Befüllen aus dem Array } else { SetValueString($BufferID, $all); // schreibt alles wieder zurück, weil es noch nicht vollständig war } }