Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
Nall-chan committed Jan 21, 2024
1 parent b32d817 commit 057786c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
2 changes: 2 additions & 0 deletions Xiaomi MIoT Configurator/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
eval('declare(strict_types=1);namespace XiaomiConfigurator {?>' . file_get_contents(__DIR__ . '/../libs/helper/DebugHelper.php') . '}');
require_once dirname(__DIR__) . '/libs/XiaomiConsts.php';
/**
* @property int ParentID
*
* @method bool SendDebug(string $Message, mixed $Data, int $Format)
*/
class XiaomiMIoTConfigurator extends IPSModule
Expand Down
3 changes: 3 additions & 0 deletions Xiaomi MIoT Device/locale.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
"Connection established": "Verbindung hergestellt",
"Reconnect successfully": "Wiederverbinden erfolgreich",
"disconnected": "getrennt",
"Try reconnecting": "Versuche neu zu verbinden",
"Reconnect failed": "Neuverbinden fehlgeschlagen",
"Try to reconnect in %d seconds": "Versuchen in %d Sekunden neu zu verbinden",
"Execute": "Ausführen",
"Request state": "Zustand lesen",
"Reload device information": "Geräteinformationen neu laden",
Expand Down
26 changes: 19 additions & 7 deletions Xiaomi MIoT Device/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ public function ApplyChanges()
);
$this->ServerStamp = 0;
$this->ServerStampTime = 0;
$this->Retries = 2;

//Never delete this line!
parent::ApplyChanges();

// Anzeige IP in der INFO Spalte
$this->SetSummary($this->ReadPropertyString(\Xiaomi\Device\Property::Host));

Expand All @@ -103,7 +105,6 @@ public function ApplyChanges()
return;
}
if ((!$this->ReadPropertyBoolean(\Xiaomi\Device\Property::Active)) || (!$this->ReadPropertyString(\Xiaomi\Device\Property::Host))) {
$this->Retries = 2;
$this->SetStatus(IS_INACTIVE);
return;
}
Expand Down Expand Up @@ -154,7 +155,6 @@ public function ApplyChanges()
}

$this->LogMessage($this->Translate('Connection established'), KL_MESSAGE);
$this->Retries = 2;
$this->SetTimerInterval(\Xiaomi\Device\Timer::RefreshState, $this->ReadPropertyInteger(\Xiaomi\Device\Property::RefreshInterval) * 1000);
}

Expand All @@ -180,13 +180,21 @@ public function RequestAction($Ident, $Value)
$this->RequestState();
return;
case \Xiaomi\Device\Timer::Reconnect:
//Reconnect Timer abgelaufen. Verbindungsaufbau versuchen.
$this->ApplyChanges();
// Reconnect Timer abgelaufen. Verbindungsaufbau versuchen.
$this->SetTimerInterval(\Xiaomi\Device\Timer::Reconnect, 0);
$this->LogMessage($this->Translate('Try reconnecting'), KL_MESSAGE);
if ($this->SendHandshake()) {
$this->Retries = 2;
$this->SetStatus(IS_ACTIVE);
$this->SetTimerInterval(\Xiaomi\Device\Timer::RefreshState, $this->ReadPropertyInteger(\Xiaomi\Device\Property::RefreshInterval) * 1000);
}
return;
case 'ForceReloadModel':
//User hat Geräteinfos neu laden über die Instanz-Konfig ausgeführt.
// User hat Geräteinfos neu laden über die Instanz-Konfig ausgeführt.
// Alle Timer anhalten
$this->SetTimerInterval(\Xiaomi\Device\Timer::RefreshState, 0);
$this->SetTimerInterval(\Xiaomi\Device\Timer::Reconnect, 0);
// Alle Attribute löschen
$this->WriteAttributeString(\Xiaomi\Device\Attribute::Token, '');
$this->WriteAttributeArray(\Xiaomi\Device\Attribute::Specs, []);
$this->WriteAttributeString(\Xiaomi\Device\Attribute::ProductName, '');
Expand All @@ -198,6 +206,7 @@ public function RequestAction($Ident, $Value)
$this->WriteAttributeArray(\Xiaomi\Device\Attribute::ActionIdents, []);
$this->WriteAttributeArray(\Xiaomi\Device\Attribute::ParamIdentsRead, []);
$this->WriteAttributeArray(\Xiaomi\Device\Attribute::ParamIdentsWrite, []);
// Neu laden von allen Einstellungen und Attributen
IPS_RunScriptText('IPS_Applychanges(' . $this->InstanceID . ');');
return;
case 'ReloadForm':
Expand Down Expand Up @@ -456,18 +465,21 @@ protected function SetStatus($State)
{
switch ($State) {
case IS_ACTIVE:
$this->Retries = 2;
if ($this->GetStatus() > IS_EBASE) {
$this->LogMessage($this->Translate('Reconnect successfully'), KL_MESSAGE);
}
break;
case IS_INACTIVE:
$this->Retries = 2;
$this->LogMessage($this->Translate('disconnected'), KL_MESSAGE);
break;
default:
$this->LogMessage($this->Translate('Reconnect failed'), KL_MESSAGE);
if ($this->Retries < 3600) {
$this->Retries++;
}
$this->LogMessage('Retry in ' . $this->Retries . ' seconds', KL_MESSAGE);
$this->LogMessage(sprintf($this->Translate('Try to reconnect in %d seconds'), $this->Retries), KL_MESSAGE);
$this->SetTimerInterval(\Xiaomi\Device\Timer::Reconnect, $this->Retries * 1000);
break;
}
Expand All @@ -477,7 +489,7 @@ protected function SetStatus($State)
private function KernelReady()
{
$this->UnregisterMessage(0, IPS_KERNELSTARTED);
// Wenn Kernel fertig, dann fangen wir von vorne an.
// Wenn Kernel fertig, dann machen wir da im Applychanges weiter, wo wir vorher abgebrochen haben.
$this->ApplyChanges();
}

Expand Down
4 changes: 2 additions & 2 deletions library.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"version": "6.4"
},
"version": "1.10",
"build": 115,
"date": 1704122147
"build": 116,
"date": 1705843766
}

0 comments on commit 057786c

Please sign in to comment.