Note de ce sujet :
  • Moyenne : 0 (0 vote(s))
  • 1
  • 2
  • 3
  • 4
  • 5
Intégration shelly PRO em
#1
EDIT 02/07/2024
Des modifications sur la V11 empêche la reprise du fichier des versions précédentes (Reboot).
Fichier Source_ShellyEm.ino modifié pour la V11 ici : https://uploadnow.io/f/PkNvnnT


Bonjour,
Je me suis lancé dans la conception du routeur.
Problème rencontré, je dispose d'un Shelly Pro Em.
Hors la requête HTTP à effectuer est différente d'un shelly EM classique, et la réponse JSON également.
J'ai dû modifier le code source dans le fichier Source_ShellyEm.ino

Voici les modifications effectuées pour un shelly PRO em.
Si cela pouvait être intégré aux prochaines version se serait top.



La requête : http://IP_SHELLY/rpc/shelly.getstatus

Modification du fichier Source_ShellyEm.ino

Déclaration à ajouter pour la récupération
String tmp;

Modification de la requête http :
String url = "/rpc/Shelly.GetStatus";

Modification de la partie commenté Monophasé

Code :
//Monophasé

    //***************** ADD PERSO : PRO EM ******************
    ShEm_dataBrute = "<strong>Monophasé</strong><br>" + Shelly_Data;
   
    tmp=PrefiltreJson("em1:"+ String(Voie),":",Shelly_Data);

    //Récupération partie pince sur la voie paramètré
    Pw = ValJson("act_power",tmp);
    voltage = ValJson("voltage",tmp);
    pf = ValJson("pf",tmp);
    pf = abs(pf);
    if (pf > 1) pf = 1;
    if (Voie == voie) {  //voie du routeur
      if (Pw >= 0) {
          PuissanceS_M_inst = Pw;
          PuissanceI_M_inst = 0;
          if (pf > 0.01) {
            PVAS_M_inst = PfloatMax(Pw / pf);
          } else {
            PVAS_M_inst = 0;
          }
          PVAI_M_inst = 0;
        } else {
          PuissanceS_M_inst = 0;
          PuissanceI_M_inst = -Pw;
          if (pf > 0.01) {
            PVAI_M_inst = PfloatMax(-Pw / pf);
          } else {
            PVAI_M_inst = 0;
          }
          PVAS_M_inst = 0;
        }
        tmp=PrefiltreJson("em1data:"+ String(Voie),":",Shelly_Data);
        Energie_M_Soutiree = myLongJson("total_act_energy",tmp);
        Energie_M_Injectee = myLongJson("total_act_ret_energy",tmp);
        PowerFactor_M = pf;
        Tension_M = voltage;
        Pva_valide=true;
      } else {  // voie secondaire
        if (LissageLong) {
          PwMoy2 = 0.2 * Pw + 0.8 * PwMoy2;  //Lissage car moins de mesure sur voie secondaire
          pfMoy2 = 0.2 * pf + 0.8 * pfMoy2;
          Pw = PwMoy2;
          pf = pfMoy2;
        }
        if (Pw >= 0) {
          PuissanceS_T_inst = Pw;
          PuissanceI_T_inst = 0;
          if (pf > 0.01) {
            PVAS_T_inst = PfloatMax(Pw / pf);
          } else {
            PVAS_T_inst = 0;
          }
          PVAI_T_inst = 0;
        } else {
          PuissanceS_T_inst = 0;
          PuissanceI_T_inst = -Pw;
          if (pf > 0.01) {
            PVAI_T_inst = PfloatMax(-Pw / pf);
          } else {
            PVAI_T_inst = 0;
          }
          PVAS_T_inst = 0;
        }
        tmp=PrefiltreJson("em1data:"+ String(Voie),":",Shelly_Data);
        Energie_T_Soutiree = myLongJson("total_act_energy",tmp);
        Energie_T_Injectee = myLongJson("total_act_ret_energy",tmp);
        PowerFactor_T = pf;
        Tension_T = voltage;
      }


NB : Voici le format du JSON
Code :
{
  "ble": {},
  "cloud": {
    "connected": true
  },
  "em1:0": {
    "id": 0,
    "current": 2.454,
    "voltage": 239.9,
    "act_power": 226.5,
    "aprt_power": 590.1,
    "pf": 0.62,
    "freq": 50,
    "calibration": "factory"
  },
  "em1:1": {
    "id": 1,
    "current": 1.782,
    "voltage": 239.9,
    "act_power": 426.4,
    "aprt_power": 429.6,
    "pf": 0.99,
    "freq": 50,
    "calibration": "factory"
  },
  "em1data:0": {
    "id": 0,
    "total_act_energy": 995515.84,
    "total_act_ret_energy": 106191.28
  },
  "em1data:1": {
    "id": 1,
    "total_act_energy": 477522.54,
    "total_act_ret_energy": 756.38
  },
  "eth": {
    "ip": null
  },
  "modbus": {},
  "mqtt": {
    "connected": false
  },
  "switch:0": {
    "id": 0,
    "source": "WS_in",
    "output": false,
    "temperature": {
      "tC": 37,
      "tF": 98.6
    }
  },
  "sys": {
    "mac": "34987A6XXXXX",
    "restart_required": false,
    "time": "17:13",
    "unixtime": 1718205196,
    "uptime": 419677,
    "ram_size": 243368,
    "ram_free": 117336,
    "fs_size": 524288,
    "fs_free": 192512,
    "cfg_rev": 22,
    "kvs_rev": 0,
    "schedule_rev": 15,
    "webhook_rev": 9,
    "available_updates": {},
    "reset_reason": 3
  },
  "wifi": {
    "sta_ip": "192.168.1.XX",
    "status": "got ip",
    "ssid": "Freebox-XXXX",
    "rssi": -50
  },
  "ws": {
    "connected": false
  }
}
Répondre


Messages dans ce sujet
Intégration shelly PRO em - par Raphael591 - 12-06-2024, 05:49 PM
RE: Intégration shelly PRO em - par F1ATB - 12-06-2024, 07:10 PM
RE: Intégration shelly PRO em - par Raphael591 - 12-06-2024, 07:16 PM
RE: Intégration shelly PRO em - par F1ATB - 12-06-2024, 07:18 PM
RE: Intégration shelly PRO em - par Raphael591 - 12-06-2024, 07:53 PM
RE: Intégration shelly PRO em - par DanielJ - 17-06-2024, 04:00 PM
RE: Intégration shelly PRO em - par Raphael591 - 23-06-2024, 03:33 PM
RE: Intégration shelly PRO em - par F1ATB - 23-06-2024, 04:31 PM
RE: Intégration shelly PRO em - par DanielJ - 26-06-2024, 12:36 PM
RE: Intégration shelly PRO em - par Raphael591 - 26-06-2024, 02:31 PM
RE: Intégration shelly PRO em - par F1ATB - 03-07-2024, 04:23 PM
RE: Intégration shelly PRO em - par DanielJ - 03-07-2024, 06:56 PM
RE: Intégration shelly PRO em - par Raphael591 - 03-07-2024, 10:01 PM
RE: Intégration shelly PRO em - par F1ATB - Hier, 08:31 AM

Atteindre :


Utilisateur(s) parcourant ce sujet : 1 visiteur(s)