Skip to content

Commit

Permalink
eTRV010x + danfoss commands updates
Browse files Browse the repository at this point in the history
  • Loading branch information
tcharp38 committed Dec 1, 2023
1 parent 2dfa1c9 commit 9fb648b
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 27 deletions.
27 changes: 24 additions & 3 deletions core/class/AbeilleCmd.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,18 +198,39 @@ public function execute($_options = null) {
$lop = strpos($logicId, '#');
$logicId = substr($logicId, 0, $lop);
// logMessage('debug', "-- execute(): logicId=".$logicId);
$cmdLogic = $eqLogic->getCmd('info', $logicId);
if (!is_object($cmdLogic)) {
$cmdLogic2 = $eqLogic->getCmd('info', $logicId);
if (!is_object($cmdLogic2)) {
message::add("Abeille", $eqLogic->getHumanName().": Commande '".$logicId."' inconnue");
} else {
$cmdVal = $cmdLogic->execCmd();
$cmdVal = $cmdLogic2->execCmd();
logMessage('debug', "-- Cmd logicId='".$logicId."', val=".$cmdVal);
$vo = str_replace('#logicid'.$logicId.'#', $cmdVal, $vo); // Replace #logicid...#
}
}
$newValue = jeedom::evaluateExpression($vo); // Compute final formula
logMessage('debug', "-- 'valueOffset' applied: ".$_options['slider']." => ".$newValue);
$_options['slider'] = $newValue;
} else if (strpos($request, '#value#') !== false) {
// #value# must be replaced by valueOffset result
$lop = strpos($vo, '#logicid'); // Any #logicid....# variable ?
if ($lop != false) {
// logMessage('debug', "-- execute(): logicId at pos ".$lop);
$logicId = substr($vo, $lop + 8);
$lop = strpos($logicId, '#');
$logicId = substr($logicId, 0, $lop);
// logMessage('debug', "-- execute(): logicId=".$logicId);
$cmdLogic2 = $eqLogic->getCmd('info', $logicId);
if (!is_object($cmdLogic2)) {
message::add("Abeille", $eqLogic->getHumanName().": Commande '".$logicId."' inconnue");
} else {
$cmdVal = $cmdLogic2->execCmd();
logMessage('debug', "-- Cmd logicId='".$logicId."' => val=".$cmdVal);
$vo = str_replace('#logicid'.$logicId.'#', $cmdVal, $vo); // Replace #logicid...#
}
}
$newValue = jeedom::evaluateExpression($vo); // Compute final formula
$request = str_replace('#value#', $newValue, $request);
logMessage('debug', "-- 'valueOffset' applied: newValue=${newValue}");
}
}

