Skip to content

Commit e01af03

Browse files
authored
Merge pull request #45 from Nall-chan/dev
SYNC: nall-chan
2 parents 2751f77 + e865ed7 commit e01af03

File tree

4 files changed

+99
-66
lines changed

4 files changed

+99
-66
lines changed

Device/module.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public function GetConfigurationForm()
9191
$ModelUrl = str_replace([' ', '/'], '_', $Model);
9292
$Form['elements'][1]['caption'] = $this->Translate('Link to device information: ') .
9393
'https://www.zigbee2mqtt.io/devices/' . rawurlencode($ModelUrl) . '.html';
94+
$Form['actions'][1]['items'][0]['items'][1]['download'] = 'Z2M_Debug_' . rawurlencode($ModelUrl) . '.json';
9495
} else {
9596
$Form['elements'][1]['visible'] = false;
9697
}

library.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"compatibility": {
77
"version": "7.0"
88
},
9-
"version": "5.19",
10-
"build": 519,
11-
"date": 1742121510
9+
"version": "5.20",
10+
"build": 520,
11+
"date": 1743957530
1212
}

libs/ModulBase.php

Lines changed: 62 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ abstract class ModulBase extends \IPSModule
261261
['group_type' => '', 'feature' => 'window_detection', 'profile' => '~Window', 'variableType' => VARIABLETYPE_BOOLEAN],
262262
['group_type' => '', 'feature' => 'contact', 'profile' => '~Window.Reversed', 'variableType' => VARIABLETYPE_BOOLEAN],
263263
['group_type' => '', 'feature' => 'tamper', 'profile' => '~Alert', 'variableType' => VARIABLETYPE_BOOLEAN],
264+
['group_type' => '', 'feature' => 'smoke', 'profile' => '~Alert', 'variableType' => VARIABLETYPE_BOOLEAN],
264265
['group_type' => 'light', 'feature' => 'color', 'profile' => '~HexColor', 'variableType' => VARIABLETYPE_INTEGER],
265266
['group_type' => 'climate', 'feature' => 'occupied_heating_setpoint', 'profile' => '~Temperature.Room', 'variableType' => VARIABLETYPE_FLOAT]
266267
];
@@ -1593,7 +1594,11 @@ private function processPayload(array $payload): void
15931594

