Skip to content

Commit

Permalink
improve code
Browse files Browse the repository at this point in the history
  • Loading branch information
zoic21 authored Jan 19, 2024
1 parent 4202aec commit 786a48f
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions core/class/z2m.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1081,14 +1081,16 @@ public static function convertXYToRGB($x, $y, $bri = 255) {
/* * *********************Methode d'instance************************* */

public function preSave(){
$logicalId = $this->getLogicalId();
if(strlen($logicalId) > 254){
if(strpos($logicalId,'%') === false){
$this->setConfiguration('logicalId',$logicalId);
$this->setLogicalId(substr($logicalId,0,254).'%');
if(version_compare(jeedom::version(), '4.4.2') < 0){
$logicalId = $this->getLogicalId();
if(strlen($logicalId) > 254){
if(strpos($logicalId,'%') === false){
$this->setConfiguration('logicalId',$logicalId);
$this->setLogicalId(substr($logicalId,0,254).'%');
}
}else{
$this->setConfiguration('logicalId',null);
}
}else{
$this->setConfiguration('logicalId',null);
}
}

Expand Down Expand Up @@ -1120,7 +1122,11 @@ public function execute($_options = array()) {
}
break;
}
$logicalId = $this->getConfiguration('logicalId',$this->getLogicalId());
if(version_compare(jeedom::version(), '4.4.2') < 0){
$logicalId = $this->getConfiguration('logicalId',$this->getLogicalId());
}else{
$logicalId = $this->getLogicalId();
}

$subTopic = $this->getConfiguration('subPayload');
if(strpos($logicalId,'json::') === 0){
Expand Down

0 comments on commit 786a48f

Please sign in to comment.