Expand Down
6 changes: 3 additions & 3 deletions core/class/AbeilleCmdProcess.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -624,9 +624,9 @@ function setParam4($dest,$Command) {
*
* @return none
*/
function setParamGeneric($dest,$Command) {
function setParamGeneric($dest, $Command) {

cmdLog('debug', "command setParam4", $this->debug['processCmd']);
cmdLog('debug', " command setParamGeneric", $this->debug['processCmd']);

$priority = $Command['priority'];

Expand Down Expand Up @@ -658,7 +658,7 @@ function setParamGeneric($dest,$Command) {
$addrMode = "02";
$addr = $Command['address'];
$srcEp = "01";
if ($Command['destinationEndpoint']>1 ) { $dstEp = $Command['destinationEndpoint']; } else { $dstEp = "01"; } // $dstEp; // "01";
if ($Command['EP']>1 ) { $dstEp = $Command['EP']; } else { $dstEp = "01"; } // $dstEp; // "01";

$profId = "0104";
$clustId = $Command['clusterId'];
Expand Down
8 changes: 4 additions & 4 deletions core/class/AbeilleParser.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1921,8 +1921,8 @@ function decode8002_ZCLCorrectAttrValue($ep, $clustId, $eq, &$attr) {
$newVal = $newVal / 2; // Battery percent
}
} else if ($clustId == "0201") { // Thermostat
if ($attrId == "0000") {
$newVal /= 100; // Temperature
if (($attrId == "0000") || ($attrId == "0012")) {
$newVal /= 100; // LocalTemperature or OccupiedHeatingSetpoint
}
} else if ($clustId == "0300") {
if ($attrId == "0007") {
Expand Down Expand Up @@ -3362,7 +3362,7 @@ function decode8002($dest, $payload, $lqi) {
break; // Stop decode there

// Attribute value post correction according to ZCL spec
$correct = ['0001-0020', '0001-0021', '0201-0000', '0300-0007', '0400-0000', '0402-0000', '0403-0000', '0405-0000'];
$correct = ['0001-0020', '0001-0021', '0201-0000', '0201-0012', '0300-0007', '0400-0000', '0402-0000', '0403-0000', '0405-0000'];
if (in_array($clustId.'-'.$attr['id'], $correct))
$this->decode8002_ZCLCorrectAttrValue($srcEp, $clustId, $eq, $attr);

Expand Down Expand Up @@ -3583,7 +3583,7 @@ function decode8002($dest, $payload, $lqi) {
break;

// Attribute value post correction according to ZCL spec
$correct = ['0001-0020', '0001-0021', '0201-0000', '0300-0007', '0400-0000', '0402-0000', '0403-0000', '0405-0000'];
$correct = ['0001-0020', '0001-0021', '0201-0000', '0201-0012', '0300-0007', '0400-0000', '0402-0000', '0403-0000', '0405-0000'];
if (in_array($clustId.'-'.$attr['id'], $correct))
$this->decode8002_ZCLCorrectAttrValue($srcEp, $clustId, $eq, $attr);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"logicalId": "#EP#-danfossTemperatureConsigneValue",
"isHistorized": "1",
"subType": "numeric",
"template": "badge",
"invertBinary": "0",
"configuration": {
"calculValueOffset": "#value#\/100",
"visibilityCategory": "All"
},
"type": "info",
Expand Down
1 change: 1 addition & 0 deletions core/config/commands/inf_zbAttr-0201-LocalTemperature.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"comment": "0201/Thermostat cluster, attrib 0000/LocalTemperature",
"type": "info",
"subType": "numeric",
"template": "badge",
"configuration": [],
"logicalId": "0201-#EP#-0000",
"unit": "\u00b0C",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"comment": "0201/Thermostat cluster, attrib 0012/OccupiedHeatingSetpoint",
"type": "info",
"subType": "numeric",
"template": "badge",
"configuration": [],
"logicalId": "0201-#EP#-0012",
"unit": "\u00b0C",
Expand Down
2 changes: 1 addition & 1 deletion core/config/commands/zbWriteGenericAttribute.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"subType": "other",
"configuration": {
"topic": "WriteAttributeRequestGeneric",
"request": "ep=#EP#&Proprio=#PROPRIO#&clusterId=#CLUSTID#&attributeId=#ATTRID#&attributeType=#ATTRTYPE#&value=#VALUE#"
"request": "EP=#EP#&Proprio=#PROPRIO#&clusterId=#CLUSTID#&attributeId=#ATTRID#&attributeType=#ATTRTYPE#&value=#VALUE#"
},
"type": "action"
}
Expand Down
20 changes: 9 additions & 11 deletions core/config/devices/eTRV0100/eTRV0100.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,35 +53,33 @@
"use": "act_zbReadAttribute",
"params": "clustId=0001&attrId=0020"
},
"Set setpoint (OLD)": {
"use": "danfossTemperatureConsigneSet",
"nextLine": "after"
},
"+": {
"use": "act_zbWriteAttribute",
"params": "clustId=0201&attrId=0012&attrType=29&attrVal=#value#",
"valueOffset": "(#logicidsetpoint#+0.5)*100",
"valueOffset": "(#logicid0201-01-0012#+0.5)*100",
"comment": "Writing (setpoint value + 0.5) * 100",
"logicalId": "raiseSetpoint",
"isVisible": 1
},
"-": {
"use": "act_zbWriteAttribute",
"params": "clustId=0201&attrId=0012&attrType=29&attrVal=#value#",
"valueOffset": "(#logicidsetpoint#-0.5)*100",
"valueOffset": "(#logicid0201-01-0012#-0.5)*100",
"comment": "Writing (setpoint value - 0.5) * 100",
"logicalId": "lowerSetpoint",
"isVisible": 1
},
"Set temp (OLD)": {
"use": "danfossTemperatureConsigneSet"
},
"Get setpoint": {
"use": "danfossTemperatureConsigneGet"
"use": "act_zbReadAttribute",
"params": "clustId=0201&attrId=0012"
},
"Setpoint": {
"use": "inf_zbAttr-0201-OccupiedHeatingSetpoint",
"logicalId": "setpoint",
"isVisible": 1
},
"Setpoint OLD": {
"use": "danfossTemperatureConsigneValue",
"isVisible": 1,
"nextLine": "after"
},
"Get temp": {
Expand Down
3 changes: 3 additions & 0 deletions core/php/AbeilleCmd.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ function updateDeviceFromDB($eqId) {
return;
}

if (!isset($GLOBALS['devices'][$net]))
$GLOBALS['devices'][$net] = [];

$found = false;
if (isset($GLOBALS['devices'][$net][$addr]))
$found = true;
Expand Down
2 changes: 2 additions & 0 deletions docs/fr_FR/Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ ChangeLog
- Attribut 0000/LocalTemp du cluster 0201 divisé par 100 par défaut.
- Interne: Cmd: Correction 'writeAttribute0530()'
- Interne: Cmd: Corrections 'writeAttribute()'
- Attribut 0012/OccupiedHeatingSetpoint du cluster 0201 divisé par 100 par défaut.
- Danfoss eTRV010x: Modèle en cours de changements (2662).

231130-BETA-2
-------------
Expand Down
17 changes: 13 additions & 4 deletions plugin_info/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -961,16 +961,25 @@ function updateConfigDB() {

$saveCmd = false;
if ($cmdLogicId == 'online') {
if ($cmdLogic->setConfiguration('repeatEventManagement', '') == '') {
if ($cmdLogic->getConfiguration('repeatEventManagement', '') == '') {
$cmdLogic->setConfiguration('repeatEventManagement', "always");
log::add('Abeille', 'debug', " ${cmdHName}: Added 'repeatEventManagement'='always'");
$saveCmd = true;
}
// '0201-#EP#-0000': Removing 'calculValueOffset'
} else if (preg_match("/^0201-[0-9A-F]*-0000/", $cmdLogicId)) {
$cmdLogic->setConfiguration('calculValueOffset', null);
log::add('Abeille', 'debug', " ${cmdHName}: Removed 'calculValueOffset'");
$saveCmd = true;
if ($cmdLogic->getConfiguration('calculValueOffset', null) !== null) {
$cmdLogic->setConfiguration('calculValueOffset', null);
log::add('Abeille', 'debug', " ${cmdHName}: Removed 'calculValueOffset'");
$saveCmd = true;
}
// '0201-#EP#-0012': Removing 'calculValueOffset'
} else if (preg_match("/^0201-[0-9A-F]*-0012/", $cmdLogicId)) {
if ($cmdLogic->getConfiguration('calculValueOffset', null) !== null) {
$cmdLogic->setConfiguration('calculValueOffset', null);
log::add('Abeille', 'debug', " ${cmdHName}: Removed 'calculValueOffset'");
$saveCmd = true;
}
} else if ($topic == 'OnOff') {
$request = $cmdLogic->getConfiguration('request', '');
$request = str_replace("Action=Off", "cmd=00", $request);
Expand Down

0 comments on commit 9fb648b

Please sign in to comment.