Seit einiger Zeit befindet sich in meinem Netzwerk (neben einer SMA EV Charger 22 Wallbox) auch ein SMA Wechselrichter für eine Photovoltaikanlage und ein dazugehöriger SMA Sunny Home Manager. Letzterer ist so verbaut, dass er nicht nur die ins Netz eingespeiste Energie messen kann. Zusätzlich misst er auch die Verbräuche. Damit kann man sich also jederzeit den aktuellen Bezug elektrischer Energie angucken. Dies ermöglicht es jederzeit einen guten Überblick darüber zu haben wieviel Energie erzeugt bzw. verbraucht wird.
So kann man durch einen hohen Eigenverbrauch der erzeugten Energie möglichst viel Energie selbst nutzen (anstatt sie ins Netz einzuspeisen).
Dies ist bei SMA bereits über eine spezielle App möglich. Allerdings lassen sich damit nur bedingt Vorgänge automatisieren. Letztendlich möchte ich diese Daten auch für mein eigenes SmartHome System auslesen und nutzen können.
Der im folgenden vorgestellte Node Red Code ist ein erster Anfang. Damit lassen sich bereits die gängigsten Verbrauchs- bzw. auch Erzeugerdaten auslesen. Ich muss auch dazu sagen, dass der Code nicht alleine von mir erstellt wurde. Ich habe mich an verschiedenen (leider nicht mehr bekannten) Quellen inspirieren lassen. (Wer seinen Code hier wiederfindet soll mir bitte bescheid geben. Dann füge ich die Info hier hinzu. :))
Aber nun erstmal zu meinem aktuellen Node Red code um die Daten eines SMA Sunny Home Manager auslesen zu können.
Safety instructions
I know the following notes are always kind of annoying and seem unnecessary. Unfortunately, many people who knew "better" have lost eyes, fingers or other things due to carelessness or injured themselves. Data loss is almost negligible in comparison, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Because even the coolest project is not worth injury or other trouble.
https://www.nerdiy.de/sicherheitshinweise/
Affiliate links/advertising links
The links to online shops listed here are so-called affiliate links. If you click on such an affiliate link and make a purchase via this link, Nerdiy.de will receive a commission from the relevant online shop or provider. The price does not change for you. If you make your purchases via these links, you support Nerdiy.de in being able to offer other useful projects in the future. 🙂
Requirements
Helpful articles:
So that you can use NodeRed, NodeRed should of course already be installed on your Raspberry Pi.
How to prepare a Raspberry Pi for this and then install NodeRed on it is described in the following articles.
- RaspberryPi – setup for nerdiys!
- RaspberryPi – Tuee First configuration!
- RaspberryPi – Control the RaspberryPi via SSH
- NodeRed – Installing NodeRed on the RaspberryPi
- NodeRed – Install new nodes
- NodeRed - import and export node code
In the following lists you will find all the parts you need to implement this article.
Required tool:
Number | Link |
---|---|
1x | Screwdriver set Buy at Amazon |
1x | SD card reader Buy at Amazon |
Required material:
Number | Link |
---|---|
1x | Raspberry Pi Buy at Amazon |
1x | Raspberry Pi power supply Buy at Amazon |
1x | Raspberry Pi case Buy at Amazon |
1x | Micro SD card 64GB Buy at Amazon |
1x | SMA Sunny Home Manager 2.0 |
SMA Sunny Home Manager Voraussetzungen
Damit die Daten Eures SMA Sunny Home Manager ausgelesen werden können sollte dieser bereits in Betrieb und mit Eurem Netzwerk verbunden sein. Wenn Ihr die Daten Eures Wechselrichters bereits mit der App von SMA auslesen könnt sollte alles korrekt eingerichtet sein.
Import Node Red code
In this section you will find the Node Red code you need. How you can import this into your NodeRed environment is in the article NodeRed - import and export node code described.
Um den unten verlinkten Node Code nutzen zu können, müsst ihr keine Änderungen vornehmen. Die Daten werden aus den Multicast Nachrichten des Home Managers ausgelesen und sollten demzufolge direkt verfügbar sein.
You can find the Node Red code in the Nerdiy Git repository at the following link:


