Skip to content

Commit

Permalink
Tuya 2keysremote + enhancements rcvValueEnum
Browse files Browse the repository at this point in the history
  • Loading branch information
tcharp38 committed Nov 17, 2024
1 parent 7050c3a commit db753bd
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 0 deletions.
10 changes: 10 additions & 0 deletions core/config/devices/LISEZMOI.txt
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,16 @@ La syntaxe actuelle est la suivante :
"function": "rcvValue",
"info": "01-measuredValue"
},

// Fonctions supportées
// 'rcvValue'
// 'rcvValueEnum'
// "function": "rcvValueEnum",
// "enum": {
// "00": "single",
// "01": "double",
// "02": "long"
// }
},

"FCC0-0112": { // CLUSTID-ATTRID
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"TS0021__TZ3210_3ulg9kpo": {
"manufacturer": "Tuya",
"model": "LKWSZ211",
"type": "Tuya 2 keys remote",
"genericType": "Light",
"category": {
"light": "1"
},
"configuration": {
"icon": "Tuya-2KeysRemote",
"mainEP": "01",
"batteryType": "2x1.5V AAA"
},
"commands": {
"Battery-Percent": {
"use": "inf_zbAttr-0001-BatteryPercent",
"params": "ep=01"
},
"Click 1": {
"use": "inf_click",
"comment": "value = single, double or long",
"logicalId": "inf_click1",
"isVisible": 1
},
"Click 2": {
"use": "inf_click",
"comment": "value = single, double or long",
"logicalId": "inf_click2",
"isVisible": 1
}
},
"private": {
"EF00": {
"type": "tuya",
"01": {
"function": "rcvValueEnum",
"enum": {
"00": "single",
"01": "double",
"02": "long"
},
"comment": "00=single, 01=double, 02=long",
"info": "inf_click1"
},
"02": {
"function": "rcvValueEnum",
"enum": {
"00": "single",
"01": "double",
"02": "long"
},
"comment": "00=single, 01=double, 02=long",
"info": "inf_click2"
},
"10": {
"function": "rcvValue",
"info": "0001-01-0021"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"epCount":1,"endPoints":{"01":{"profId":"0104","devId":"0402","servClusters":{"0001":{"attributes":{"0000":{"dataType":"21","access":"05","value":0},"0020":{"dataType":"20","access":"05","value":0},"0021":{"dataType":"20","access":"05","value":0},"FFFD":{"dataType":"21","access":"05","value":1}},"commandsGenerated":"UNSUPPORTED","commandsReceived":"UNSUPPORTED"},"0500":{"attributes":{"0000":{"dataType":"30","access":"05","value":0},"0001":{"dataType":"31","access":"05","value":40},"0002":{"dataType":"19","access":"05","value":0},"0010":{"dataType":"F0","access":"07","value":"0000000000000000"},"0011":{"dataType":"20","access":"05","value":255},"FFFD":{"dataType":"21","access":"05","value":1}},"commandsReceived":"UNSUPPORTED","commandsGenerated":"UNSUPPORTED"},"EF00":{"attributes":{"0000":{"value":0}},"commandsReceived":"UNSUPPORTED","commandsGenerated":"UNSUPPORTED"},"0000":{"attributes":{"0000":{"dataType":"20","access":"05","value":3},"0001":{"dataType":"20","access":"05","value":66},"0002":{"dataType":"20","access":"05","value":0},"0003":{"dataType":"20","access":"05","value":1},"0004":{"dataType":"42","access":"05","value":"_TZ3210_3ulg9kpo"},"0005":{"dataType":"42","access":"05","value":"TS0021"},"0006":{"dataType":"42","access":"05","value":""},"0007":{"dataType":"30","access":"05","value":3},"FFDE":{"dataType":"20","access":"07","value":13},"FFFD":{"dataType":"21","access":"05","value":2},"FFFE":{"dataType":"30","access":"05","value":0},"FFE2":{"dataType":"20","access":"05","value":54},"FFE3":{"dataType":"48","access":"05","value":"00"}},"commandsGenerated":"UNSUPPORTED","commandsReceived":"UNSUPPORTED"},"0019":{"attributes":{"0008":{"value":65535},"0009":{"value":0},"FFFD":{"value":3},"0000":{"value":"FFFFFFFFFFFFFFFF"},"0001":{"value":4294967295},"0002":{"value":66},"0003":{"value":2},"0004":{"value":4294967295},"0006":{"value":0}}},"000A":{"attributes":{"FFFD":{"value":1}}}},"cliClusters":{"0019":{"attributes":{"0000":{},"0001":{},"0002":{},"0003":{},"0004":{},"0005":{},"0006":{},"0007":{},"0008":{},"0009":{},"FFFD":{}}},"000A":{"attributes":{"FFFD":{}}}}}},"powerSource":"battery","fileSignature":"Abeille discovery file"}
19 changes: 19 additions & 0 deletions core/php/AbeilleParser-Tuya.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ function tuyaDecodeDp($addr, $ep, $dp, $mapping) {
$info = "undefined-info";
$div = 1; // For optional value division
$mult = 1; // For optional value multiplication
$enum = []; // For rcvValueEnum
if (isset($mapping[$dpId]['function'])) {
$func = $mapping[$dpId]['function'];
if (isset($mapping[$dpId]['info']))
Expand All @@ -131,6 +132,8 @@ function tuyaDecodeDp($addr, $ep, $dp, $mapping) {
$div = $mapping[$dpId]['div'];
if (isset($mapping[$dpId]['mult']))
$mult = $mapping[$dpId]['mult'];
if (isset($mapping[$dpId]['enum']))
$enum = $mapping[$dpId]['enum'];
} else
// This case should no longer be required. Obsolete !
$func = $mapping[$dpId];
Expand Down Expand Up @@ -218,6 +221,22 @@ function tuyaDecodeDp($addr, $ep, $dp, $mapping) {
'value' => $val,
);
break;
case "rcvValueEnum": // Converting value thru enum
$val = $dp['data'];
// parserLog2("debug", $addr, "val=$val => enum=".json_encode($enum));
if (isset($enum[$val]))
$valOut = $enum[$val];
else {
parserLog2("error", $addr, " '".$func."' for dpId=$dpId: Unknown enum");
$attributeN = false;
break;
}
$logMsg = " ".$dp['m']." => 'rcvValueEnum' => '".$info."'=".$valOut;
$attributeN = array(
'name' => $info,
'value' => $valOut,
);
break;

default:
parserLog2("error", $addr, " Unknown Tuya function '".$func."' for dpId=".$dpId);
Expand Down
3 changes: 3 additions & 0 deletions docs/fr_FR/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# ChangeLog

- Amélioration: Modèle pour Tuya 2 keys remote (2731).
- Amélioration: Support Tuya: Ajout function générique 'rcvValueEnum'.

## 241115-BETA-1

- Amélioration: Philips RWL021: Mise-à-jour modèle (1243).
Expand Down
Binary file added images/node_Tuya-2KeysRemote.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit db753bd

Please sign in to comment.