Skip to content

Commit

Permalink
Merge pull request #19 from ThePiloo/beta
Browse files Browse the repository at this point in the history
Ajout d'une gestion des retours d'erreur lors du rafraichissement des infos via /HomeStatus
  • Loading branch information
zoic21 authored Apr 22, 2024
2 parents ca2e1f4 + 6f8ee0f commit 4d717d6
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
28 changes: 27 additions & 1 deletion core/class/netatmo.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,27 @@ public static function refreshClassNetatmo($homesdata = null){
}
foreach ($home_ids as $home_id) {
$homestatus = netatmo::request('/homestatus',array('home_id' => $home_id));
if(isset($homestatus['errors']) && count($homestatus['errors']) > 0){
$error_desc[1] = "Unknown error";
$error_desc[2] = "Internal error";
$error_desc[3] = "Parser error";
$error_desc[4] = "Command unknown node module error";
$error_desc[5] = "Command invalid params";
$error_desc[6] = "Unreachable";
$ModulesError = array();
foreach ($homestatus['errors'] as $deviceerror) {
$ModulesError[$deviceerror['id']] = $deviceerror['code'];
$eqLogic = eqLogic::byLogicalId($deviceerror['id'], 'netatmo');
if(!is_object($eqLogic)){
continue;
}
$Cmderrorinfo = $eqLogic->getCmd('info','error_status');
if(isset($Cmderrorinfo)){
log::add('netatmo','debug','[netatmo cloud] Erreur '.$deviceerror['code'].' détectée sur l\'équipement '.$deviceerror['id']);
$eqLogic->checkAndUpdateCmd("error_status",$deviceerror['code'].' '.$error_desc[$deviceerror['code']]);
}
}
}
if(isset($homestatus['home']) && isset($homestatus['home']['modules']) && count($homestatus['home']['modules']) > 0){
foreach ($homestatus['home']['modules'] as $module) {
if ($module['type']=="OTM" || $module['type']=="NATherm1") {
Expand All @@ -150,6 +171,11 @@ public static function refreshClassNetatmo($homesdata = null){
if($logicalId == 'state'){
$logicalId = 'status';
}
if($logicalId == 'error_status'){
if($logicalId == 'error_status' && !isset($ModulesError[$module['id']])) {
$eqLogic->checkAndUpdateCmd($cmd,'0 No error');
}
}
if(!isset($module[$logicalId])){
continue;
}
Expand All @@ -175,7 +201,7 @@ public static function refreshClassNetatmo($homesdata = null){
}
}
}
}
}
}

public static function cronHourly(){
Expand Down
8 changes: 8 additions & 0 deletions core/config/devices/NOC.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@
"isHistorized": 0,
"logicalId": "siren_status"
},
{
"name": "Etat Erreur",
"type": "info",
"subtype": "string",
"isVisible": 0,
"isHistorized": 0,
"logicalId": "error_status"
},
{
"name": "Connexion (Etat)",
"type": "info",
Expand Down

0 comments on commit 4d717d6

Please sign in to comment.