Bon ben même après avoir remis le TI.OBI comme d’origine ça ne fonctionne toujours pas.
Le contenu du data.json :
{
"option_tarifaire" : 2,
"tarif_courant" : 8,
"isousc" : 45,
"conso_base" : 0,
"conso_hc" : 0,
"conso_hp" : 0,
"conso_hc_b" : 000043160,
"conso_hp_b" : 000083202,
"conso_hc_w" : 000000000,
"conso_hp_w" : 000000000,
"conso_hc_r" : 000000000,
"conso_hp_r" : 000000000,
"type_imp_0" : 0,
"type_imp_1" : 1,
"type_imp_2" : 1,
"type_imp_3" : 1,
"type_imp_4" : 1,
"type_imp_5" : 1,
"label_entree1" : "Convecteurs ",
"label_entree2" : "Climatisation ",
"label_entree3" : "Plaque et Four ",
"label_entree4" : "LV et SL et L ",
"label_entree5" : "Cumulus ",
"label_entree_imp0" : "Gaz",
"label_entree_imp1" : "Eau",
"label_entree_imp2" : "Eau",
"label_entree_imp3" : "Eau",
"label_entree_imp4" : "Eau",
"label_entree_imp5" : "Eau",
"entree_imp0_disabled" : 0,
"entree_imp1_disabled" : 0,
"entree_imp2_disabled" : 1,
"entree_imp3_disabled" : 1,
"entree_imp4_disabled" : 1,
"entree_imp5_disabled" : 1
}
ça parrait OK mais toujours pas de Array après la ligne getInformations :
Quelque chose doit le déranger mais je vois pas quoi, je vais essayer de regarder le code, il doit y avoir une valeur hors limite attendue.
EDIT :
J’ai ajouté des logs pour mieux comprendre, il y a un nettoyage de la chaines json récupéré en 3 étapes :
[2021-03-29 21:39:01][DEBUG] : getInformations http://192.168.0.2/data.json
[2021-03-29 21:39:01][DEBUG] : { "option_tarifaire" : 2, "tarif_courant" : 8, "isousc" : 45, "conso_base" : 0, "conso_hc" : 0, "conso_hp" : 0, "conso_hc_b" : 000043160, "conso_hp_b" : 000083391, "conso_hc_w" : 000000000, "conso_hp_w" : 000000000, "conso_hc_r" : 000000000, "conso_hp_r" : 000000000, "type_imp_0" : 0, "type_imp_1" : 1, "type_imp_2" : 1, "type_imp_3" : 1, "type_imp_4" : 1, "type_imp_5" : 1, "label_entree1" : "Convecteurs ", "label_entree2" : "Climatisation ", "label_entree3" : "Plaque et Four ", "label_entree4" : "LV et SL et L ", "label_entree5" : "Cumulus ", "label_entree_imp0" : "Gaz", "label_entree_imp1" : "Eau", "label_entree_imp2" : "Eau", "label_entree_imp3" : "Eau", "label_entree_imp4" : "Eau", "label_entree_imp5" : "Eau", "entree_imp0_disabled" : 0, "entree_imp1_disabled" : 0, "entree_imp2_disabled" : 1, "entree_imp3_disabled" : 1, "entree_imp4_disabled" : 1, "entree_imp5_disabled" : 1 }
[2021-03-29 21:39:01][DEBUG] : {"option_tarifaire":2,"tarif_courant":8,"isousc":45,"conso_base":0,"conso_hc":0,"conso_hp":0,"conso_hc_b":000043160,"conso_hp_b":000083391,"conso_hc_w":000000000,"conso_hp_w":000000000,"conso_hc_r":000000000,"conso_hp_r":000000000,"type_imp_0":0,"type_imp_1":1,"type_imp_2":1,"type_imp_3":1,"type_imp_4":1,"type_imp_5":1,"label_entree1":"Convecteurs","label_entree2":"Climatisation","label_entree3":"PlaqueetFour","label_entree4":"LVetSLetL","label_entree5":"Cumulus","label_entree_imp0":"Gaz","label_entree_imp1":"Eau","label_entree_imp2":"Eau","label_entree_imp3":"Eau","label_entree_imp4":"Eau","label_entree_imp5":"Eau","entree_imp0_disabled":0,"entree_imp1_disabled":0,"entree_imp2_disabled":1,"entree_imp3_disabled":1,"entree_imp4_disabled":1,"entree_imp5_disabled":1}
[2021-03-29 21:39:01][DEBUG] : {"option_tarifaire":2,"tarif_courant":8,"isousc":45,"conso_base": 0,"conso_hc": 0,"conso_hp": 0,"conso_hc_b":000043160,"conso_hp_b":000083391,"conso_hc_w":000000000,"conso_hp_w":000000000,"conso_hc_r":000000000,"conso_hp_r":000000000,"type_imp_0": 0,"type_imp_1":1,"type_imp_2":1,"type_imp_3":1,"type_imp_4":1,"type_imp_5":1,"label_entree1":"Convecteurs","label_entree2":"Climatisation","label_entree3":"PlaqueetFour","label_entree4":"LVetSLetL","label_entree5":"Cumulus","label_entree_imp0":"Gaz","label_entree_imp1":"Eau","label_entree_imp2":"Eau","label_entree_imp3":"Eau","label_entree_imp4":"Eau","label_entree_imp5":"Eau","entree_imp0_disabled": 0,"entree_imp1_disabled": 0,"entree_imp2_disabled":1,"entree_imp3_disabled":1,"entree_imp4_disabled":1,"entree_imp5_disabled":1}
[2021-03-29 21:39:01][DEBUG] : {"option_tarifaire":2,"tarif_courant":8,"isousc":45,"conso_base": 0,"conso_hc": 0,"conso_hp": 0,"conso_hc_b":43160,"conso_hp_b":83391,"conso_hc_w":,"conso_hp_w":,"conso_hc_r":,"conso_hp_r":,"type_imp_0": 0,"type_imp_1":1,"type_imp_2":1,"type_imp_3":1,"type_imp_4":1,"type_imp_5":1,"label_entree1":"Convecteurs","label_entree2":"Climatisation","label_entree3":"PlaqueetFour","label_entree4":"LVetSLetL","label_entree5":"Cumulus","label_entree_imp0":"Gaz","label_entree_imp1":"Eau","label_entree_imp2":"Eau","label_entree_imp3":"Eau","label_entree_imp4":"Eau","label_entree_imp5":"Eau","entree_imp0_disabled": 0,"entree_imp1_disabled": 0,"entree_imp2_disabled":1,"entree_imp3_disabled":1,"entree_imp4_disabled":1,"entree_imp5_disabled":1}
Je dirais bien que ce qu’il ne lui plait pas c’est ça :
"conso_hc_w":,"conso_hp_w":,"conso_hc_r":,"conso_hp_r":
Il n’y a plus de chiffres. les 000000000 devrait se transformer en 0 et ce n’est pas le cas.
EDIT2 : j’ai corrigé le code, faudra que je vois avec Lunarok si j’ai raté un truc ou pas mais c’est bizarre que je sois le seul tombé dans ce cas.
EDIT3 :
@lunarok, je suis tombé, comme tu pourras le voir ci-dessus, sur un cas où le plugin ne remontait pas d’informations issue de data.json car pas d’index sur au moins un des champs dans un tarif bleu blanc rouge (Index : 000000000).
Du coup j’ai modifié la fonction comme ça. Que penses-tu de faire la modification à ton niveau ? C’est ok pour moi maintenant mais est-ce que ça flingue autre chose auquel je n’ai pas pensé ?
$corrected = preg_replace('/\s+/', '', $devResbis);
// $corrected = preg_replace('/\:0,/', ': 0,', $corrected); // ancienne ligne
$corrected = preg_replace('/\:[0]+/', ":", $corrected);
$corrected = preg_replace('/\:,/', ":0,", $corrected); // nouvelle ligne