Skip to content

Commit

Permalink
v1.43
Browse files Browse the repository at this point in the history
  • Loading branch information
demel42 committed Feb 7, 2024
1 parent 57b228e commit 89ebbd7
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 47 deletions.
20 changes: 8 additions & 12 deletions NetatmoWeatherConfig/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,11 @@ private function getConfiguratorValues()

$instanceID = 0;
foreach ($instIDs as $instID) {
if (IPS_GetProperty($instID, 'station_id') != $station_id) {
continue;
if (@IPS_GetProperty($instID, 'station_id') == $station_id && @IPS_GetProperty($instID, 'module_id') == $module_id) {
$this->SendDebug(__FUNCTION__, 'instance found: ' . IPS_GetName($instID) . ' (' . $instID . ')', 0);
$instanceID = $instID;
break;
}
if (IPS_GetProperty($instID, 'module_id') != $module_id) {
continue;
}
$instanceID = $instID;
break;
}

if ($instanceID && IPS_GetInstance($instanceID)['ConnectionID'] != IPS_GetInstance($this->InstanceID)['ConnectionID']) {
Expand All @@ -141,9 +138,8 @@ private function getConfiguratorValues()
]
]
];

$entries[] = $entry;
$this->SendDebug(__FUNCTION__, 'entry=' . print_r($entry, true), 0);
$this->SendDebug(__FUNCTION__, 'instanceID=' . $instanceID . ', entry=' . print_r($entry, true), 0);
}
}
}
Expand All @@ -164,14 +160,14 @@ private function getConfiguratorValues()
continue;
}

$module_type = IPS_GetProperty($instID, 'module_type');
@$module_type = IPS_GetProperty($instID, 'module_type');
if ($module_type != 'Station') {
continue;
}

$name = IPS_GetName($instID);
$city = '';
$station_id = IPS_GetProperty($instID, 'station_id');
@$station_id = IPS_GetProperty($instID, 'station_id');

$entry = [
'instanceID' => $instID,
Expand All @@ -180,7 +176,7 @@ private function getConfiguratorValues()
'station_id' => $station_id,
];
$entries[] = $entry;
$this->SendDebug(__FUNCTION__, 'missing entry=' . print_r($entry, true), 0);
$this->SendDebug(__FUNCTION__, 'lost: instanceID=' . $instID . ', entry=' . print_r($entry, true), 0);
}

return $entries;
Expand Down
57 changes: 27 additions & 30 deletions NetatmoWeatherDevice/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,8 @@ private function getConfiguratorValues4Station()
*/

