Skip to content

Commit

Permalink
TS011F__TZ3000_ksw8qtmt model + parser read reporting config response
Browse files Browse the repository at this point in the history
  • Loading branch information
tcharp38 committed Nov 20, 2024
1 parent 76b0344 commit c926d61
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 360 deletions.
355 changes: 2 additions & 353 deletions core/class/AbeilleParser.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -3533,13 +3533,12 @@ function decode8002($dest, $payload, $lqi) {
// Reportable change => Variable size
// Note: no reportable change for boolean type
$attrSize = zbGetDataSize($attrType);
parserLog2('debug', $srcAddr, " AttrSize=$attrSize");
$change = substr($pl, 18, $attrSize * 2);
// parserLog2('debug', $srcAddr, " AttrSize=$attrSize");
$change = AbeilleTools::reverseHex(substr($pl, 18, $attrSize * 2)); // Reverse for attrSize>1

parserLog2('debug', $srcAddr, ' Status='.$status.'/'.zbGetZCLStatus($status).', Dir='.$dir.', AttrId='.$attrId
.', AttrType='.$attrType.', MinInterval='.$minInterval.', MaxInterval='.$maxInterval.", Change=$change");
} else {
// $msg = substr($msg, 8);
parserLog2('debug', $srcAddr, ' Status='.$status.'/'.zbGetZCLStatus($status).', Dir='.$dir.', AttrId='.$attrId);
}
}
Expand Down Expand Up @@ -5523,356 +5522,6 @@ function decode80A7($dest, $payload, $lqi) {
$this->whoTalked[] = $dest.'/'.$source;
} // End decode80A7()

// /* Common function for 8100 & 8102 messages */
// function decode8100_8102($type, $dest, $payload, $lqi) {
// //<Sequence number: uint8_t>
// //<Src address : uint16_t>
// //<Endpoint: uint8_t>
// //<Cluster id: uint16_t>
// //<Attribute Enum: uint16_t>
// //<Attribute status: uint8_t>
// //<Attribute data type: uint8_t>
// //<Size Of the attributes in bytes: uint16_t>
// //<Data byte list : stream of uint8_t>
// $sqn = substr($payload, 0, 2);
// $srcAddr = substr($payload, 2, 4);
// $ep = substr($payload, 6, 2);
// $clustId = substr($payload, 8, 4);
// $attrId = substr($payload, 12, 4);
// $attrStatus = substr($payload, 16, 2);
// $dataType = substr($payload, 18, 2);
// $attrSize = substr($payload, 20, 4);
// $Attribut = substr($payload, 24, hexdec($attrSize) * 2);

// if ($type == "8100") {
// $msgDecoded = '8100/Read individual attribute response';
// $cmdId = '01';
// } else {
// $msgDecoded = '8102/Attribute report';
// $cmdId = '0A';
// }
// $msgDecoded .= ', SQN=' .$sqn
// .', Addr=' .$srcAddr
// .', EP=' .$ep
// .', ClustId=' .$clustId
// .', AttrId=' .$attrId
// .', AttrStatus=' .$attrStatus
// .', AttrDataType=' .$dataType
// .', AttrSize=' .$attrSize;
// parserLog('debug', $dest.', Type='.$msgDecoded, $type);
// $toMon = [];
// $toMon[] = $msgDecoded;

// // Checking if decode is handled by 8002 or still there
// // $accepted = ['0000', '0001', '000C', '0400', '0402', '0403', '0405', 'FC00'];
// // $accepted = ['0000', 'FC00'];
// $accepted = ['0000'];
// if (!in_array($clustId, $accepted)) {
// parserLog('debug', " ".$clustId."-".$attrId." => Handled by decode8002");
// return;
// }

// $this->whoTalked[] = $dest.'/'.$srcAddr; // Tcharp38: Still useful ?
// if ($attrStatus != '00') {
// if ($attrStatus == '86')
// parserLog('debug', ' Status 86 => Unsupported attribute type ', $type);

// $unknown = false;
// $updates = [];
// if ($clustId == "0000") {
// switch ($attrId) {
// case "0004":
// $updates['manufId'] = false;
// break;
// case "0005":
// $updates['modelId'] = false;
// break;
// case "0010":
// $updates['location'] = false;
// break;
// default:
// break;
// }
// }
// $unknown = $this->deviceUpdates($dest, $srcAddr, $ep, $updates);
// if ($unknown)
// return; // This is an unknown device.