15941595
// Payload-Daten verarbeiten
15951596
foreach ($flattenedPayload as $key => $value) {
1596-
$this->SendDebug(__FUNCTION__, sprintf('Verarbeite: Key=%s, Value=%s', $key, is_array($value) ? json_encode($value) : (string) $value), 0);
1597+
if ($value === null) {
1598+
$this->SendDebug(__FUNCTION__, sprintf('Skip empty value for key=%s', $key), 0);
1599+
continue;
1600+
}
1601+
$this->SendDebug(__FUNCTION__, sprintf('Verarbeite: Key=%s, Value=%s', $key, is_array($value) ? json_encode($value) : (is_bool($value) ? ($value ? 'TRUE' : 'FALSE') : (string) $value)), 0);
15971602

15981603
if (!$this->processSpecialVariable($key, $value)) {
15991604
$this->processVariable($key, $value);
@@ -1886,12 +1891,25 @@ private function handleStandardVariable(string $ident, mixed $value): bool
18861891
return false;
18871892
}
18881893

1889-
// Spezialfall child_lock: Konvertiere zu LOCK/UNLOCK
1890-
if ($ident === 'child_lock' && is_bool($value)) {
1891-
$value = $value ? 'LOCK' : 'UNLOCK';
1892-
}
1893-
// Standard: Konvertiere andere boolesche Werte zu ON/OFF
1894-
elseif (is_bool($value)) {
1894+
// Bei Boolean-Werten prüfen, ob es ein spezielles Mapping gibt
1895+
if (is_bool($value)) {
1896+
$exposes = $this->ReadAttributeArray(self::ATTRIBUTE_EXPOSES);
1897+
foreach ($exposes as $expose) {
1898+
$features = isset($expose['features']) ? $expose['features'] : [$expose];
1899+
foreach ($features as $feature) {
1900+
if (isset($feature['property']) && $feature['property'] === $ident &&
1901+
isset($feature['value_on']) && isset($feature['value_off']) &&
1902+
$feature['type'] === 'binary') {
1903+
1904+
// Benutzerdefinierte Werte verwenden
1905+
$value = $value ? $feature['value_on'] : $feature['value_off'];
1906+
$payload = [$ident => $value];
1907+
return $this->SendSetCommand($payload);
1908+
}
1909+
}
1910+
}
1911+
1912+
// Fallback auf Standard ON/OFF
18951913
$value = $value ? 'ON' : 'OFF';
18961914
}
18971915

@@ -2232,26 +2250,34 @@ private function adjustValueByType(array $variableObject, mixed $value): mixed
22322250
return $value;
22332251
}
22342252
if (is_string($value)) {
2235-
// Spezialbehandlung für child_lock
2236-
if ($ident === 'child_lock') {
2237-
if (strtoupper($value) === 'LOCK') {
2238-
$this->SendDebug(__FUNCTION__, 'Konvertiere "LOCK" zu true', 0);
2239-
return true;
2240-
} elseif (strtoupper($value) === 'UNLOCK') {
2241-
$this->SendDebug(__FUNCTION__, 'Konvertiere "UNLOCK" zu false', 0);
2242-
return false;
2253+
// Exposes-Daten für diesen Identifier abrufen
2254+
$exposes = $this->ReadAttributeArray(self::ATTRIBUTE_EXPOSES);
2255+
foreach ($exposes as $expose) {
2256+
// Features durchsuchen
2257+
$features = isset($expose['features']) ? $expose['features'] : [$expose];
2258+
foreach ($features as $feature) {
2259+
if (isset($feature['property']) && $feature['property'] === $ident &&
2260+
isset($feature['value_on']) && isset($feature['value_off']) &&
2261+
$feature['type'] === 'binary') {
2262+
2263+
// Prüfen ob der Wert dem value_on entspricht
2264+
if ($value == $feature['value_on']) {
2265+
return true;
2266+
}
2267+
// Prüfen ob der Wert dem value_off entspricht
2268+
elseif ($value == $feature['value_off']) {
2269+
return false;
2270+
}
2271+
}
22432272
}
22442273
}
2245-
// Standard ON/OFF Konvertierung
2274+
// Standard ON/OFF Prüfung als Fallback
22462275
if (strtoupper($value) === 'ON') {
2247-
$this->SendDebug(__FUNCTION__, 'Konvertiere "ON" zu true', 0);
22482276
return true;
22492277
} elseif (strtoupper($value) === 'OFF') {
2250-
$this->SendDebug(__FUNCTION__, 'Konvertiere "OFF" zu false', 0);
22512278
return false;
22522279
}
22532280
}
2254-
$this->SendDebug(__FUNCTION__, 'Konvertiere zu bool: ' . json_encode((bool) $value), 0);
22552281
return (bool) $value;
22562282
case 1:
22572283
$this->SendDebug(__FUNCTION__, 'Konvertiere zu int: ' . (int) $value, 0);
@@ -2709,7 +2735,6 @@ private function convertLabelToName(string $label): string
27092735
*
27102736
*
27112737
* @see \Zigbee2MQTT\ModulBase::registerStateMappingProfile()
2712-
* @see \Zigbee2MQTT\ModulBase::registerStringProfile()
27132738
* @see \Zigbee2MQTT\ModulBase::getStandardProfile()
27142739
* @see \Zigbee2MQTT\ModulBase::isValidStandardProfile()
27152740
* @see \Zigbee2MQTT\ModulBase::handleProfileType()
@@ -2754,7 +2779,23 @@ private function registerVariableProfile(array $expose): string
27542779
) {
27552780
return '~Switch';
27562781
} else {
2757-
return $this->registerStringProfile($ProfileName, (string) $valueOn, (string) $valueOff);
2782+
// Erstelle Profilwerte für boolean-Variable
2783+
$profileValues = [
2784+
[false, $this->convertLabelToName($valueOff), '', 0xFF0000], // Rot für Aus (false)
2785+
[true, $this->convertLabelToName($valueOn), '', 0x00FF00] // Grün für An (true)
2786+
];
2787+
2788+
// Registriere das Boolean-Profil direkt
2789+
$this->RegisterProfileBooleanEx(
2790+
$ProfileName,
2791+
'Power', // Icon
2792+
'', // Prefix
2793+
'', // Suffix
2794+
$profileValues
2795+
);
2796+
2797+
$this->SendDebug(__FUNCTION__, 'Custom Boolean-Profil erstellt: ' . $ProfileName . ' mit Werten: ' . json_encode($profileValues), 0);
2798+
return $ProfileName;
27582799
}
27592800
}
27602801
return '~Switch';
@@ -3237,44 +3278,6 @@ private function registerNumericProfile(array $expose): array
32373278
return ['mainProfile' => $fullRangeProfileName, 'presetProfile' => $presetProfileName];
32383279
}
32393280

3240-
/**
3241-
* registerStringProfile
3242-
*
3243-
* Erstellt ein benutzerdefiniertes Stringprofil für Variablen.
3244-
*
3245-
* Diese Methode erstellt ein Profil für String-Variablen mit benutzerdefinierten Wertenfür On/Off
3246-
*
3247-
* @param string $ProfileName Der eindeutige Name für das zu erstellende Profil (z.B. 'Z2M.CustomString')
3248-
* @param string $valueOn
3249-
* @param string $valueOff
3250-
*
3251-
* @return string Der Name des erstellten Profils
3252-
*
3253-
* @see \Zigbee2MQTT\ModulBase::RegisterProfileStringEx()
3254-
* @see \IPSModule::SendDebug()
3255-
* @see json_encode()
3256-
*/
3257-
private function registerStringProfile(string $ProfileName, string $valueOn, string $valueOff): string
3258-
{
3259-
// Erstelle Profilwerte
3260-
$profileValues = [
3261-
[$valueOff, $this->convertLabelToName($valueOff),'', 0xFF0000], // Rot für Aus
3262-
[$valueOn, $this->convertLabelToName($valueOff) ,'', 0x00FF00] // Grün für An
3263-
];
3264-
3265-
// Registriere das Profil
3266-
$this->RegisterProfileStringEx(
3267-
$ProfileName,
3268-
'Power', // Icon
3269-
'', // Prefix
3270-
'', // Suffix
3271-
$profileValues
3272-
);
3273-
3274-
$this->SendDebug(__FUNCTION__, 'Custom String-Profil erstellt: ' . $ProfileName . ' mit Werten: ' . json_encode($profileValues), 0);
3275-
return $ProfileName;
3276-
}
3277-
32783281
/**
32793282
* registerPresetProfile
32803283
*

libs/locale_z2m.json

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@
301301
"Calibration Time": "Kalibrierungszeit",
302302
"Calibration Time Left": "Kalibrierzeit links",
303303
"Calibration Time Right": "Kalibrierzeit Rechts",
304+
"Cancel": "Abbrechen",
304305
"Cancel Adaptation": "Anpassung abbrechen",
305306
"Cancun": "Cancún",
306307
"Candle": "Kerze",
@@ -532,6 +533,7 @@
532533
"Dimming Speed Up Local": "Lokale Dimmgeschwindigkeit Hoch",
533534
"Dimming Speed Up Remote": "Funk Dimmgeschwindigkeit Hoch",
534535
"Direction": "Richtung",
536+
"DISABLE": "Deaktivieren",
535537
"Disarm": "Deaktivieren",
536538
"Display Auto Off": "Display Auto Abschaltung",
537539
"Display Auto Off Enabled": "Bildschirm automatisch ausschalten",
@@ -613,6 +615,7 @@
613615
"Emerald Isle": "Grüne Insel",
614616
"Emergency": "Notfall",
615617
"Emergency Panic": "Notfall-Panik",
618+
"ENABLE": "Aktivieren",
616619
"Enable Abc": "ABC aktivieren",
617620
"Enable Gas": "Gas aktivieren",
618621
"Enable Humidity": "Aktiviere Feuchtigkeit",
@@ -996,6 +999,7 @@
996999
"Low Temperature": "Geringe Temperatur",
9971000
"Low Water Temp Protection": "Schutz vor niedriger Wassertemperatur",
9981001
"Lower": "Niedriger",
1002+
"Lower Alarm": "Unterer Alarm",
9991003
"LTARF": "LTARF",
10001004
"Luminance Level": "Luminanzstufe",
10011005
"Magenta": "Lila",
@@ -1163,6 +1167,7 @@
11631167
"Normal Schedule Timer 2": "Normaler Zeitplan-Timer 2",
11641168
"Normal Schedule Timer 3": "Normaler Zeitplan-Timer 3",
11651169
"Normal Schedule Timer 4": "Normaler Zeitplan-Timer 4",
1170+
"Normal State": "Status Normal",
11661171
"not connected": "Nicht verbunden",
11671172
"NTARF": "NTARF",
11681173
"O Sensitivity": "O Sensibilität",
@@ -1191,7 +1196,7 @@
11911196
"Off Transition Time": "Übergangszeit Aus",
11921197
"Off/On": "Aus/An",
11931198
"Off/on": "Off/on",
1194-
"On\/off Status": "Ein/Aus Status",
1199+
"On Off Status": "Ein/Aus Status",
11951200
"Office": "Büro",
11961201
"Okay": "Okay",
11971202
"On": "An",
@@ -1209,12 +1214,13 @@
12091214
"On Press Release": "An losgelassen",
12101215
"On Transition Time": "Übergangszeit Ein",
12111216
"On/off": "An/Aus",
1212-
"On\/Off Status": "On/Off Status",
12131217
"Online": "Online",
12141218
"Only Pir": "Nur PIR",
12151219
"Only Radar": "Nur Radar",
12161220
"Opal": "Opal",
12171221
"Open": "Öffnen",
1222+
"Open Alarm Time": "Alarmzeit Offen",
1223+
"Open Time Alarm": "Alarm Öffnungszeit",
12181224
"Open Window": "Fenster offen",
12191225
"Open window detected": "Offenes Fenster entdeckt",
12201226
"Open Window Temperature": "Temperatur bei Fenster offen",
@@ -1298,6 +1304,10 @@
12981304
"Power on behavior L2": "Einschaltverhalten nach Stromausfall L2",
12991305
"Power on behavior L3": "Einschaltverhalten nach Stromausfall L3",
13001306
"Power on behavior L4": "Einschaltverhalten nach Stromausfall L4",
1307+
"Power On Behavior L1": "Einschaltverhalten nach Stromausfall L1",
1308+
"Power On Behavior L2": "Einschaltverhalten nach Stromausfall L2",
1309+
"Power On Behavior L3": "Einschaltverhalten nach Stromausfall L3",
1310+
"Power On Behavior L4": "Einschaltverhalten nach Stromausfall L4",
13011311
"Power On Behavior Left": "Einschaltverhalten Links",
13021312
"Power On Behavior Right": "Einschaltverhalten Rrechts",
13031313
"Power Outage Count": "Stromausfall Zähler",
@@ -1336,19 +1346,28 @@
13361346
"Preset": "Voreinstellung",
13371347
"Press": "Drücken",
13381348
"Press 1": "Drücke 1",
1349+
"Press 1 And 2": "Drücke 1 und 2",
1350+
"Press 1 And 2 And 3": "Drücke 1 und 2 und 3",
1351+
"Press 1 And 3": "Drücke 1 und 3",
1352+
"Press 1 And 3 And 4": "Drücke 1 und 3 und 4",
1353+
"Press 1 And 4": "Drücke 1 und 4",
13391354
"Press 1 and 2": "Drücke 1 und 2",
13401355
"Press 1 and 2 and 3": "Drücke 1 und 2 und 3",
13411356
"Press 1 and 3": "Drücke 1 und 3",
13421357
"Press 1 and 3 and 4": "Drücke 1 und 3 und 4",
13431358
"Press 1 and 4": "Drücke 1 und 4",
13441359
"Press 2": "Drücke 2",
1360+
"Press 2 And 3 And 4": "Drücke 2 und 3 und 4",
1361+
"Press 2 And 4": "Drücke 2 und 4",
13451362
"Press 2 and 3 and 4": "Drücke 2 und 3 und 4",
13461363
"Press 2 and 4": "Drücke 2 und 4",
13471364
"Press 3": "Drücke 3",
1365+
"Press 3 And 4": "Drücke 3 und 4",
13481366
"Press 3 and 4": "Drücke 3 und 4",
13491367
"Press 4": "Drücke 4",
13501368
"Press all": "Drücke alle",
13511369
"Press energy bar": "Drücke Energieleiste",
1370+
"Press Energy Bar": "Drücke Energieleiste",
13521371
"Pressure": "Luftdruck",
13531372
"Pressure Offset": "Luftdruck Bereich",
13541373
"Previous": "Vorherig",
@@ -1411,8 +1430,10 @@
14111430
"Release": "Loslassen",
14121431
"Release 1": "Freigabe 1",
14131432
"Release 1 and 3": "Freigabe 1 und 3",
1433+
"Release 1 And 3": "Freigabe 1 und 3",
14141434
"Release 2": "Freigabe 2",
14151435
"Release 2 and 4": "Freigabe 2 und 4",
1436+
"Release 2 And 4": "Freigabe 2 und 4",
14161437
"Release 3": "Freigabe 3",
14171438
"Release 4": "Freigabe 4",
14181439
"Reliability": "Zuverlässigkeit",
@@ -1465,6 +1486,8 @@
14651486
"Rotate Stop": "Drehen anhalten",
14661487
"Rssi": "Rssi",
14671488
"Ruby Romance": "Rubinromantik",
1489+
"Run Time": "Laufzeit",
1490+
"Run Time Alarm": "Laufzeit Alarm",
14681491
"Running": "In Betrieb",
14691492
"Running Mode": "Betriebsmodus",
14701493
"Running State": "Betriebsstatus",
@@ -1781,7 +1804,7 @@
17811804
"Target Temp First": "Soll-Temperatur zuerst",
17821805
"Tds": "Tds",
17831806
"Temperature": "Temperatur",
1784-
"Temperature Accuracy": "Temperaturgenauigkeit",
1807+
"Temperature Accuracy": "Temperaturgenauigkeit",
17851808
"Temperature Alarm": "Temperatur Alarm",
17861809
"Temperature Breaker": "Temperatursicherung",
17871810
"Temperature Calibration": "Temperatur Kalibrierung",
@@ -1886,7 +1909,7 @@
18861909
"TransAction": "Transaktion",
18871910
"Transitions": "Übergänge",
18881911
"Transmit Power": "Sendeleistung",
1889-
"Trigger": "Erkennen",
1912+
"Trigger": "Auslösen",
18901913
"Trigger Adaptation Process": "Kalibrierung Starten",
18911914
"Trigger Count": "Auslöseanzahl",
18921915
"Trigger Indicator": "Auslöser-Indikator",
@@ -1961,6 +1984,7 @@
19611984
"Update State": "Update: Status",
19621985
"Upper": "Höherer",
19631986
"Upper Temp": "Obere Temperatur",
1987+
"Upper Alarm": "Oberer Alarm",
19641988
"Urms 1": "Urms 1",
19651989
"Urms 2": "Urms 2",
19661990
"Urms 3": "Urms 3",
@@ -2028,8 +2052,10 @@
20282052
"Warmest": "Sehr warm",
20292053
"WarmWhite": "Warmes Weiß",
20302054
"Warmwhite": "Warmes Weiß",
2055+
"Warm White": "Warmes Weiß",
20312056
"WarmYellow": "Warmes Gelb",
20322057
"Warmyellow": "Warmes Gelb",
2058+
"Warm Yellow": "Warmes Gelb",
20332059
"Warning": "Warnung",
20342060
"Warning Duration": "Warnung Dauer",
20352061
"Warning Level": "Warnung Level",
@@ -2040,6 +2066,9 @@
20402066
"Water Consumed": "Wasserverbrauch",
20412067
"Water Flow": "Wasserfluss",
20422068
"Water Leak": "Wasserleck",
2069+
"Water Leakage": "Wasserleck",
2070+
"Water Shortage": "Wasserknappheit",
2071+
"Water Shortage & Water Leakage": "Wassermangel und Wasserlecks",
20432072
"Weather Delay": "Wetter Verzögerung",
20442073
"Wednesday": "Mittwoch",
20452074
"Wednesday Hour 1": "Mittwoch Stunde 1",

0 commit comments

Comments
 (0)