Die ausgelesenen Daten werden gruppiert ausgegeben. Aktuell werden sie “nur” auf dem Dashboard angezeigt. Ihr könnt Sie aber natürlich auch anderweitig weiterverarbeiten und so zum Beispiel den passenden Zeitpunkt herausfinden um Eure Waschmaschine einzuschalten. 🙂
More articles about Node Red
In den folgenden Kategorien findet Ihr weitere Links zum Thema Node Red.
Have fun with the project
I hope everything worked as described for you. If not or you have questions or suggestions please let me know in the comments. I will then add this to the article if necessary.
Ideas for new projects are always welcome. 🙂
PS Many of these projects - especially the hardware projects - cost a lot of time and money. Of course I do this because I enjoy it, but if you think it's cool that I share the information with you, I would be happy about a small donation to the coffee fund. 🙂
Thank you for the great work. I imported the code into my Node-Red of my Home Assistant system. Unfortunately I get an error with the buffer-parser. This would be unknown.
Unfortunately, I am a complete beginner in Node-Red.
Do you have any tip what I could check?
Oh sorry, found out. I only had to install the buffer parser 🙂
Hey Toby,
just simply install the appropriate node over the palette. 🙂
Good luck with it and best regards
Fabian
Hello Fabian,
me again. I noticed that the firmware version unfortunately does not fit exactly. For me this is 2.12.3.R (is a new beta version). Unfortunately, 2.0c.3.R is displayed.
0C should actually be a 12.
If I change the type in the buffer-parser Measurements from hex to byte, it is displayed correctly for me.
You can check it and update the template if necessary.
Hey Toby,
thanks for the hint. Corrected the template. 🙂
Best regards
Fabian
Hello,
First of all great work, exactly what I was looking for.
However, I have a question about the flow.
First of all: I am an absolute newbie when it comes to Home Assistant and Node-Red.
How do I get some of the measured values back in Home Assistant in order to visualize them there or process them further.
I can't create a node that only contains one value (e.g. grid-feed total).
greeting
Rico
Hi Rico,
you can transfer data from NodeRed to HomeAssistant with the homeassistant websocket nodes. (https://flows.nodered.org/node/node-red-contrib-home-assistant-websocket)
Unfortunately I don't have an example (yet). Which of the measurement data do you want in the HomeAssistant? 🙂
Best regards
Fabian
Hello Fabian,
As measured values, I only wanted the current purchase and feed-in
As I said, I'm already failing at just picking up a single value from the function node and outputting it as a debug msg.
Greetings Rico.
Hi Rico,
what single value would you like to get out of a function node? Then I can help you specifically. 🙂
You know that you can also integrate the SMA devices directly via the integration into HomeAssistant? Then you don't need to go through NodeRed. 🙂
Best regards
Fabian
Hi Nerdy,
retrieving the data from the HomeManager works fine , but I notice , as soon as I enable the UDP node on port 9522 in Nodered , the SMA chain doesn't like it , and for example the SunnyBoyStorage is not longer able to connect to the HomeManager , and I get serious connection issues , as I read the log files.
My config is Sunny Home Manager 2.0, Sunny Boy Storage 3.7, Sunny Tripower 6.0
Do you have any suggestions regarding this ?
Kind Regards, Peter
Hi Peter,
hmm that sounds strange. I couldn't observe anything like this. Might be that this is due to the different setup since I do not have the battery storage in my setup. :/ Do you mind sharing some of the (anonymized) log entries?
Best regards
Fabian
Hello,
das sieht ja klasse aus und scheint genau die Basis zu sein um mit meiner “Homematic IP CCU3” den PV-Überschuss zu messen und dann wiederum Verbraucher über Homematic IP zu steuern.
Allerdings wird bei mir ständig “Verbindung wird hergestellt” angezeigt.
What could be the reason?
Many thanks, works right away and exactly what I was looking for to set up my other controls - great!
Gladly! Good luck. 🙂
Hello,
I hope you can help me as a HA newbie.
I integrated everything according to your instructions, unfortunately my flow doesn't say connected like yours.
but connection is established.
Do I have to enter an IP address or what am I doing Flasch.
The SMA Home Manager is in the Sunny Portal and has been writing data there for a long time
I have an SMA Home Manager 2.0, could that be the reason?
Greetings Mathias
Hello,
a great script! How does the SunnyBoy communicate with the Home Manager? Is there a way to read the charge level and charge rate?
Greetings
Hi,
I installed the Home Manager 2.0 and SUNNY TRIPOWER 8.0 SE. The payload length here is 58. Do you have an idea how to get the appropriate specification?
Many thanks and greetings
Hi Andi,
Unfortunately I don't have the exact specifications.
Have you already tried to assign the values using trial and error? 🙂
Best regards
Fabian
I am also trying to understand the message that comes in. Did you already had any luck? My setup looks similar to yours and I’m also receiving 58 payload length.
Hi Fabian,
thanks for the great flow. I’m a beginner, but I really managed to display the data I wanted in HA. However, sending the data every 1s is too often for me. How can I change the flow so that the data is only sent every 2 or 3s
Greetings
Ren
Hi Ren,
actually there is no way to limit the reception interval of the data by manipulating the source itself since this is based on the received broadcasts. But you can use a limit node to limit the data. You have to put it between the “SMA EM” and the function node. In this you can then define the rate that fits best for you. 🙂
Best regards
Fabian
Hi Fabian,
danke für die tolle Arbeit! Läuft sehr fein! Eine Frage habe ich noch. Wenn ich das richtig verstehe, wird der Solarertrag nicht erfasst, richtig? Ich habe erst Einspeisung als solchen interpretiert, da erhalte ich aktuell aber mangels fertiger Anlage und Testaufbau mit nur 2,7kwp aktuell immer nur 0, weil ich nichts in das öffentliche Netz einspeise. Ist meine Annahme richtig? Den Solarertrag würde ich dann direkt vom Inverter erhalten und nicht über den Homemanager?
Danke und viele Grüße
Thomas
Hi Thomas,
danke. 🙂 Ja genau so wie du das beschrieben hast verstehe ich es auch. Ich denke diesen Wert muss du direkt vom Wechselrichter beziehen. Vllt. helfen dir die Infos hier: https://nerdiy.de/de_de/howto-node-red-sma-sunny-solar-wechselrichter-daten-auslesen/
Best regards
Fabian
Hi Fabian,
danke dir, hab die schon alle im Test. Beim Inverter schmiert allerdings meine Node Red Instanz laufend ab. Allerdings nur beim Tripower 10 SE. Bei meinem Sunny Boy 5.0 klappt es.
Mal gucken, ob ich den Fehler finde, aber erstmal spiele ich weiter. 😉
Best regards
Thomas
Alles klar, wenn du mehr rausgefunden hast freue ich mich über Feedback. 🙂
Viel Erfolg!
Fabian