Skip to content

Commit

Permalink
Fix No Response Error on reload module
Browse files Browse the repository at this point in the history
  • Loading branch information
Nall-chan committed Oct 23, 2024
1 parent d4e670e commit d07543d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
3 changes: 3 additions & 0 deletions libs/AttributeArrayHelper.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

namespace Zigbee2MQTT;

/**
Expand Down
45 changes: 22 additions & 23 deletions libs/ModulBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function ApplyChanges()
$Filter2 = preg_quote('"Topic":"' . $BaseTopic . '/SymconExtension/response/' . static::$ExtensionTopic . $MQTTTopic);
$this->SendDebug('Filter', '.*(' . $Filter1 . '|' . $Filter2 . ').*', 0);
$this->SetReceiveDataFilter('.*(' . $Filter1 . '|' . $Filter2 . ').*');
if (($this->HasActiveParent()) && (IPS_GetKernelRunlevel() == KR_READY)) {
if (($this->HasActiveParent()) && (IPS_GetKernelRunlevel() == KR_READY) && ($this->GetStatus() != IS_CREATING)) {
$this->UpdateDeviceInfo();
}
$this->SetStatus(IS_ACTIVE);
Expand Down Expand Up @@ -607,7 +607,7 @@ protected function DecodeData($Payload)
$variableTypeKey = $key . '_type';
if (isset($Payload[$variableTypeKey])) {
$variableType = $Payload[$variableTypeKey];

// Prüfe, ob ein State-Mapping existiert und wende es an
if (array_key_exists($key, self::$stateMappings)) {
$mappedValue = self::convertStateBasedOnMapping($key, $value, $variableType);
Expand Down Expand Up @@ -758,25 +758,25 @@ protected function SetValue($Ident, $Value)
}
}
}
// Typ der vorhandenen Variable abrufen
$varType = IPS_GetVariable($this->GetIDForIdent($Ident))['VariableType'];
// Standardverarbeitung für andere Variablentypen
switch ($varType) {
case VARIABLETYPE_BOOLEAN:
$adjustedValue = (bool) $Value;
break;
case VARIABLETYPE_INTEGER:
$adjustedValue = (int) $Value;
break;
case VARIABLETYPE_FLOAT:
$adjustedValue = (float) $Value;
break;
case VARIABLETYPE_STRING:
$adjustedValue = (string) $Value;
break;
default:
$adjustedValue = (string) $Value; // Fallback, falls der Typ unbekannt ist
break;
// Typ der vorhandenen Variable abrufen
$varType = IPS_GetVariable($this->GetIDForIdent($Ident))['VariableType'];
// Standardverarbeitung für andere Variablentypen
switch ($varType) {
case VARIABLETYPE_BOOLEAN:
$adjustedValue = (bool) $Value;
break;
case VARIABLETYPE_INTEGER:
$adjustedValue = (int) $Value;
break;
case VARIABLETYPE_FLOAT:
$adjustedValue = (float) $Value;
break;
case VARIABLETYPE_STRING:
$adjustedValue = (string) $Value;
break;
default:
$adjustedValue = (string) $Value; // Fallback, falls der Typ unbekannt ist
break;
}

$this->SendDebug(__FUNCTION__ . ' :: ' . __LINE__ . ' :: Adjusted value for ' . $Ident, (is_array($adjustedValue) ? json_encode($adjustedValue) : $adjustedValue), 0);
Expand Down Expand Up @@ -1118,7 +1118,6 @@ private function registerVariable($feature, $exposeType = null)
$label = ucwords(str_replace('_', ' ', $feature['property'] ?? $property));
$this->SendDebug(__FUNCTION__ . ' :: Line ' . __LINE__ . ' :: Using Expose Type: ', $type, 0);


// Überprüfen, ob die Variable bereits existiert
$objectID = @$this->GetIDForIdent($ident);
if ($objectID) {
Expand Down Expand Up @@ -1152,7 +1151,7 @@ private function registerVariable($feature, $exposeType = null)
if ($objectID) {
return;
}

// Überprüfung auf Standardprofil und zugehörigen Variablentyp
$standardProfile = $this->getStandardProfile($type, $property);
$variableType = $this->getVariableTypeFromProfile($type, $property);
Expand Down

0 comments on commit d07543d

Please sign in to comment.