Skip to content

Commit

Permalink
v3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
demel42 committed Feb 5, 2024
1 parent 39ab12b commit f6f368d
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 19 deletions.
78 changes: 62 additions & 16 deletions AutomowerConnectSplitter/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,44 @@ private function CheckModuleConfiguration()
return $r;
}

private function CheckModuleUpdate(array $oldInfo, array $newInfo)
{
$r = [];

if ($this->version2num($oldInfo) < $this->version2num('3.6')) {
$collectApiCallStats = $this->ReadPropertyBoolean('collectApiCallStats');
if ($collectApiCallStats) {
$r[] = $this->Translate('Set ident of media objects');
}
}

return $r;
}

private function CompleteModuleUpdate(array $oldInfo, array $newInfo)
{
$r = '';

if ($this->version2num($oldInfo) < $this->version2num('3.6')) {
$collectApiCallStats = $this->ReadPropertyBoolean('collectApiCallStats');
if ($collectApiCallStats) {
$m = [
'ApiCallStats' => '.txt',
];

foreach ($m as $ident => $extension) {
$filename = 'media' . DIRECTORY_SEPARATOR . $this->InstanceID . '-' . $ident . $extension;
@$mediaID = IPS_GetMediaIDByFile($filename);
if ($mediaID != false) {
IPS_SetIdent($mediaID, $ident);
}
}
}
}

return $r;
}

public function ApplyChanges()
{
parent::ApplyChanges();
Expand Down Expand Up @@ -148,24 +186,32 @@ public function ApplyChanges()

$connection_type = $this->ReadPropertyInteger('connection_type');

$apiLimits = [
[
'value' => 1,
'unit' => 'second',
],
];
if ($connection_type == self::$CONNECTION_OAUTH) {
$apiLimits[] = [
'value' => 100,
'unit' => 'day',
];
} else {
$apiLimits[] = [
'value' => 10000,
'unit' => 'month',
$vpos = 1000;

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

if ($collectApiCallStats) {
$apiLimits = [
[
'value' => 1,
'unit' => 'second',
],
];
if ($connection_type == self::$CONNECTION_OAUTH) {
$apiLimits[] = [
'value' => 100,
'unit' => 'day',
];
} else {
$apiLimits[] = [
'value' => 10000,
'unit' => 'month',
];
}
$apiNotes = '';
$this->ApiCallSetInfo($apiLimits, $apiNotes);
}
$this->ApiCallSetInfo($apiLimits, '');

$module_disable = $this->ReadPropertyBoolean('module_disable');
if ($module_disable) {
Expand Down
6 changes: 6 additions & 0 deletions AutomowerConnectSplitter/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"'Application secret' or Username and Password must be specified":
"'Application secret' oder Benutzerkennung und Passwort müssen angegeben werden",

"__function__": "CheckUpdate",
"Set ident of media objects": "Ident der Media-Objekte setzen",

"__elements__": "",
"Disable instance": "Instanz deaktivieren",

Expand Down Expand Up @@ -48,6 +51,9 @@
"Mower": "Rasenmäher",
"Model": "Modell",

"__media__": "",
"API call statistics": "API-Aufruf-Statistkdaten",

"__end__": ""
}
}
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ Quellen:

## 7. Versions-Historie

- 3.6 @ 28.01.2024 16:45
- Änderung: Medien-Objekte haben zur eindeutigen Identifizierung jetzt ebenfalls ein Ident
- update submodule CommonStubs

- 3.5 @ 27.01.2024 11:09
- Neu: Schalter, um Daten zu API-Aufrufen zu sammeln
Die API-Aufruf-Daten stehen nun in einem Medienobjekt zur Verfügung
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": "3.5",
"version": "3.6",
"build": 0,
"date": 1706350144
"date": 1706456703
}
2 changes: 1 addition & 1 deletion libs/CommonStubs
Submodule CommonStubs updated 3 files
+3 −2 README.md
+57 −31 common.php
+0 −3 translation.json

0 comments on commit f6f368d

Please sign in to comment.