From 9702a88cb3febf82a65e5ee88766dc88126f7d31 Mon Sep 17 00:00:00 2001 From: jhartworks Date: Thu, 16 Apr 2026 15:21:30 +0200 Subject: [PATCH] fix: enhance variable naming logic and update build number in library.json --- CounterClient/module.php | 15 +++++++++++---- library.json | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CounterClient/module.php b/CounterClient/module.php index 80ccde7..b16cad2 100644 --- a/CounterClient/module.php +++ b/CounterClient/module.php @@ -212,10 +212,16 @@ class CounterClient extends IPSModule } $value = round((float) $value, 3); + $varName = mb_strtolower(IPS_GetName($varId)); + $parentId = IPS_GetParent($varId); + if ($parentId > 0) { + $varName = mb_strtolower(IPS_GetName($parentId) . ' ' . IPS_GetName($varId)); + } + $unitNorm = $this->normalizeUnit($unit); - if (in_array($unitNorm, ['kwh', 'wh', 'mwh', 'm3', 'l'], true)) { + if (in_array($unitNorm, ['kwh', 'kw/h', 'wh', 'mwh', 'm3', 'l'], true)) { return [ 'field' => 'total_value', 'value' => $value, @@ -334,7 +340,6 @@ class CounterClient extends IPSModule return null; } - private function assignInOutValues(array &$counterData, array $items, string $fieldIn, string $fieldOut): void { foreach ($items as $item) { @@ -408,7 +413,8 @@ class CounterClient extends IPSModule || strpos($name, 'vl') !== false || strpos($name, 'flow') !== false || strpos($name, 'ein') !== false - || strpos($name, 'in') !== false; + || strpos($name, ' in ') !== false + || strpos($name, 'iv') !== false; } private function looksLikeOut(string $name): bool @@ -418,7 +424,8 @@ class CounterClient extends IPSModule || strpos($name, 'rl') !== false || strpos($name, 'return') !== false || strpos($name, 'aus') !== false - || strpos($name, 'out') !== false; + || strpos($name, ' out ') !== false + || strpos($name, 'ri') !== false; } private function normalizeUnit(string $unit): string diff --git a/library.json b/library.json index 336bbb4..51854c3 100644 --- a/library.json +++ b/library.json @@ -8,6 +8,6 @@ "date": 1491343200 }, "version": "1.1", - "build": 3, + "build": 4, "date": 0 } \ No newline at end of file