foreach ($devices as $device) {
$this->SendDebug(__FUNCTION__, 'device=' . print_r($device, true), 0);

$_id = $device['_id'];
if ($station_id != $_id) {
continue;
Expand All @@ -421,29 +423,25 @@ private function getConfiguratorValues4Station()
$module_type = 'NAMain';
$module_id = $device['_id'];
$module_desc = $this->Translate('Base module');
$module_name = $this->GetArrayElem($device, 'module_name', '');
if ($module_name == '') {
$module_name = $module_desc;
}

$instanceID = 0;
foreach ($instIDs as $instID) {
if (IPS_GetProperty($instID, 'station_id') != $station_id) {
continue;
}
if (IPS_GetProperty($instID, 'module_id') != $module_id) {
continue;
if (@IPS_GetProperty($instID, 'station_id') == $station_id && @IPS_GetProperty($instID, 'module_id') == $module_id) {
$this->SendDebug(__FUNCTION__, 'instance found: ' . IPS_GetName($instID) . ' (' . $instID . ')', 0);
$instanceID = $instID;
$module_name = IPS_GetName($instanceID);
break;
}
$instanceID = $instID;
break;
}

if ($instanceID && IPS_GetInstance($instanceID)['ConnectionID'] != IPS_GetInstance($this->InstanceID)['ConnectionID']) {
continue;
}

$module_name = $this->GetArrayElem($device, 'module_name', '');
if ($module_name == '') {
$module_name = IPS_GetName($instanceID);
}
$module_info = $module_desc . ' (' . $station_name . '\\' . $module_name . ')';

$entry = [
'instanceID' => $instanceID,
'name' => $module_name,
Expand All @@ -452,7 +450,7 @@ private function getConfiguratorValues4Station()
'create' => [
'moduleID' => $guid,
'location' => $location,
'info' => $module_info,
'info' => $module_desc . ' (' . $station_name . '\\' . $module_name . ')',
'configuration' => [
'module_id' => $module_id,
'module_type' => $module_type,
Expand All @@ -461,7 +459,7 @@ private function getConfiguratorValues4Station()
]
];
$entries[] = $entry;
$this->SendDebug(__FUNCTION__, 'entry=' . print_r($entry, true), 0);
$this->SendDebug(__FUNCTION__, 'instanceID=' . $instID . ', entry=' . print_r($entry, true), 0);

$modules = $this->GetArrayElem($device, 'modules', '');
if ($modules != '') {
Expand All @@ -470,6 +468,8 @@ private function getConfiguratorValues4Station()
if ($module['type'] != $types) {
continue;
}
$this->SendDebug(__FUNCTION__, 'module=' . print_r($module, true), 0);

$module_type = $module['type'];
switch ($module_type) {
case 'NAModule1':
Expand All @@ -490,34 +490,31 @@ private function getConfiguratorValues4Station()
break;
default:
$module_id = '';
echo 'unknown module_type ' . $module_type;
$this->SendDebug(__FUNCTION__, 'unknown module_type ' . $module_type, 0);
break;
}
if ($module_id == '') {
continue;
}

$module_name = $this->GetArrayElem($module, 'module_name', '');
if ($module_name == '') {
$module_name = $module_desc;
}

$instanceID = 0;
foreach ($instIDs as $instID) {
if (IPS_GetProperty($instID, 'station_id') != $station_id) {
continue;
}
if (IPS_GetProperty($instID, 'module_id') != $module_id) {
continue;
if (@IPS_GetProperty($instID, 'station_id') == $station_id && @IPS_GetProperty($instID, 'module_id') == $module_id) {
$this->SendDebug(__FUNCTION__, 'instance found: ' . IPS_GetName($instID) . ' (' . $instID . ')', 0);
$instanceID = $instID;
$module_name = IPS_GetName($instanceID);
break;
}
$instanceID = $instID;
break;
}

if ($instanceID && IPS_GetInstance($instanceID)['ConnectionID'] != IPS_GetInstance($this->InstanceID)['ConnectionID']) {
continue;
}
$module_name = $this->GetArrayElem($module, 'module_name', '');
if ($module_name == '') {
$module_name = IPS_GetName($instanceID);
}
$module_info = $module_desc . ' (' . $station_name . '\\' . $module_name . ')';

$entry = [
'instanceID' => $instanceID,
Expand All @@ -527,7 +524,7 @@ private function getConfiguratorValues4Station()
'create' => [
'moduleID' => $guid,
'location' => $location,
'info' => $module_info,
'info' => $module_desc . ' (' . $station_name . '\\' . $module_name . ')',
'configuration' => [
'module_id' => $module_id,
'module_type' => $module_type,
Expand All @@ -536,7 +533,7 @@ private function getConfiguratorValues4Station()
]
];
$entries[] = $entry;
$this->SendDebug(__FUNCTION__, 'entry=' . print_r($entry, true), 0);
$this->SendDebug(__FUNCTION__, 'instanceID=' . $instID . ', entry=' . print_r($entry, true), 0);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions NetatmoWeatherIO/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ public function ApplyChanges()
return;
}

$vpos = 1000;
$collectApiCallStats = $this->ReadPropertyBoolean('collectApiCallStats');
$this->MaintainMedia('ApiCallStats', $this->Translate('API call statistics'), MEDIATYPE_DOCUMENT, '.txt', false, $vpos++, $collectApiCallStats);
$vpos = 1000;
$collectApiCallStats = $this->ReadPropertyBoolean('collectApiCallStats');
$this->MaintainMedia('ApiCallStats', $this->Translate('API call statistics'), MEDIATYPE_DOCUMENT, '.txt', false, $vpos++, $collectApiCallStats);

$module_disable = $this->ReadPropertyBoolean('module_disable');
if ($module_disable) {
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,9 @@ GUIDs

## 7. Versions-Historie

- 1.43 @ 07.02.2024 17:56
- Fix: Absicherung von Zugriffen auf andere Instanzen in Konfiguratoren

- 1.42 @ 29.01.2024 11:02
- Änderung: Medien-Objekte haben zur eindeutigen Identifizierung jetzt ebenfalls ein Ident
- Neu: Schalter, um Daten zu API-Aufrufen zu sammeln
Expand Down
4 changes: 2 additions & 2 deletions library.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"compatibility": {
"version": "6.2"
},
"version": "1.42",
"version": "1.43",
"build": 0,
"date": 1706522537
"date": 1707324976
}

0 comments on commit 89ebbd7

Please sign in to comment.