// /* Forwarding unsupported atttribute to Abeille */
// $attributes = [];
// $attributes[] = array(
// 'name' => $clustId.'-'.$ep.'-'.$attrId,
// 'value' => false, // False = unsupported
// );
// $toAbeille = array(
// // 'src' => 'parser',
// 'type' => 'attributesReportN',
// 'net' => $dest,
// 'addr' => $srcAddr,
// 'ep' => $ep,
// 'clustId' => $clustId,
// 'attributes' => $attributes,
// 'time' => time(),
// 'lqi' => $lqi
// );
// msgToAbeille2($toAbeille);

// /* Send to client if connection opened */
// $toCli = array(
// // 'src' => 'parser',
// 'type' => 'attributeReport', // 8100 or 8102
// 'net' => $dest,
// 'addr' => $srcAddr,
// 'ep' => $ep,
// 'clustId' => $clustId,
// 'attrId' => $attrId,
// 'status' => "86"
// );
// $this->msgToClient($toCli);

// // Monitor if requested
// if (isset($GLOBALS["dbgMonitorAddr"]) && !strcasecmp($GLOBALS["dbgMonitorAddr"], $srcAddr))
// monMsgFromZigate($msgDecoded); // Send message to monitor

// return;
// } // Status != 00

// // Status == 00

// /* Params: SrcAddr, ClustId, AttrId, Data */
// // $this->msgToAbeille($dest."/".$srcAddr, 'Link', 'Quality', $lqi);

// /* Treating message in the following order
// - by clustId
// - then attribId.
// If not treated there, then next steps will be
// - renaining custom cases that should be moved in first place
// - and finally direct conversion according to attrib type and return as it is
// */
// $data = null; // Data to push to Abeille
// if ($clustId == "0000") { // Basic cluster
// // TEST
// // if ($attrId == "0005") {
// // $Attribut = "53494E2D342D322D3230002000000014000000CCCB0020B1020100900000003D9F";
// // }
// // TEST END

// // Xiaomi lumi.sensor_86sw1 (Wall 1 Switch sur batterie)
// // if (($attrId == "FF01") && ($attrSize == "001B")) {
// // parserLog("debug"," Xiaomi proprietary (Wall 1 Switch, Gaz Sensor)" );
// // parserLog("debug"," WARNING !! This support should be moved to decode8002");

// // // For info until activation
// // xiaomiDecodeTags($dest, $srcAddr, $clustId, $attrId, $Attribut);
// // // For info until activation

// // // Dans le cas du Gaz Sensor, il n'y a pas de batterie alors le decodage est probablement faux.
// // $voltage = hexdec(substr($payload, 24 + 2 * 2 + 2, 2).substr($payload, 24 + 2 * 2, 2));
// // $etat = substr($payload, 80, 2);
// // parserLog('debug', ' Voltage=' .$voltage.', Voltage%='.$this->volt2pourcent($voltage).', Etat=' .$etat);
// // $attrReportN = [
// // array( "name" => "0006-01-0000", "value" => $etat ),
// // // array( "name" => "0001-01-0020", "value" => $voltage / 1000 ),
// // array( "name" => "0001-01-0021", "value" => $this->volt2pourcent($voltage) ),
// // ];
// // }

// // Xiaomi bouton Aqara Wireless Switch V3 #712 (https://github.com/KiwiHC16/Abeille/issues/712)
// if (($attrId == 'FF01') && ($attrSize == "0026")) {
// // Assuming $dataType == "42"
// parserLog('debug', ' Xiaomi proprietary (Aqara Wireless Switch V3)');
// parserLog("debug"," WARNING !! This support should be moved to decode8002 with 'private' section in model");

// // For info until activation
// xiaomiDecodeTagsDebug($dest, $srcAddr, $clustId, $attrId, $Attribut);
// // For info until activation

// $voltage = hexdec(substr($payload, 24 + 2 * 2 + 2, 2).substr($payload, 24 + 2 * 2, 2));
// parserLog('debug', ' Volt=' .$voltage.', Volt%='.$this->volt2pourcent($voltage));
// $attrReportN = [
// // array( "name" => "0001-01-0020", "value" => $voltage / 1000 ),
// array( "name" => "0001-01-0021", "value" => $this->volt2pourcent($voltage) ),
// ];
// }

