Binding Request: SMA Sunny home manager using sunnyportal.com


(Jens Zach) #1

Hey community,

I´ve got openhab running and intergration of my heatpump, as well as sonos are working fine so far.
Next step is to intergrate my SMA inverter to openhab.

I´ve the following configuration:

  • SUNNY TRIPOWER 9000TL-20
  • SUNNY HOME MANAGER

What is the best approach to get data from my inverter to openhab?


(nikoraes) #2

I use sbfspot (https://sbfspot.codeplex.com/) together with the following rule which reads the last line of the csv file and uploads to pvoutput. Not very elegant but it works.

rule "PV uitlezen"
when
	Time cron "0 0/5 5-23 * * ?"
then
	executeCommandLine("/home/pi/SBFspot/SBFspot.sh > /dev/null")
	
	var String PVd = String::format( "%1$tY%1$tm%1$td", new Date() )
	var String PVt = String::format( "%1$tH:%1$tM", new Date() )
	
	var String smaspotlogfile = String::format( "/home/pi/smadata/%1$tY/ni-lo-pv-Spot-%1$tY%1$tm%1$td.csv", new Date() )
	val fileReader = new java.io.FileReader(smaspotlogfile)
	var String line
	var String nextline
	try {
		val values = new java.io.BufferedReader(fileReader)
		nextline = values.readLine
		while (nextline != null) {
			line = nextline
			nextline = values.readLine
		}		
	}	
	finally {
		try { fileReader.close() } catch (Exception e) {}
	}
	var String[] pvbuffer = line.replace(",",".").split(";")
	postUpdate (PVPac1, Float::parseFloat(pvbuffer.get(10)))
	postUpdate (PVIac1, Float::parseFloat(pvbuffer.get(13)))
	postUpdate (PVUac1, Float::parseFloat(pvbuffer.get(16)))
	postUpdate (PVEtoday, Float::parseFloat(pvbuffer.get(22)))
	postUpdate (PVEtotal, Float::parseFloat(pvbuffer.get(23)))
	postUpdate (PVFreq, Float::parseFloat(pvbuffer.get(24)))
	postUpdate (PVPdc1, Float::parseFloat(pvbuffer.get(4)))
	postUpdate (PVIdc1, Float::parseFloat(pvbuffer.get(6)))
	postUpdate (PVUdc1, Float::parseFloat(pvbuffer.get(8)))
	postUpdate (PVPdc2, Float::parseFloat(pvbuffer.get(5)))
	postUpdate (PVIdc2, Float::parseFloat(pvbuffer.get(7)))
	postUpdate (PVUdc2, Float::parseFloat(pvbuffer.get(9)))
	postUpdate (PVConditie, pvbuffer.get(28))
	postUpdate (PVTemp, Float::parseFloat(pvbuffer.get(30)))
	
	var String v1 = (PVEtoday.state as DecimalType * 1000).intValue().toString
	var String v2 = (PVPac1.state as DecimalType).intValue().toString
	var String v5 = String::format("%.1f", (PVTemp.state as DecimalType).floatValue())
	var String PVOutputGET = "http://pvoutput.org/service/r2/addstatus.jsp?key=xxxxx&sid=xxxxx&d=" + PVd + "&t=" + PVt + "&v1=" + v1 + "&v2=" + v2 + "&v5=" + v5
	logInfo("PV-GET",PVOutputGET)
	sendHttpGetRequest(PVOutputGET)

end

with the following sbfspot.sh

#!/bin/bash
/usr/local/bin/sbfspot.3/SBFspot -nosql

SMA EnergyMeter 4x
Rules: Reading from file
(Jens Zach) #3

Hi nikoraes,

Sbfspot will gather the data from the inverter and does not consider the information from the power meter, am I right?

My idea is to check also my electrical consumption as well what is feed to the grid.


(Jens Zach) #4

Till now I am a step further,

I discoverd, that sunnyportal is providing real data from my inverter as well as my power meter in that format:
{"__type":“LiveDataUI”,“Timestamp”:{"__type":“DateTime”,“DateTime”:“2015-11-02T10:51:15”,“Kind”:“Unspecified”},“PV”:4696,“FeedIn”:4378,“GridConsumption”:0,“DirectConsumption”:null,“SelfConsumption”:318,“SelfSupply”:318,“TotalConsumption”:318,“DirectConsumptionQuote”:null,“SelfConsumptionQuote”:7,“AutarkyQuote”:100,“BatteryIn”:null,“BatteryOut”:null,“BatteryChargeStatus”:null,“OperationHealth”:null,“BatteryStateOfHealth”:null,“InfoMessages”:[],“WarningMessages”:[],“ErrorMessages”:[],“Info”:{}}

All the binding need to do is, to log in at https://www.sunnyportal.com and read back the data while calling https://www.sunnyportal.com/homemanager
Can anyone help in that topic?


(Jens Zach) #5

Situation has changed a little bit.
SMA has now published the SEMP protocoll to gather data directly from Sunny Home Manager.

Is someone working on this or interested in getting it done?


(John Cocula) #6

Someone appears to have built a binding that might be related to this?


(Jens Zach) #7

unfortunately I do have Sunny Home Manager and not Sunnywebbox.


(Joe) #8

Hi Jens,

Same situation here! Ich also discovered the json data by sniffing my fritzbox.
I want to switch my heatpump between normal circuit and heatpump circuit depending in power situation from my solar system.

Problem: let’s call me a DAU in regards to programming - I have no clue about automatically logging in and pulling/saving data locally for switching.
Integration into openhab sounds very interesting to me! Any progress so far? I just saw that SMA now supports modbus as well.

Can anyone help? I would REALLY appreciate it!

Cheers,
Jochen


(Peter Priebe) #9

Hallo Jens,
the SEMP protocoll does not deliver any live datas. It connects the SMA Home Manager with other electrical machines e.g. like washing machine to control the switch on/off depending on the power of the pv modules.

So this is no solution for our problem!

peter54


(Peter Priebe) #10

Hi Jens,

any news to this topic? Did you find another solution?

I’m still waiting for a OH2 binding. Can anybody help?

peter54


(Jens Zach) #11

Yes, I changed to IP-SYMCON


(KD) #12

Would you agree to share all your config ?

At the moment I use sunnyexplorer to extract my SMA data and upload on a website (mysql) to display the usage, …

I have now installed SBFSpot on my Rasb and this looks promising. I’d like to grab your config to see what are the different graphs posibilities

Thank


(Kim Andersen) #13

How do you use Sunny Explorer?


(KD) #14

I use it on my windows server (it only runs there) I have a script (found on some other posts) that extract a CSV file and then I upload it on my zonphp website (http://zonphp.cindyenguy.be/)

Now, as I have SBFSpot on my rasp, it’s easier to get it all done from a central location


(Kim Andersen) #15

Okay… The reason I ask is because a seek a solution for our SMA solar setup:

Sunny Tripower 6000TL
Sunnyboy Storage 2.5
SMA Energy Meter.
LG chem Resu 10 (10kWh lithium battery).

There is a binding for the Energy Meter, but I cant use it because the Energy Meter is connected directly to the Sunnyboy 2.5, running speedwire inbetween, which means I can´t reach the Energy Meter on my LAN. (I have tried connecting the Energy Meter to my main switch, but that resolved in the Sunnyboy wont see the Energy Meter, leaving me without data update on Sunny Portal). It should have been working, but isn´t for some reason.

So I am searching for an alternative way to collect the data, either from Sunny Portal og Sunny Explorer.


(Leo Verkaik) #16

Hi,

Just another way of getting this done.

I needed to use the current power from the SunnyBoy to be used and diplayed in OpenHab2. This for switching the electro car charger on and off, depending on the power from the solar panels.

For this purpose I installed a headless webscraper on the OpenHabian Pi, made a Python script to get the values from sunnyPortal.com and send the current values to OpenHab2 by the mqtt binding. With an alogorithm using the current value and the average of the last 5 minutes I switch the charger on and off.

The average of the last 5 minutes is easily calculated thanks to the persistence functions of OpenHab.

The Python script needs a lot of error handling to get the input stream stable, but it finally seems to work so far.

For webscraping see: http://www.mantonel.com/tutorials/web-scraping-raspberry-pi-and-python

Adressing the “currentPower” in the webbrowser:

divElement = browser.find_element_by_xpath(’//div[@data-name=“pvPower”]’)
SubHead = divElement.find_element_by_xpath(’.//div[@class=“widgetSubHead”]’).text
currentPower = divElement.find_element_by_xpath(’.//span[@class=“mainValueAmount”]’).text

Nb. you will need the SubHead info to, if it is not null, the currentPower is old info.

If anyone is interested in more info, let me know.

Good luck !


(Markus) #17

Hi,

I wrote a SEMP service for OpenHab, You can test it if you like.
SEMP Service

Greetings
Markinus


(Markus) #18

Hi,

I have a similar configuration. Tripower 9000, Boy Storage 5.0 and Home Manager 2.0. The best way to collect data is with modbus. OpenHab is able to comunicate directly with these devices. I wanted to write a binding for that but we don’t need that. Here are my configuration files for modbus. Maybe you can use some stuff from it.
The list of modbus registers is availible from the SMA website. You have to enable modbus on the tripower and on the boy storage and activate the modbus binding.

Modbus SMA.zip.txt (6.1 KB)

(it’s a zip file, remove the .txt from filename).
Greetings
Markus


(Kim Andersen) #19

I already have modbus running for my Nilan ventilation system…
I think I´ll try with the Smart Energy meter binding again. I have spoken to a few people, and they said it should work, if I insert the energy meter and the Sunnyboy storage 2.5 directly into my switch. And then reset the Energy Meter (<-- important step).
After that Sunnyboy storage should be able to see the energy meter. And openhab will be able to connect to the energy meter as well through the binding. I just need some free time to make the change :slight_smile: