Skip to content

Commit

Permalink
v2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
demel42 committed Jan 27, 2024
1 parent 7085f54 commit c20cd3f
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 15 deletions.
42 changes: 30 additions & 12 deletions MielelAtHomeSplitter/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ public function Create()

$this->RegisterPropertyInteger('OAuth_Type', self::$CONNECTION_UNDEFINED);

$this->RegisterPropertyBoolean('collectApiCallStats', true);

$this->RegisterAttributeString('ApiRefreshToken', json_encode([]));
$this->RegisterAttributeString('ApiAccessToken', json_encode([]));
$this->RegisterAttributeInteger('ConnectionType', self::$CONNECTION_UNDEFINED);

$this->RegisterAttributeString('UpdateInfo', json_encode([]));
$this->RegisterAttributeString('ApiCallStats', json_encode([]));
$this->RegisterAttributeString('ModuleStats', json_encode([]));

$this->InstallVarProfiles(false);
Expand Down Expand Up @@ -186,7 +187,7 @@ public function ApplyChanges()
$connection_type = $this->ReadPropertyInteger('OAuth_Type');

$apiLimits = [];
$this->ApiCallsSetInfo($apiLimits, '');
$this->ApiCallSetInfo($apiLimits, '');

$module_disable = $this->ReadPropertyBoolean('module_disable');
if ($module_disable) {
Expand Down Expand Up @@ -691,6 +692,12 @@ private function GetFormElements()
break;
}

$formElements[] = [
'type' => 'CheckBox',
'name' => 'collectApiCallStats',
'caption' => 'Collect data of API calls'
];

return $formElements;
}

Expand Down Expand Up @@ -726,19 +733,25 @@ private function GetFormActions()
'onClick' => 'IPS_RequestAction(' . $this->InstanceID . ', "TestAccess", "");',
];

$items = [
$this->GetInstallVarProfilesFormItem(),
[
'type' => 'Button',
'caption' => 'Clear token',
'onClick' => 'IPS_RequestAction(' . $this->InstanceID . ', "ClearToken", "");',
],
];

$collectApiCallStats = $this->ReadPropertyBoolean('collectApiCallStats');
if ($collectApiCallStats) {
$items[] = $this->GetApiCallStatsFormItem();
}

$formActions[] = [
'type' => 'ExpansionPanel',
'caption' => 'Expert area',
'expanded' => false,
'items' => [
$this->GetInstallVarProfilesFormItem(),
[
'type' => 'Button',
'caption' => 'Clear token',
'onClick' => 'IPS_RequestAction(' . $this->InstanceID . ', "ClearToken", "");',
],
$this->GetApiCallStatsFormItem(),
]
'items' => $items,
];

$formActions[] = $this->GetInformationFormAction();
Expand Down Expand Up @@ -1090,7 +1103,12 @@ private function do_HttpRequest($func, $params, $header, $postdata, $mode, &$dat
$this->LogMessage('url=' . $url . ' => statuscode=' . $statuscode . ', err=' . $err, KL_WARNING);
$this->SendDebug(__FUNCTION__, ' => statuscode=' . $statuscode . ', err=' . $err . ', msg=' . $msg, 0);
}
$this->ApiCallsCollect($url, $err, $statuscode);

$collectApiCallStats = $this->ReadPropertyBoolean('collectApiCallStats');
if ($collectApiCallStats) {
$this->ApiCallCollect($url, $err, $statuscode);
}

return $statuscode;
}
}
2 changes: 2 additions & 0 deletions MielelAtHomeSplitter/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
"Netherlands": "Niederlande",
"Switzerland": "Schweiz",

"Collect data of API calls": "Daten von API-Aufrufen sammeln",

"__actions__": "",
"Login at Miele@Home": "Miele@Home Anmeldung",
"Test access": "Zugang prüfen",
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ Verweise:

## 7. Versions-Historie

- 2.2 @ 27.01.2024 11:20
- Neu: Schalter, um Daten zu API-Aufrufen zu sammeln
Die API-Aufruf-Daten stehen nun in einem Medienobjekt zur Verfügung
- update submodule CommonStubs

- 2.1 @ 10.12.2023 10:43
- Neu: ab IPS-Version 7 ist im Konfigurator die Angabe einer Import-Kategorie integriert, daher entfällt die bisher vorhandene separate Einstellmöglichkeit

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": "2.1",
"version": "2.2",
"build": 0,
"date": 1702201417
"date": 1706350801
}
2 changes: 1 addition & 1 deletion libs/CommonStubs
Submodule CommonStubs updated 3 files
+6 −3 README.md
+53 −33 common.php
+3 −0 translation.json

0 comments on commit c20cd3f

Please sign in to comment.