// else {
// parserLog('debug', " ".$clustId."-".$attrId." => Handled by decode8002");
// return;
// }
// } // End cluster 0000

// // else if ($clustId == "000C") { // Analog input cluster
// // if ($attrId == "0055") {
// // // assuming $dataType == "39"

// // if ($ep == "01") {
// // // Remontée puissance (instantannée) relay double switch 1
// // // On va envoyer ca sur la meme variable que le champ ff01
// // $hexNumber = substr($payload, 24, 8);
// // $hexNumberOrder = $hexNumber[6].$hexNumber[7].$hexNumber[4].$hexNumber[5].$hexNumber[2].$hexNumber[3].$hexNumber[0].$hexNumber[1];
// // $bin = pack('H*', $hexNumberOrder);
// // $puissanceValue = unpack("f", $bin )[1];

// // // Relay Double
// // // $this->msgToAbeille($dest."/".$srcAddr, '000C', '01-0055', $puissanceValue);
// // $attrReportN = [
// // array( "name" => '000C-01-0055', "value" => $puissanceValue ),
// // ];
// // }
// // if (($ep == "02") || ($ep == "15")) {
// // // Remontée puissance (instantannée) de la prise xiaomi et relay double switch 2
// // // On va envoyer ca sur la meme variable que le champ ff01
// // $hexNumber = substr($payload, 24, 8);
// // $hexNumberOrder = $hexNumber[6].$hexNumber[7].$hexNumber[4].$hexNumber[5].$hexNumber[2].$hexNumber[3].$hexNumber[0].$hexNumber[1];
// // $bin = pack('H*', $hexNumberOrder );
// // $puissanceValue = unpack("f", $bin )[1];

// // // Relay Double - Prise Xiaomi
// // // $this->msgToAbeille($dest."/".$srcAddr, $clustId, $ep.'-'.$attrId, $puissanceValue);
// // $attrReportN = [
// // array( "name" => $clustId.'-'.$ep.'-'.$attrId, "value" => $puissanceValue ),
// // ];
// // }
// // if ($ep == "03") {
// // // Example Cube Xiaomi
// // // Sniffer dit Single Precision Floating Point
// // // b9 1e 38 c2 -> -46,03
// // // $data = hexdec(substr($payload, 24, 4));
// // // $data = unpack("s", pack("s", hexdec(substr($payload, 24, 4))))[1];
// // $hexNumber = substr($payload, 24, 8);
// // $hexNumberOrder = $hexNumber[6].$hexNumber[7].$hexNumber[4].$hexNumber[5].$hexNumber[2].$hexNumber[3].$hexNumber[0].$hexNumber[1];
// // $bin = pack('H*', $hexNumberOrder);
// // $value = unpack("f", $bin)[1];
// // $attrReportN = [
// // array( "name" => $clustId.'-'.$ep.'-'.$attrId, "value" => $value ),
// // ];
// // }
// // }
// // } // End cluster 000C

// // Philips Hue specific cluster
// // Used by RWL021, RDM001
// // Tcharp38: Where is the source of this decoding ?
// // else if ($clustId == "FC00") {
// // $buttonEventTxt = array (
// // '00' => 'Short press',
// // '01' => 'Long press',
// // '02' => 'Release short press',
// // '03' => 'Release long press',
// // );
// // $button = $attrId;
// // $buttonEvent = substr($payload, 24 + 2, 2);
// // $buttonDuree = hexdec(substr($payload, 24 + 6, 2));
// // parserLog("debug", " Philips Hue proprietary: Button=".$button.", Event=".$buttonEvent." (".$buttonEventTxt[$buttonEvent]."), duration=".$buttonDuree);

// // // $this->msgToAbeille($dest."/".$srcAddr, $clustId."-".$ep, $attrId."-Event", $buttonEvent);
// // // $this->msgToAbeille($dest."/".$srcAddr, $clustId."-".$ep, $attrId."-Duree", $buttonDuree);

// // // return;
// // // $data = hexdec($buttonEvent);

