Messages : 17
Sujets : 2
Inscription : Aug 2024
Réputation :
1
(13-10-2024, 07:28 PM)manusaxo a écrit : Tu peux faire un envoi via une automatisation HA des valeurs nécessaires vers un Topic Mqtt.
Je viens d'installer la V12 et mon Shelly Pro3EM en triphasé n'est toujours pas interprété correctement.
Je suppose que André à privilégiez d'autres amélioration pour les utilisateurs cet hiver :-)
C'est vrai que cela sera plus simple, plus fiable, avec une interprétation direct du Shelly ProEM en triphasé et de l'ensemble des ses données. Je n'étais pas revenu sur ce sujet, mais c'est exactement ce que j'ai fait la semaine dernière. J'ai paramétré le MQTT en source de mesure et fait dans HA l'automatisation pour publier automatiquement les valeurs et ça marche très bien.
Messages : 74
Sujets : 2
Inscription : Jun 2024
Réputation :
11
14-10-2024, 10:43 AM
(Modification du message : 14-10-2024, 10:43 AM par Raphael591.)
Désolé André, j'avais développé la partie shelly pro 3 em en m’appuyant sur la documentation ayant la version pro EM (Monophasé).
Je ne m'attendais pas à ce que tu récupères mon code.
Visiblement il y a des subtilités avec le modèle triphasé !
Si je comprends bien il faudrait pouvoir détecter si le module pro 3 em est configuré en mono ou en tri car les données renvoyées sont différentes
Problème dans le code :
- On ne regarde pas le paramétrage si shelly pro EM ou shelly pro 3 em mais uniquement la voie (Si voie ==3 => shelly pro 3 em, sinon shelly pro EM)
Il faut modifier pour vérifier le paramétrage au lieu de tester la voie (Si pro EM ou pro 3 em).
- pro 3 em en mono, récupération JSON ok mais le code est erronée (on cumul les données des 3 pinces, hors il faut prendre uniquement la voie indiqué dans le paramétrage).
- pro 3 em en tri : Les données à récupérer :
pf et voltage ? : faire une moyenne sur les 3 pinces (a, b, c) ?
Triphasé
{ble:{}
bthome:{}
cloud:{connected:true}
em:0:{id:0
a_current:1.841
a_voltage:238.1
a_act_power:-380.9
a_pf:0.87
...
total_act_power:2633.595
total_act:320248.38
total_act_ret:90747.51}
eth:{ip:null}
modbus:{}
...
ws:{connected:false}}
Si ça peut aider !
Routeur avec Triac, CE 2500w. Shelly pro em50 pour les mesures. Kit PV pnp 2 kW. Home assistant
Messages : 74
Sujets : 2
Inscription : Jun 2024
Réputation :
11
Ceux qui on un shelly pro 3 em pouvez vous m'envoyer la réponse à cette requête avec l'IP de votre shelly :
http://192.168.1.XX/rpc/Shelly.GetDeviceInfo
Merci.
ça permettra d'identifier si shelly pro em ou shelly pro 3 em.
Routeur avec Triac, CE 2500w. Shelly pro em50 pour les mesures. Kit PV pnp 2 kW. Home assistant
Messages : 17
Sujets : 2
Inscription : Aug 2024
Réputation :
1
14-10-2024, 01:05 PM
(Modification du message : 14-10-2024, 01:07 PM par olivr2s.)
(14-10-2024, 12:37 PM)Raphael591 a écrit : Ceux qui on un shelly pro 3 em pouvez vous m'envoyer la réponse à cette requête avec l'IP de votre shelly :
http://192.168.1.XX/rpc/Shelly.GetDeviceInfo
Merci.
ça permettra d'identifier si shelly pro em ou shelly pro 3 em.
{"name":null,"id":"shellypro3em-xxx9e0e9dxxx","mac":"xxx9E0E9Dxxx","slot":1,"model":"SPEM-003CEBEU","gen":2,"fw_id":"20240822-121054/1.4.3-g143ff62","ver":"1.4.3","app":"Pro3EM","auth_en":false,"auth_domain":null,"profile":"triphase"}
Messages : 74
Sujets : 2
Inscription : Jun 2024
Réputation :
11
14-10-2024, 02:00 PM
(Modification du message : 14-10-2024, 02:18 PM par Raphael591.)
test en cours
Routeur avec Triac, CE 2500w. Shelly pro em50 pour les mesures. Kit PV pnp 2 kW. Home assistant
Messages : 74
Sujets : 2
Inscription : Jun 2024
Réputation :
11
14-10-2024, 03:20 PM
(Modification du message : 14-10-2024, 05:39 PM par Raphael591.)
Qui peut tester ?
C'est fonctionnel pour le shelly pro 50 EM.
Besoin d'un test avec un pro 3 em en monophasé et un avec un triphasé.
Paramétrage de la voie pour le shelly pro 3 em :
- 3 sur le triphasé.
- 0 ou 1 ou 2 sur le monophasé fonction de la pince à utiliser.
Fichier Bin : https://uploadnow.io/f/gMbYjnw
Source_ShellyEm.ino
Code : //****************************************************************
// Variante Shelly Pro Em proposé par Raphael591 (Juillet 2024)
// + Correction Octobre 2024
// ****************************************************
// * Client d'un Shelly Em sur voie 0 ou 1 ou triphasé*
// ****************************************************
void LectureShellyProEm()
{
String S = "";
String Shelly_Data = "";
String Shelly_Name = "";
float Pw = 0;
float voltage = 0;
float pf = 0;
// ADD PERSO : AJOUT VARIABLE JSON pour facilité la lecture des infos EM PRO
String tmp; // ADD PERSO
// Use WiFiClient class to create TCP connections
WiFiClient clientESP_RMS;
byte arr[4];
arr[0] = RMSextIP & 0xFF; // 0x78
arr[1] = (RMSextIP >> 8) & 0xFF; // 0x56
arr[2] = (RMSextIP >> 16) & 0xFF; // 0x34
arr[3] = (RMSextIP >> 24) & 0xFF; // 0x12
String host = String(arr[3]) + "." + String(arr[2]) + "." + String(arr[1]) + "." + String(arr[0]);
if (!clientESP_RMS.connect(host.c_str(), 80))
{
StockMessage("connection to Shelly Em failed : " + host);
delay(200);
return;
}
int voie = EnphaseSerial.toInt();
int Voie = voie % 2;
if (ShEm_comptage_appels == 1)
{
Voie = (Voie + 1) % 2;
}
// Connaître modèle du shelly *******************************************
String url = "/rpc/Shelly.GetDeviceInfo";
//ShEm_comptage_appels = (ShEm_comptage_appels + 1) % 5; // 1 appel sur 6 vers la deuxième voie qui ne sert pas au routeur
clientESP_RMS.print(String("GET ") + url + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n");
unsigned long timeout = millis();
while (clientESP_RMS.available() == 0)
{
if (millis() - timeout > 5000)
{
StockMessage("client Shelly Em Timeout ! : " + host);
clientESP_RMS.stop();
return;
}
}
timeout = millis();
// Lecture des données brutes distantes
while (clientESP_RMS.available() && (millis() - timeout < 5000))
{
Shelly_Data += clientESP_RMS.readStringUntil('\r');
}
Shelly_Name = StringJson("id", Shelly_Data);
int p = Shelly_Name.indexOf("-");
Shelly_Name = Shelly_Name.substring(0,p);
Shelly_Data = "";
// Modèle shelly FIN *****************************************************
if (!clientESP_RMS.connect(host.c_str(), 80))
{
StockMessage("connection to Shelly Em failed : " + host);
delay(200);
return;
}
url = "/rpc/Shelly.GetStatus"; // pour Pro Em
ShEm_comptage_appels = (ShEm_comptage_appels + 1) % 5; // 1 appel sur 6 vers la deuxième voie qui ne sert pas au routeur
clientESP_RMS.print(String("GET ") + url + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n");
timeout = millis();
while (clientESP_RMS.available() == 0)
{
if (millis() - timeout > 5000)
{
StockMessage("client Shelly Em Timeout 2 ! : " + host);
clientESP_RMS.stop();
return;
}
}
timeout = millis();
// Lecture des données brutes distantes
while (clientESP_RMS.available() && (millis() - timeout < 5000))
{
Shelly_Data += clientESP_RMS.readStringUntil('\r');
}
p = Shelly_Data.indexOf("{");
Shelly_Data = Shelly_Data.substring(p);
if (Shelly_Name == "shellypro3em" && voie == 3) {
// 3 em Triphasé
ShEm_dataBrute = "<strong>"+Shelly_Name+"</strong><br>" + Shelly_Data;
float Pw1, Pw2, Pw3;
float pf1, pf2, pf3;
float volt1, volt2, volt3;
tmp = PrefiltreJson("em:0", ":", Shelly_Data);
Pw1 = ValJson("a_act_power", tmp);
volt1 = ValJson("a_voltage", tmp);
pf1 = ValJson("a_pf", tmp);
Pw2 = ValJson("b_act_power", tmp);
volt2 = ValJson("b_voltage", tmp);
pf2 = ValJson("b_pf", tmp);
Pw3 = ValJson("c_act_power", tmp);
volt3 = ValJson("c_voltage", tmp);
pf3 = ValJson("c_pf", tmp);
Pw = (Pw1 + Pw2 + Pw3) / 3;
voltage = (volt1 + volt2 + volt3) / 3;
pf = abs((pf1 + pf2 + pf3) / 3);
if (pf > 1) pf = 1;
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("emdata:0", ":", Shelly_Data); // ADD PERSO
Energie_M_Soutiree = myLongJson("total_act", tmp); // ADD PERSO
Energie_M_Injectee = myLongJson("total_act_ret", tmp); // ADD PERSO
PowerFactor_M = pf;
Tension_M = voltage;
Pva_valide = true;
}
else if (Shelly_Name == "shellypro3em")
{
// 3 em Monophasé : Voie != 3
ShEm_dataBrute = "<strong>"+Shelly_Name+"</strong><br>" + Shelly_Data;
tmp = PrefiltreJson("em1:" + String(Voie), ":", Shelly_Data); // Voie mono
Pw = ValJson("act_power", tmp);
voltage = ValJson("voltage", tmp);
pf = ValJson("pf", tmp);
pf = abs(pf);
if (pf > 1) pf = 1;
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); // ADD PERSO
Energie_M_Soutiree = myLongJson("total_act_energy", tmp); // ADD PERSO
Energie_M_Injectee = myLongJson("total_act_ret_energy", tmp); // ADD PERSO
PowerFactor_M = pf;
Tension_M = voltage;
Pva_valide = true;
}
else if (Shelly_Name == "shellyproem50" )
{ // Monophasé pro EM
ShEm_dataBrute = "<strong>Voie : " + Shelly_Name + "</strong><br>" + Shelly_Data;
Shelly_Data = Shelly_Data + ",";
if (Shelly_Data.indexOf("true") > 0)
{ // Donnée valide
tmp = PrefiltreJson("em1:" + String(Voie), ":", Shelly_Data); // ADD PERSO
Pw = ValJson("act_power", tmp); // ADD PERSO
voltage = ValJson("voltage", tmp); // ADD PERSO
pf = ValJson("pf", tmp); // ADD PERSO
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); // ADD PERSO
Energie_M_Soutiree = myLongJson("total_act_energy", tmp); // ADD PERSO
Energie_M_Injectee = myLongJson("total_act_ret_energy", tmp); // ADD PERSO
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); // ADD PERSO
Energie_T_Soutiree = myLongJson("total_act_energy", tmp); // ADD PERSO
Energie_T_Injectee = myLongJson("total_act_ret_energy", tmp); // ADD PERSO
PowerFactor_T = pf;
Tension_T = voltage;
}
}
}
filtre_puissance();
PuissanceRecue = true; // Reset du Watchdog à chaque trame du Shelly reçue
if (ShEm_comptage_appels > 1)
EnergieActiveValide = true;
if (cptLEDyellow > 30)
{
cptLEDyellow = 4;
}
}
Routeur avec Triac, CE 2500w. Shelly pro em50 pour les mesures. Kit PV pnp 2 kW. Home assistant
Messages : 74
Sujets : 2
Inscription : Jun 2024
Réputation :
11
17-10-2024, 04:23 PM
(Modification du message : 17-10-2024, 04:31 PM par Raphael591.)
(17-10-2024, 06:12 AM)cetin.s a écrit : Bonjour,
Mon installation dispose d'un compteur Shelly pro 3 EM.
j'ai installé la version 12 . on a bien une lecture des donnée brut de Shelly mais les valeur ne sont pas lu et visible sur l'écran accueille ni sur les graphique.
Après l'installation de votre modification , on a une lecture mais malheureusement celle-ci n'est pas correct pour moi.
Shelly fait déjà la moyenne de la puissance, donc pas de division des puissances cumulé cela fausse le fonctionnement.
Je pense que la lecture de la ligne surligné serait plus approprié.
total_act_power:469.889 Puissance active
total_aprt_power:652.952 puissance Reactive
Merci pour votre travail.
Merci pour le test.
Correction lecture de puissance en triphasé. Si vous pouviez valider.
Le pro 3 em en monophasé ne devrait pas poser problème (même format que le pro EM 50 qui fonctionne).
Je pense qu'on est bon André !
Code : //****************************************************************
// Variante Shelly Pro Em proposé par Raphael591 (Juillet 2024)
// + Correction Octobre 2024
// ****************************************************
// * Client d'un Shelly Em sur voie 0 ou 1 ou triphasé*
// ****************************************************
void LectureShellyProEm()
{
String S = "";
String Shelly_Data = "";
String Shelly_Name = "";
float Pw = 0;
float voltage = 0;
float pf = 0;
// ADD PERSO : AJOUT VARIABLE JSON pour facilité la lecture des infos EM PRO
String tmp; // ADD PERSO
// Use WiFiClient class to create TCP connections
WiFiClient clientESP_RMS;
byte arr[4];
arr[0] = RMSextIP & 0xFF; // 0x78
arr[1] = (RMSextIP >> 8) & 0xFF; // 0x56
arr[2] = (RMSextIP >> 16) & 0xFF; // 0x34
arr[3] = (RMSextIP >> 24) & 0xFF; // 0x12
String host = String(arr[3]) + "." + String(arr[2]) + "." + String(arr[1]) + "." + String(arr[0]);
if (!clientESP_RMS.connect(host.c_str(), 80))
{
StockMessage("connection to Shelly Em failed : " + host);
delay(200);
return;
}
int voie = EnphaseSerial.toInt();
int Voie = voie % 2;
if (ShEm_comptage_appels == 1)
{
Voie = (Voie + 1) % 2;
}
// Connaître modèle du shelly *******************************************
String url = "/rpc/Shelly.GetDeviceInfo";
clientESP_RMS.print(String("GET ") + url + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n");
unsigned long timeout = millis();
while (clientESP_RMS.available() == 0)
{
if (millis() - timeout > 5000)
{
StockMessage("client Shelly Em Timeout ! : " + host);
clientESP_RMS.stop();
return;
}
}
timeout = millis();
// Lecture des données brutes distantes
while (clientESP_RMS.available() && (millis() - timeout < 5000))
{
Shelly_Data += clientESP_RMS.readStringUntil('\r');
}
Shelly_Name = StringJson("id", Shelly_Data);
int p = Shelly_Name.indexOf("-");
Shelly_Name = Shelly_Name.substring(0,p);
Shelly_Data = "";
// Modèle shelly FIN *****************************************************
if (!clientESP_RMS.connect(host.c_str(), 80))
{
StockMessage("connection to Shelly Em failed : " + host);
delay(200);
return;
}
url = "/rpc/Shelly.GetStatus"; // pour Pro Em
ShEm_comptage_appels = (ShEm_comptage_appels + 1) % 5; // 1 appel sur 6 vers la deuxième voie qui ne sert pas au routeur
clientESP_RMS.print(String("GET ") + url + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n");
timeout = millis();
while (clientESP_RMS.available() == 0)
{
if (millis() - timeout > 5000)
{
StockMessage("client Shelly Em Timeout 2 ! : " + host);
clientESP_RMS.stop();
return;
}
}
timeout = millis();
// Lecture des données brutes distantes
while (clientESP_RMS.available() && (millis() - timeout < 5000))
{
Shelly_Data += clientESP_RMS.readStringUntil('\r');
}
p = Shelly_Data.indexOf("{");
Shelly_Data = Shelly_Data.substring(p);
if (Shelly_Name == "shellypro3em" && voie == 3) {
// 3 em Triphasé
ShEm_dataBrute = "<strong>"+Shelly_Name+"</strong><br>" + Shelly_Data;
float Pw1, Pw2, Pw3;
float pf1, pf2, pf3;
float volt1, volt2, volt3;
tmp = PrefiltreJson("em:0", ":", Shelly_Data);
Pw = ValJson("total_act_power", tmp);
volt1 = ValJson("a_voltage", tmp);
pf1 = ValJson("a_pf", tmp);
volt2 = ValJson("b_voltage", tmp);
pf2 = ValJson("b_pf", tmp);
volt3 = ValJson("c_voltage", tmp);
pf3 = ValJson("c_pf", tmp);
voltage = (volt1 + volt2 + volt3) / 3;
pf = abs((pf1 + pf2 + pf3) / 3);
if (pf > 1) pf = 1;
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("emdata:0", ":", Shelly_Data); // ADD PERSO
Energie_M_Soutiree = myLongJson("total_act", tmp); // ADD PERSO
Energie_M_Injectee = myLongJson("total_act_ret", tmp); // ADD PERSO
PowerFactor_M = pf;
Tension_M = voltage;
Pva_valide = true;
}
else if (Shelly_Name == "shellypro3em")
{
// 3 em Monophasé : Voie != 3
ShEm_dataBrute = "<strong>"+Shelly_Name+"</strong><br>" + Shelly_Data;
tmp = PrefiltreJson("em1:" + String(Voie), ":", Shelly_Data); // Voie mono
Pw = ValJson("act_power", tmp);
voltage = ValJson("voltage", tmp);
pf = ValJson("pf", tmp);
pf = abs(pf);
if (pf > 1) pf = 1;
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); // ADD PERSO
Energie_M_Soutiree = myLongJson("total_act_energy", tmp); // ADD PERSO
Energie_M_Injectee = myLongJson("total_act_ret_energy", tmp); // ADD PERSO
PowerFactor_M = pf;
Tension_M = voltage;
Pva_valide = true;
}
else if (Shelly_Name == "shellyproem50" )
{ // Monophasé pro EM
ShEm_dataBrute = "<strong>" + Shelly_Name + "</strong><br>" + Shelly_Data;
Shelly_Data = Shelly_Data + ",";
if (Shelly_Data.indexOf("true") > 0)
{ // Donnée valide
tmp = PrefiltreJson("em1:" + String(Voie), ":", Shelly_Data); // ADD PERSO
Pw = ValJson("act_power", tmp); // ADD PERSO
voltage = ValJson("voltage", tmp); // ADD PERSO
pf = ValJson("pf", tmp); // ADD PERSO
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); // ADD PERSO
Energie_M_Soutiree = myLongJson("total_act_energy", tmp); // ADD PERSO
Energie_M_Injectee = myLongJson("total_act_ret_energy", tmp); // ADD PERSO
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); // ADD PERSO
Energie_T_Soutiree = myLongJson("total_act_energy", tmp); // ADD PERSO
Energie_T_Injectee = myLongJson("total_act_ret_energy", tmp); // ADD PERSO
PowerFactor_T = pf;
Tension_T = voltage;
}
}
}
filtre_puissance();
PuissanceRecue = true; // Reset du Watchdog à chaque trame du Shelly reçue
if (ShEm_comptage_appels > 1)
EnergieActiveValide = true;
if (cptLEDyellow > 30)
{
cptLEDyellow = 4;
}
}
Routeur avec Triac, CE 2500w. Shelly pro em50 pour les mesures. Kit PV pnp 2 kW. Home assistant
Messages : 1,185
Sujets : 40
Inscription : May 2024
Réputation :
135
J'attends un peu, si c'est validé, on publie cette nouvelle version.
Cdlt
André
Messages : 74
Sujets : 2
Inscription : Jun 2024
Réputation :
11
(17-10-2024, 07:32 PM)cetin.s a écrit : Bonjour,
je désolé comprend rien en la programmation.
Pourriez vous générer un nouveau fichier bin pour mettre a jour le programme afin que je puisse tester.
merci
Super merci
bonne soirée
Le fichier : https://uploadnow.io/f/CcLCpW3
Routeur avec Triac, CE 2500w. Shelly pro em50 pour les mesures. Kit PV pnp 2 kW. Home assistant
Messages : 2
Sujets : 0
Inscription : Oct 2024
Réputation :
0
18-10-2024, 09:04 PM
(Modification du message : 18-10-2024, 09:32 PM par Robi60.)
(14-10-2024, 03:20 PM)Raphael591 a écrit : Qui peut tester ?
C'est fonctionnel pour le shelly pro 50 EM.
Besoin d'un test avec un pro 3 em en monophasé et un avec un triphasé.
Paramétrage de la voie pour le shelly pro 3 em :
- 3 sur le triphasé.
- 0 ou 1 ou 2 sur le monophasé fonction de la pince à utiliser.
Fichier Bin : https://uploadnow.io/f/gMbYjnw
Source_ShellyEm.ino
Code : //****************************************************************
// Variante Shelly Pro Em proposé par Raphael591 (Juillet 2024)
// + Correction Octobre 2024
// ****************************************************
// * Client d'un Shelly Em sur voie 0 ou 1 ou triphasé*
// ****************************************************
void LectureShellyProEm()
{
String S = "";
String Shelly_Data = "";
String Shelly_Name = "";
float Pw = 0;
float voltage = 0;
float pf = 0;
// ADD PERSO : AJOUT VARIABLE JSON pour facilité la lecture des infos EM PRO
String tmp; // ADD PERSO
// Use WiFiClient class to create TCP connections
WiFiClient clientESP_RMS;
byte arr[4];
arr[0] = RMSextIP & 0xFF; // 0x78
arr[1] = (RMSextIP >> 8) & 0xFF; // 0x56
arr[2] = (RMSextIP >> 16) & 0xFF; // 0x34
arr[3] = (RMSextIP >> 24) & 0xFF; // 0x12
String host = String(arr[3]) + "." + String(arr[2]) + "." + String(arr[1]) + "." + String(arr[0]);
if (!clientESP_RMS.connect(host.c_str(), 80))
{
StockMessage("connection to Shelly Em failed : " + host);
delay(200);
return;
}
int voie = EnphaseSerial.toInt();
int Voie = voie % 2;
if (ShEm_comptage_appels == 1)
{
Voie = (Voie + 1) % 2;
}
// Connaître modèle du shelly *******************************************
String url = "/rpc/Shelly.GetDeviceInfo";
//ShEm_comptage_appels = (ShEm_comptage_appels + 1) % 5; // 1 appel sur 6 vers la deuxième voie qui ne sert pas au routeur
clientESP_RMS.print(String("GET ") + url + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n");
unsigned long timeout = millis();
while (clientESP_RMS.available() == 0)
{
if (millis() - timeout > 5000)
{
StockMessage("client Shelly Em Timeout ! : " + host);
clientESP_RMS.stop();
return;
}
}
timeout = millis();
// Lecture des données brutes distantes
while (clientESP_RMS.available() && (millis() - timeout < 5000))
{
Shelly_Data += clientESP_RMS.readStringUntil('\r');
}
Shelly_Name = StringJson("id", Shelly_Data);
int p = Shelly_Name.indexOf("-");
Shelly_Name = Shelly_Name.substring(0,p);
Shelly_Data = "";
// Modèle shelly FIN *****************************************************
if (!clientESP_RMS.connect(host.c_str(), 80))
{
StockMessage("connection to Shelly Em failed : " + host);
delay(200);
return;
}
url = "/rpc/Shelly.GetStatus"; // pour Pro Em
ShEm_comptage_appels = (ShEm_comptage_appels + 1) % 5; // 1 appel sur 6 vers la deuxième voie qui ne sert pas au routeur
clientESP_RMS.print(String("GET ") + url + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n");
timeout = millis();
while (clientESP_RMS.available() == 0)
{
if (millis() - timeout > 5000)
{
StockMessage("client Shelly Em Timeout 2 ! : " + host);
clientESP_RMS.stop();
return;
}
}
timeout = millis();
// Lecture des données brutes distantes
while (clientESP_RMS.available() && (millis() - timeout < 5000))
{
Shelly_Data += clientESP_RMS.readStringUntil('\r');
}
p = Shelly_Data.indexOf("{");
Shelly_Data = Shelly_Data.substring(p);
if (Shelly_Name == "shellypro3em" && voie == 3) {
// 3 em Triphasé
ShEm_dataBrute = "<strong>"+Shelly_Name+"</strong><br>" + Shelly_Data;
float Pw1, Pw2, Pw3;
float pf1, pf2, pf3;
float volt1, volt2, volt3;
tmp = PrefiltreJson("em:0", ":", Shelly_Data);
Pw1 = ValJson("a_act_power", tmp);
volt1 = ValJson("a_voltage", tmp);
pf1 = ValJson("a_pf", tmp);
Pw2 = ValJson("b_act_power", tmp);
volt2 = ValJson("b_voltage", tmp);
pf2 = ValJson("b_pf", tmp);
Pw3 = ValJson("c_act_power", tmp);
volt3 = ValJson("c_voltage", tmp);
pf3 = ValJson("c_pf", tmp);
Pw = (Pw1 + Pw2 + Pw3) / 3;
voltage = (volt1 + volt2 + volt3) / 3;
pf = abs((pf1 + pf2 + pf3) / 3);
if (pf > 1) pf = 1;
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("emdata:0", ":", Shelly_Data); // ADD PERSO
Energie_M_Soutiree = myLongJson("total_act", tmp); // ADD PERSO
Energie_M_Injectee = myLongJson("total_act_ret", tmp); // ADD PERSO
PowerFactor_M = pf;
Tension_M = voltage;
Pva_valide = true;
}
else if (Shelly_Name == "shellypro3em")
{
// 3 em Monophasé : Voie != 3
ShEm_dataBrute = "<strong>"+Shelly_Name+"</strong><br>" + Shelly_Data;
tmp = PrefiltreJson("em1:" + String(Voie), ":", Shelly_Data); // Voie mono
Pw = ValJson("act_power", tmp);
voltage = ValJson("voltage", tmp);
pf = ValJson("pf", tmp);
pf = abs(pf);
if (pf > 1) pf = 1;
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); // ADD PERSO
Energie_M_Soutiree = myLongJson("total_act_energy", tmp); // ADD PERSO
Energie_M_Injectee = myLongJson("total_act_ret_energy", tmp); // ADD PERSO
PowerFactor_M = pf;
Tension_M = voltage;
Pva_valide = true;
}
else if (Shelly_Name == "shellyproem50" )
{ // Monophasé pro EM
ShEm_dataBrute = "<strong>Voie : " + Shelly_Name + "</strong><br>" + Shelly_Data;
Shelly_Data = Shelly_Data + ",";
if (Shelly_Data.indexOf("true") > 0)
{ // Donnée valide
tmp = PrefiltreJson("em1:" + String(Voie), ":", Shelly_Data); // ADD PERSO
Pw = ValJson("act_power", tmp); // ADD PERSO
voltage = ValJson("voltage", tmp); // ADD PERSO
pf = ValJson("pf", tmp); // ADD PERSO
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); // ADD PERSO
Energie_M_Soutiree = myLongJson("total_act_energy", tmp); // ADD PERSO
Energie_M_Injectee = myLongJson("total_act_ret_energy", tmp); // ADD PERSO
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); // ADD PERSO
Energie_T_Soutiree = myLongJson("total_act_energy", tmp); // ADD PERSO
Energie_T_Injectee = myLongJson("total_act_ret_energy", tmp); // ADD PERSO
PowerFactor_T = pf;
Tension_T = voltage;
}
}
}
filtre_puissance();
PuissanceRecue = true; // Reset du Watchdog à chaque trame du Shelly reçue
if (ShEm_comptage_appels > 1)
EnergieActiveValide = true;
if (cptLEDyellow > 30)
{
cptLEDyellow = 4;
}
}
Hello,
je m'insère dans la conversation ;-)
Je suis en triphasé,
J'ai acheté un Pro3EM il y a 4 mois dans le but de faire le routeur
Et vu après l'avoir installé que le routeur était indiqué comme "pas fonctionnel" en tri avec le PRO3EM. Je m'étais dit que je regarderai comment c'est fait le jour où je démarrerai le routeur.
J'ai commencé mercredi, v12.01 etc, J'ai également un Shelly 3EM donc je peux switcher de l'un à l'autre : 3EM OK, Pro3EM marche pas mais effectivement on voyait les valeurs passer dans les données brutes.
Je regarde sur le forum, et, oh bonheur cette mise à jour de code de Raphael591!
Copier coller, injecté et hop ça fonctionne sous la 12.0.1 donc avec un PRO3EM et triphasé, voir captures
bien joué et un gros merci.
Veux-tu vérifier d'autres choses afin de valider la modif et passer le code en standard?
|