Skip to content

Commit

Permalink
check & update JSON: updates: 'tuyaEF00/fromDevice' => 'private/EF00'
Browse files Browse the repository at this point in the history
  • Loading branch information
tcharp38 committed Mar 19, 2024
1 parent 28a91f1 commit 3e45296
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .tools/check_json.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ function checkDeviceModel($devModName, $dev) {

$pKeyLen = strlen($pKey);
$pType = $pVal['type'];

if ($pType == "xiaomi") {
if ($pKeyLen != 9) { // Expecting CLUSTID-ATTRID
newDevError($devModName, "ERROR", "Xiaomi private support: Invalid key '${pKey}'");
Expand Down Expand Up @@ -370,6 +371,44 @@ function checkDeviceModel($devModName, $dev) {
}
}
}

/* Tuya DP case
"EF00": {
"type": "tuya",
"05": { // DP
"function": "rcvValue",
"info": "01-measuredValue"
},
},
*/
else if ($pType == "tuya") {
if ($pKeyLen != 4) { // Expecting CLUSTID
newDevError($devModName, "ERROR", "Tuya DP private support: Invalid key '${pKey}'");
continue;
}

foreach ($private[$pKey] as $dpId => $dpVal) {
if ($dpId == "type")
continue;

if (!isset($dpVal['function'])) {
$error = newDevError($devModName, "ERROR", "Missing 'function' for private/${pKey}");
continue;
}
$func = $dpVal['function'];
$supportedFunc = ['rcvValue', 'rcvValueDiv', 'rcvValueMult', 'rcvValue0Is1'];
if (!in_array($func, $supportedFunc)) {
$error = newDevError($devModName, "ERROR", "Invalid function '${func}' for private/${pKey} DP ${dpId}");
continue;
}
if ($func == 'rcvValueDiv') {
if (!isset($dpVal['div'])) {
$error = newDevError($devModName, "ERROR", "Missing 'div' for DP '${dpId}' in private/${pKey}");
continue;
}
}
}
}
}
}

Expand Down
14 changes: 14 additions & 0 deletions .tools/update_json.php
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,20 @@ function updateDevice($devName, $fullPath, $dev) {
$devUpdated = true;
echo " 'xiaomi' updated to 'private'.\n";
}
// tuyaEF00/fromDevice => private + type=tuya
if (isset($dev[$devName]['tuyaEF00'])) {
if (isset($dev[$devName]['tuyaEF00']['fromDevice'])) {
$dev[$devName]['private'] = [];
$dev[$devName]['private']['EF00'] = [];
$dev[$devName]['private']['EF00']['type'] = 'tuya';
foreach ($dev[$devName]['tuyaEF00']['fromDevice'] as $dpId => $dpVal) {
$dev[$devName]['private']['EF00'][$dpId] = $dpVal;
}
}
unset($dev[$devName]['tuyaEF00']);
$devUpdated = true;
echo " 'tuyaEF00/fromDevice' updated to 'private/EF00'.\n";
}

if ($devUpdated) {
$text = json_encode($dev, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
Expand Down
1 change: 1 addition & 0 deletions docs/fr_FR/Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ ChangeLog
- Interne: Configuration sur 'device announce' déplacée de Parser vers Cmd.
- Réseau: Affichage table des liens Zigate 1 à l'ouverture.
- SonOff ZbminiL2: Correction 'mac capa' incorrect => 'RxOnWhenIdle'.
- Interne: Mises-à-jour 'check_json' + 'update_json' pour changement 'tuyaEF00/fromDevice' => 'private/EF00'.

240308-BETA-1
-------------
Expand Down

0 comments on commit 3e45296

Please sign in to comment.