// // $attrReportN = [
// // array( "name" => $clustId."-".$ep."-".$attrId."-Event", "value" => $buttonEvent ),
// // array( "name" => $clustId."-".$ep."-".$attrId."-Duree", "value" => $buttonDuree ),
// // ];
// // }

// if (!isset($attrReportN) && !isset($data)) {
// /* Core hereafter is performing default conversion according to data type */

// /* Note: If $data is not set, then nothing to send to Abeille. This might be because data type is unsupported */
// $data = $this->decodeDataType(substr($payload, 24), $dataType, false, hexdec($attrSize), $oSize, $hexValue);
// if ($data === false)
// return; // Unsupported data type
// $attrName = zbGetZCLAttributeName($clustId, $attrId);
// parserLog('debug', ' '.$attrName.', ValueHex='.$hexValue.' => '.$data);
// }

// $unknown = false;
// // Clust 0000, attrib 0004/0005 & 0010 have dedicated deviceUpdate() call.
// if (($clustId != "0000") || (($attrId != "0004") && ($attrId != "0005") && ($attrId != "0010"))) {
// $unknown = $this->deviceUpdates($dest, $srcAddr, $ep);
// }

// // Tcharp38: deviceUpdate or discoveryUpdate ?
// // If discovering step, recording infos
// $discovering = $this->discoveringState($dest, $srcAddr);
// if ($discovering) {
// $isServer = 1;
// $attributes = [];
// $attributes[$attrId] = [];
// $attributes[$attrId]['value'] = $data;
// $this->discoverUpdate($dest, $srcAddr, $ep, 'ReadAttributesResponse', $clustId, $isServer, $attributes);
// }

// if ($unknown)
// return; // If unknown to Jeedom, nothing to send

// /* Forwarding atttribute value to Abeille */
// if (isset($attrReportN)) {
// $toAbeille = array(
// // 'src' => 'parser',
// 'type' => 'attributesReportN',
// 'net' => $dest,
// 'addr' => $srcAddr,
// 'ep' => $ep,
// 'clustId' => $clustId,
// 'attributes' => $attrReportN,
// 'time' => time(),
// 'lqi' => $lqi
// );
// msgToAbeille2($toAbeille);
// } else if (isset($data)) {
// $attributes = [];
// $attributes[] = array(
// 'name' => $clustId.'-'.$ep.'-'.$attrId,
// 'value' => $data,
// );
// $toAbeille = array(
// // 'src' => 'parser',
// 'type' => 'attributesReportN',
// 'net' => $dest,
// 'addr' => $srcAddr,
// 'ep' => $ep,
// 'clustId' => $clustId,
// 'attributes' => $attributes,
// 'time' => time(),
// 'lqi' => $lqi
// );
// msgToAbeille2($toAbeille);
// }

// /* Send to client if connection opened */
// $toCli = array(
// // 'src' => 'parser',
// 'type' => 'attributeReport', // 8100 or 8102
// 'net' => $dest,
// 'addr' => $srcAddr,
// 'ep' => $ep,
// 'clustId' => $clustId,
// 'attrId' => $attrId,
// 'status' => "00",
// 'value' => $data
// );
// $this->msgToClient($toCli);

// // Monitor if requested
// if (isset($toMon) && isset($GLOBALS["dbgMonitorAddr"]) && !strcasecmp($GLOBALS["dbgMonitorAddr"], $srcAddr))
// foreach ($toMon as $monMsg)
// monMsgFromZigate($monMsg); // Send message to monitor
// }

// /* 8100/Read individual Attribute Response */
// function decode8100($dest, $payload, $lqi) {
// $this->decode8100_8102("8100", $dest, $payload, $lqi);
// }

// /* Attribute report */
// function decode8102($dest, $payload, $lqi) {
// $this->decode8100_8102("8102", $dest, $payload, $lqi);
// }

/**
* 0x8701/Route Discovery Confirm - Warning: potential swap between statuses.
*
Expand Down
2 changes: 1 addition & 1 deletion core/config/Abeille.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Abeille's static config file
*/

define('lastDbVersion', 20241117);
define('lastDbVersion', 20241120);
$in = "/tmp/AbeilleDeamonInput";
$resourcePath = realpath(__DIR__.'/../../resources');
define('wifiLink', '/tmp/zigateWifi'); // For WIFI: Socat output
Expand Down
Loading

0 comments on commit c926d61

Please sign in to comment.