no message
This commit is contained in:
@@ -14,7 +14,7 @@ class SofarWechselrichter extends IPSModule
|
||||
{
|
||||
parent::Create();
|
||||
// Moduleigenschaften
|
||||
$this->RegisterPropertyString('IPAddress', '');
|
||||
$this->RegisterPropertyString('IPAddress', '172.31.70.80');
|
||||
$this->RegisterPropertyString('LoggerNumber', '0'); // als String
|
||||
$this->RegisterPropertyInteger('PollInterval', 60);
|
||||
$this->RegisterPropertyString('Registers', '[]'); // JSON-String
|
||||
@@ -54,21 +54,24 @@ class SofarWechselrichter extends IPSModule
|
||||
}
|
||||
|
||||
// 2) Variablen löschen (falls entfernt)
|
||||
// Alle Kinder-IDs durchlaufen, Variablen mit Ident "Reg<Zahl>" entfernen,
|
||||
// Alle Kinder-IDs durchlaufen, Variablen mit Ident "Reg<Zahl>" entfernen,
|
||||
// wenn sie nicht mehr in $registers stehen.
|
||||
$validIdents = [];
|
||||
foreach ($registers as $entry) {
|
||||
$validIdents[] = 'Reg' . ((int)$entry['RegisterNumber']);
|
||||
}
|
||||
|
||||
$children = IPS_GetChildrenIDs($this->InstanceID);
|
||||
foreach ($children as $childID) {
|
||||
if (@IPS_VariableExists($childID)) {
|
||||
$info = IPS_GetVariable($childID);
|
||||
$ident = $info['VariableIdent'];
|
||||
if (substr($ident, 0, 3) === 'Reg') {
|
||||
if (!in_array($ident, $validIdents)) {
|
||||
IPS_DeleteVariable($childID);
|
||||
}
|
||||
// Nur Variablen berücksichtigen
|
||||
$obj = IPS_GetObject($childID);
|
||||
if ($obj['ObjectType'] !== 2) {
|
||||
continue;
|
||||
}
|
||||
$ident = $obj['ObjectIdent']; // VariableIdent
|
||||
if (substr($ident, 0, 3) === 'Reg') {
|
||||
if (!in_array($ident, $validIdents)) {
|
||||
IPS_DeleteVariable($childID);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -142,7 +145,7 @@ class SofarWechselrichter extends IPSModule
|
||||
}
|
||||
$valueRaw = $arr['value'];
|
||||
// bc* für sichere Multiplikation auch bei großen Zahlen / negativer Skalierung
|
||||
$value = bcmul((string)$valueRaw, (string)$scale, 4);
|
||||
$value = bcmul((string)$valueRaw, (string)$scale, 4);
|
||||
SetValueFloat($this->GetIDForIdent($ident), (float)$value);
|
||||
} catch (Exception $e) {
|
||||
$this->LogMessage("Fehler Lesen Reg {$regNo}: " . $e->getMessage(), KL_WARNING);
|
||||
|
||||
Reference in New Issue
Block a user