Skip to content

Commit 7eb3ccd

Browse files
authored
FIX: ModulBase.php - flattenPayload
1.) Composite skip only on first layer 2.) remove specialhandling of UPDATE, not needed
1 parent bc54b8b commit 7eb3ccd

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

libs/ModulBase.php

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,34 +1307,26 @@ protected function ShowMissingTranslations(): bool
13071307
*
13081308
* @see \Zigbee2MQTT\ModulBase::processPayload()
13091309
*/
1310-
protected function flattenPayload(array $payload, string $prefix = ''): array
1310+
protected function flattenPayload(array $payload, string $prefix = '', int $depth = 0): array
13111311
{
13121312
$result = [];
13131313

13141314
foreach ($payload as $key => $value) {
13151315
$newKey = $prefix ? $prefix . '__' . $key : $key;
13161316

1317-
// Composite-Keys überspringen, die in SKIP_COMPOSITES definiert sind
1318-
if (in_array($key, self::SKIP_COMPOSITES) && is_array($value)) {
1319-
$this->SendDebug(__FUNCTION__, "Überspringe Composite-Key: $key", 0);
1317+
// Composite-Keys überspringen, die in SKIP_COMPOSITES definiert sind und auf oberster Ebene gesetzt sind
1318+
if ($depth === 0 && in_array($key, self::SKIP_COMPOSITES) && is_array($value)) {
1319+
$this->SendDebug(__FUNCTION__, "Überspringe Composite-Key auf oberster Ebene: $key", 0);
13201320
continue;
13211321
}
13221322

1323-
// Spezialbehandlung für color-Properties
1323+
// Spezialbehandlung für color-Properties, da zur Farbberechnung nicht als flatten benötigt
13241324
if ($key === 'color' && is_array($value)) {
13251325
// Übernehme die color-Properties direkt ins color-Array
13261326
$result['color'] = $value;
13271327
continue;
13281328
}
13291329

1330-
// Update-Properties zusammenfassen
1331-
if ($key === 'update' && is_array($value)) {
1332-
foreach ($value as $updateKey => $updateValue) {
1333-
$result['update__' . $updateKey] = $updateValue;
1334-
}
1335-
continue;
1336-
}
1337-
13381330
if (is_array($value)) {
13391331
$result = array_merge($result, $this->flattenPayload($value, $newKey));
13401332
} else {

0 commit comments

Comments
 (0)