SF 800 (Plus / Pro) - Why HTTP instead of MQTT for local only communication in ZenSDK?
Hi everyone,
I want to use my Zendure SolarFlow 800 Pro completely local and even block any internet access. For that I can switch to ZenSDK.
However, it seems ZenSDK is using HTTP instead of MQTT in local network mode although the SF 800 supports local MQTT.
So why not using MQTT only since it has less overhead and is faster?
Thanks!
If you wand to control the SF800 Pro completely local you have to think about the implementation of your control loop. Which device will be used as powersensor, a Shelly, or IR Reader on the smartmeter? I use an ESP32 with Tasmota. The SF800Pro has a settling time of approx 2s from receiving the API command until the targeted output (or input) power is achieved. This is already quite slow. MQTT usually is not faster than 10sec. Probably slower, depending on your MQTT server and control loop implementation.
The control loop is one of the most important things. If not well done, you will see a huge drop in efficiency of your whole system, especially with loads like cooking stoves or any other heating device without phase angle control. My current system has an overall average efficiency of 65%, including all losses for storing and taking out energy from the battery, self consumption of SF800 & control devices, and control loop efficiency. This drops to 30% with low consumption at night, because my house will ask for 30W only, while the SF800& the Controler takes already 25W. I can live with it, but that´s something to be improved.
For this reason I´m thinking about replacing the SF800Pro with a solution with hardwired servo control loop. This means cycletimes of less than 100msec for an almost realtime power control.
@Spessartwald You can try my implementation for homeassistant which is a simple .yaml. Nothing more needed for installation. I use it with a Shelly 3EM Pro but it works with basically any power meter. MQTT only, 100% local only.
Link: https://github.com/Utini2000/Zendure-Solarflow-Local-HomeAssistant/
At e.g. yesterdays 7,35 kWh solar input I only lost 0,05 kWh to the external power supply. So 7,30 kWh out of 7,35 kWh have been used at my home. 4,53 kWh went into storage during that day and 4,19 kWh went out of the storage.
Seems efficient enough for me :)
@Utini2000: wow, looks like huge professional work. I don´t have a Shelly or Homeassistant running to avoid additional devices and power consumption: tried to implement the minimal solution. My target is to reduce yearly consumption for a 4 person household from 2.000KWh to <700KWh with the SF800 Pro, or in otherwords: don´t pay more than 30€ per month for electric power - just to see if this is possible. ROI: 5 years maximum.
What I´m really interested in is your implementation of the controlloop with MQTT. I assume there was no FW change/disconnection from the cloud as described by R.Brandstätter https://github.com/reinhard-brandstaedter/solarflow-bt-manager.
Testcase: electric blanket (Heizdecke). Powerconsumption 160W AC, on/off switching cycle to keep 40°C : ~10sec. . With my ESP32 controlloop cycle of ~2sec it´s already clear that there are losses, because the blanket will take 160W from the grid for min. 2sec until the battery jumps in, and the battery sends 160W to the grid until the control loop switches off. Worstcase: control loop with 10sec cycle time beeing 180° out of phase (that´s what I had with MQTT initially). This will take 10secs energy from the grid, and the next 10secs drain the battery to the grid. Battery will be just empty over night, you have to pay twice... The SF800 MQTT cycle without FW modification is 10sec - isn´t it ?
Another examle attached - a coffee machine . Chart Resolution is 5sec tics, but you can clearly see the heaters 1.2KW going down to 0,4KW after ~4secs when the SF800 jumps in, and the negative spike for another few secs until beeing back to 0W. If there is a constant load of e.g. 20W my ESP achieves +/-1W 0-feed in.
My script changes adapts to the power consumption changes within 2 seconds. Sometimes there is an overload and it takes a few more seconds but usually it bis very quick.
There is also a fast gate for huge energy changes (e.gm electric oven turning suddenly off) where the output power change is instant (or as instant as possible). I don't see any hard 10sec delay
thanks, good to know. Seems Zendure implemented the same rise/fall times of >2secs for MQTT & API.
See https://github.com/Zendure/zenSDK/issues/49#issuecomment-3913027795
Anyhow, it´s good that the HTTP Api is available. I just don´t want to have any other device like Raspberrys & Homeassistants in my household, and even want to get rid of the android spyphone, which is used for the Zendure App only.
The optimum solution for me would be a cable connection between any smartmeter and the Solarflows, and complete controlinterface just using a webbrowser. No other technical shit to be maintained and vulnerable to cyberattacks. Less is sometimes more during wartimes.
As I´m working in industry, it´s good to see that cloudbased apps and devices will get more and more restrictions from the EU.
It´s foreseable that Photovoltaic devices will be categorized in near future as critical energy infrastructure, and cloudless local control may become mandatory hopefully as fast as possible for such things. From a cybersecurity point of view, I would say Zendures solution is category ´F´ - the worst. Whoever will get the servers under control is able to shutdown the product - or the grid by switching on millions of devices at the same time.
@Zendure Guys: please add those technical specs to this repo, it´s essential !
If you wand to control the SF800 Pro completely local you have to think about the implementation of your control loop. Which device will be used as powersensor, a Shelly, or IR Reader on the smartmeter? I use an ESP32 with Tasmota. The SF800Pro has a settling time of approx 2s from receiving the API command until the targeted output (or input) power is achieved. This is already quite slow. MQTT usually is not faster than 10sec. Probably slower, depending on your MQTT server and control loop implementation.
The control loop is one of the most important things. If not well done, you will see a huge drop in efficiency of your whole system, especially with loads like cooking stoves or any other heating device without phase angle control. My current system has an overall average efficiency of 65%, including all losses for storing and taking out energy from the battery, self consumption of SF800 & control devices, and control loop efficiency. This drops to 30% with low consumption at night, because my house will ask for 30W only, while the SF800& the Controler takes already 25W. I can live with it, but that´s something to be improved.
For this reason I´m thinking about replacing the SF800Pro with a solution with hardwired servo control loop. This means cycletimes of less than 100msec for an almost realtime power control.
do you have viable input data of the 25w? When running at 30w out?
I have a good feedback control that has an overall efficiency of nearly 99%. As soon as I finish the Alpha Phase i will publish it in GitHub, but still want to make the last Tweeks. This is only the feedback control. Of course, the while efficiency of the system is lower (I estimate it at 70-75%)
Ich schreib jetzt auf die schnelle mal auf Deutsch. Ich habe den SF800Pro im November angeschafft und mit 2 Paneln ohne Regelkreis nur als Notstromspeicher in Betrieb genommen. Mein Tagesverbrauch ist bezogen auf verbleichbare Tage aus dem Vorjahreszeitraum und den Tagen direkt davor (Wochentag, keinerlei Großverbraucher genutzt) an bewölkten Wintertagen um ca 0,5KWh gestiegen.
Ich habe keine Einzelmessungen. Das Gerät versorgt sich bei vermutlich bei ausreichend Licht selbst, sonst aus dem aus dem Akku bis zur Entladegrenze, danach aus dem Netz. Regelmässig gönnt sich das Gerät einen vollen Schluck aus der Pulle und zieht auch nachts bis zu 1kW über mehrere min aus dem Netz. Vermutlich ein Entladeschutz und für die Batterieheizung. Über den Tag gemittelt ergeben sich ca 20..23W Eigenverbrauch. Dazu kommen noch die beiden ESPs mit ca 1,5W.
Auszug aus meinem Tasmota Script für die Regelparameter zur Info. Das skript läuft jede Sekunde durch:
intsum=intsum+(power*0.05) // Integralanteil Ki 0,05. Power ist die vom Smartmeter sekündlich übertragene Leistung.
intsum=mp(intsum <-40 -40 >40 40) // Ki Begrenzt auf +/- 40 Watt. In dem Bereich wird langsamer, dafür sehr fein geregelt
newLimit=((oldLimit+power)*0.75)+intsum-5 // Stellwert mit Proportionalanteil Kp 0,75, und Ki 0,05. Mit einem Offset von 5 Watt, damit wir im Mittel leicht auf der Einspeiseseite liegen.
newLimit=mp(newLimit <-1300 -1300 >800 800) // das ist eine spezielle Varialble die über 2 Werte mittelt und den Stellwert für die ie Eingangsleistung des SF auf 1300W sowie die Ausgangsleistung auf 800 begrenzt.
deltaPower=abs(abs(newLimit)-abs(oldLimit)) // Unterschied zwischen aktuellem und letztem Stellwert.
Der Stellwert wird über einen webrequest gesendet,
- alle 2s, sofern deltaPower >10
- sonst nach 6s. Reduziert die WLAN Last.
ok, ist also ein Mittelwert und kann auch unter Umständen etwas höher als tatsächlich sein, wenn ab und an die Heizung mit dabei war.
Ich habe es auch noch nicht vollkommen analysiert, aber meine erste Abschätzung kommt auf etwas zwischen 15-25. Aber danke für die info.
@Spessartwald @cnadler86 Mit passenden Algorithmen und Optimierungen im script geht es noch schneller.
Lieber Even basiert anstatt strikt alle 2 sekunden. Die MQTT read/write Last so weit es geht reduzieren, dann geht die kommunikation auch schneller als 2s. Generell ist das reduzieren der last schneller als das erhöhen, daher kann man auch hier optimieren. Mit stdev arbeiten um weiter last und geschwindigkeit und genaunigkeit zu verbessern. Mit fast gates arbeiten für spezielle fälle.
Siehe: https://github.com/Utini2000/Zendure-Solarflow-Local-HomeAssistant
Inzwischen bin ich bei fast 6.000 Zeilen code obwohl ich es versuche so schlank und effizient wie möglich zu halten. Die Regelung funktioniert meiner meinung nach inzwischen sehr sehr gut. Ich sehe kein Verbesserungspotenzial mehr. Wichtig ist auch eine stabile und gute WLAN verbindung.
In dem Thread gings ja darum, welche Zykluszeit mit einem API oder MQTT basierten Regelkreis für eine Nulleinspeisung erreichet werden kann, und das die Anstiegs-/Abfallzeiten bis zum Erreichen des Sollwertes in die technische Doku des jeweiligen Gerätes gehören. Ohne die dynamischen Parameter des Stellglieds lässt sich eine vernünftige Regelung nicht realisieren. Entweder wird der Sollwert nicht oder zu langsam erreicht, oder der Regelkreis wird instabil und schwingt. Für den SF800Pro hat Zendure die Werte von 2s hier angegeben, was bei mir zu den oben angegebenen Werten für Kd und Ki geführt hat. Der Regelkreis schwingt nach hohen Lastsprüngen aus und erreicht den Sollwert innerhalb von ca 15sec. Für andere Geräte kann das durchaus anders aussehen.
Mein Skript is mehr oder weniger ´dynamisch´. Senden innerhalb von 2s nur, wenn sich die Leistung am Zähler um mehr als 10Watt geändert hat. Sonst alle 6s. Mit diesen Werten ergibt sich nachts bei nur langsam schwankender Last, z.B. wenn die Heizungspumpe regelt, eine echte ´0´ am Zähler. Ich bin kein Programmierer, aber mein Script läuft soweit zufriedenstellend. Der Aufwand um noch einige Euros im Jahr rauszuholen steht ja in keinem Verhältnis mehr.
Tatsächlich habe ich ja mit dem ESP32 mit Tasmota eine nicht ganz standardmässige Lösung realisiert, die den Überschuss aus einem anderen Balkonkraftwerk zum Aufladen verwendet. Dann gehen 1,3KW in den 3,8KWh Akku rein, wenn die Sonne scheint, und es stehen bis zu 1,6 KW an Leistung zur Verfügung, wenns die Kochplatte braucht. Zu keiner Zeit gehen mehr als 800 Watt ins Netz. Sobald der Akku voll ist, wird der Überschuss in einen Heizstab im Warmwasserboiler gegeben - ebenfalls durch den ESP geregelt. Im April hatte ich einen Gesamtverbrauch von 23KWh respektive 7 Euro Kosten, und durchgängig heisses Badewasser wie noch nie zuvor mit der Gasheizung. Der SF800 Pro tut das was er soll.
Dynamisch (verwendung einer hysterese) ist gut. Verwende ich ebenso im script. Ist aber wie oben erwähnt nur ein baustein zur schnellstmöglichen nulleinspeisung.
Deshalb habe ich oben ja ein paar weitere optimierungen aufgelistet die deinem script helfen würden.
Ich habe vor einigen Wochen schonmal da reingeschaut, das ist eine absolut professionelle und gut dokumentierte Lösung, was mit dem SF800 Pro machbar ist. Da das HomeAssistant und einen MQTT Broker und damit weitere HW und Software benötigt, kommt das für mich erstmal nicht in Betracht. Ich gehe die Dinge von unten an - mit minimalem Budget und Aufwand den maximalen Ertrag rausholen, was halt oftmals nur 90% des technisch Machbaren ergibt. Bedeutet in meinem Fall: Return of Invest sollte kleiner 4 Jahre sein, unter Einbeziehung der im Sommer nicht benötigten Gasheizung fürs Warmwasser. Bei 1.8k€ Gesamtinvest reduzieren sich meine Energiekosten um 0,5k€ p.a. -> Ziel erreicht. Wenn die Anlage ohne weitere Wartungskosten 10 Jahre läuft, ist eine Gesamtersparnis von bis zu 3k€ drin.
Interessehalber: Deine dynamische Regelung ist in der zendure_v104_dynamic_local.yaml ? Welcher Reglertyp verbirgt sich dahinter ? Ein adaptiver Regler, der seine Zykluszeit und Stellgröße automatisch an das Lastverhalten anpasst, also lernt bzw. Vorhersagen aus Wahrscheinlichkeiten ableitet ? Mit dem ESP32 und Tasmota Script Interpreter wäre das aktuell nicht machbar. Allerdings gibt es neuerdings für Tasmota einen integrierten tiny C Kompiler, der die Rechenleistung zur Laufzeit wohl um das 10 fache erhöht. Da sind dann ganz andere Dinge machbar.
Die aktuelle version ist immer zendure_control.yaml Link: https://github.com/Utini2000/Zendure-Solarflow-Local-HomeAssistant/blob/main/zendure_control.yaml
Im prinzip ja wobei es verschiedene regeltypen für ausnahmefälle gibt. Eine Hysterese wird aber genauso grundsätzlich verwendet wie z.b. auch fast gates.
Der Regler ist also im Homeassistant, vermutlich auf einem RaspPi. Wie sieht denn der Leistungsverlauf am Zähler aus, wenn eine Herdplatte mit 2kW Leistung mit 40sec Periodendauer und 50% Einschaltzeit taktet, wenn nur ein SF800Pro angeschlossen ist? Das ist bei mir der Worst Case für die Effizienz.
Läuft auf einem.homeassistant green.
E-Herd geht ganz gut dank fast gate: Ist die Einspeisung plötzlich drastisch hoch, dann überschreibe alle Regeln und aktuelle Mechanismen und minimieren sofort die Leistung.
und umgekehrt vermutlich auch. Das ist genau der Punkt um den es in einem diskreten Regelkreis mit Totzeiten geht. Die liegt bei SF800 Pro und MQTT/API Request bei mindestens 2s. Eine Last, die mit der Periodendauer der Totzeit schaltet, schwingt. Das ist bei einer Heizdecke hier im Haushalt der Fall, die zum Glück nur 120W aufnimmt, aber nach einer Nacht 0,5KW aus dem Netz gezogen hat, und 0,3KW eingespeist wurden. Einzige Lösung: entsorgen.
Nein umgekehrt nicht. Und nein es sind daher keine fixen 2 Sekunden. Es kann durchaus auch schneller gehen.
Mein Ansatz beim E-Herd ist auch: lieber etwas mehr Netzbezug dafür robuster verhindern dass nichts eingespeist wird.
Gibt es einen Grund dafür ? Bezug ist ca 4x teurer als das kurzzeitige regelkreisbedingte Einspeisen von Überschuss, für den nur die Kosten der Akkuabnutzung anfallen. Im April habe ich 22KWh bezogen und 25KWh eingespeist. Allerdings nicht nur regelkreisbedingt, sondern weil der Warmwasserboiler über 70°C abschaltet und die Energie dann ins Netz geht.
Aber gut, was ist den jetzt die konkrete Hilfe für alle anderen Leser, die diesen Thread irgendwann öffnen, bzw. wann kann der mit welchem Ergebnis geschlossen werden ?
Für mich schaut es so aus, daß eine Regelung des SF800 Pro gleichwertig mit MQTT oder JSON Webreqeuest erfolgen kann.
Die Stellzeit vom Empfang eines Befehls bis zum Erreichen des Stellwerts scheint innerhalb eines Modus <2sec.
Details dazu seitens Zendure wären hilfreich, z.B. wie die Stellzeit von der Höhe des Lastsprungs und von Änderungen des Betriebsmodus abhängt, also beim Umschalten Einspeisen aus Akku, Bypass (outputlimit) /Aufladen aus dem Netz (inputlimit). Ausserdem gfls. eine Temperaturabhängigkeit, wenn das Gerät so wie bei mir aussen betrieben wird.
Weil ich lieber meinen kostenlos gelieferten Speicher sinnvoll in der Nacht entleeren möchte als einzuspeisen.
Ob ich jetzt beziehe oder später ist egal. Aber weggeworfener Strom ist in jedem Fall verloren. Da nutze ich den lieber bedacht, leer wird er sowieso, anstelle davon was zu verschenken.
Und nein, MQTT und http Rest sind nicht gleichwertig. Http Rest hat den höheren Overhead und damit mehr workload bei read/write.