Presenting SMA converter values

Wow, that is a great feature, thanks for sharing! But would it work with logging in though? For that, you would need several steps. It might be possible, but I have not delved into the link that you shared, as I was already thinking on different possibilities. The reasons:

  • It seemed like scan_interval did not allow for quick polling (in my case, 5s; not sure if this is a bug though…)
  • Even if scan_interval would work, using CasperJS was not quick enough to actually get through all the steps in 5s and timeouts were a common occurence

So I had to look for different possibilities. I have found the node osmosis webscraper, which is a lot quicker than CasperJS, but also a bit less intuitive. Also, because of some less than expert programming on the side of SMA, it was not possible to actually get into the Sunny Portal. Banging my head against the Sunny Portal, I decided to take a look at the inverter to see if that was any easier.

And indeed it seems like the good people at SMA are better at making their inverter webserver that that of their website. Turns out that you only need two server calls for getting the necessary data. Be aware, this works for me as I have a new Sunny Boy 2.5. If you try this, I think you have to have Webconnect from SMA on your inverter.

The first call is to get a session ID:

curl -X POST -H "Connection: keep-alive" -H "Content-Length: 37" -H "Accept: application/json" -H "Accept-Encoding: gzip, deflate" -H "Content-Type: application/json" -H "Cache-Control: no-cache" -H  '{"right":"usr","pass":"[[YOUR_PASSWORD]]"}' "http://[[INVERTER_IP]]/dyn/login.json"

You will receive the follow response containing a session id:

{
  "result": {
    "sid": "_-s_pfe_sQO_5ce5"
  }
}

With the session ID, you can retrieve data:

curl -X POST -H "Connection: Keep-alive" -H "Content-Length: 37" -H "Accept: application/json" -H "Accept-Encoding: gzip, deflate" -H "Content-Type: application/json" -H "Cache-Control: no-cache" -H '{"destDev":[],"keys":["6100_40263F00"]}' "http://[[INVERTER_IP]]/dyn/getValues.json?sid=_-s_pfe_sQO_5ce5"

In this example, I only request the current power with the key “6100_40263F00”. If you want different values, you can just add these to the keys. To see which key is which value, you can check the id in the HTML code when you login to your inverter with your browser.

Using these requests, I have created a NodeJS application which runs the second request every 5 seconds. It also does some error handling, as sometimes a request does not successfully receive a session id. When it gets a value, it uses the Restful API from HA to write the value to a template sensor.

There are several reasons why I have decided to create a separate system for collecting the information:

  • I want data to be written to InfluxDB at a certain point. Now that I have the current power being sent to HA, it is a matter of creating a new request that also sends it to InfluxDB.
  • I want to collect more data from the inverter, but at different time intervals (I don’t need to check every 5 seconds how much we collected yesterday :slight_smile:).
  • I am still considering sending the data through a MQTT broker (because I want to learn how it works, and throwing data directly to the Restful API which forcefully changes the value just feels dirty…).
  • I am considering requesting different sources of data (for example getting the amount of money that I am saving, for which I need to get the price per kW from my energy provider).

An image on two different states which were changed by the NodeJS script:

Any views on this are highly appreciated! And if you need more information on my work, let me know, I am more than happy to help. I am curious if this also works for other people.

1 Like

I’m also looking for a solution to bring SMA data into HA. I started to look at SBFSpot which seems like it brings the data into a database using the bluetooth connection and/or the speedwire module. Haven’t looked into it in detail, but might help you.

Hi!
I’m also looking for a solution to bring SMA data into Hass.
I try it with the scrape Sensor on my public website- so I don’t have to Login:

platform: scrape
    resource: "https://www.sunnyportal.com/Templates/PublicPage.aspx?page=7431e23c-a310-4fdf-99ec-e31db735d65f"
    name: pv
    select: '.mainValue'
    unit_of_measurement: 'KW/h'

But I only get a “-” as result :frowning:

1 Like

Hi @Ivor, thanks for sharing!

I also recently installed a SunnyBoy (1.5 with Webconnect) and playing around with getting the data into HASS. Step 1 is done, with a pysma library that will query Webconnect from HASS. Will complete the HASS sensor platform soon, and hopefully you have some pointers on what properties you use.

Initial docs PR available here

What SMA models do you all have?

Hey!
I have the Sunny Mini Central 6000TL and Sunny Mini Central 7000HV.
And I use the SMA WebBox.

Hi @Marius82, thanks!

Not sure if it will work, but you can try the sensor, it is available on https://github.com/home-assistant/home-assistant/pull/5118

The easiest way to try might be to add the sma.py file to your custom_components folder (e.g. ~/.homeassistant/custom_components/sensor/sma.py)

I’ve written some node.js to grab historical data from my inverter. Others might find it useful for that purpose, or just as a reference. If you’re interested, check it out:

Be aware that I’ve only tried this on one inverter, my own! If you try it, and see any problems, please file an issue on github. Thanks!

At our old house, I had an SMA with web connect. I wrote a python module to convert everything to MQTT messages. You can customize the frequency (it’s a polling system) and it can report instantaneous, daily, etc. The code is here: https://github.com/TD22057/T-Home. I don’t have the inverter anymore (we moved) but you’re welcome to fork and do whatever you want. If you just want Home Assistant integration, why not use: https://home-assistant.io/components/sensor.sma/

1 Like

Would it be possible to make something like this in HA ?

  1. actual W ( that’s already ok). Is it possible to make a meter like this ?
  2. total W of today
  3. Weather : already ok
  4. graph : with graphana i think ? how can I chance between days and month’s ?
  5. Table ( Table on front-end I think)

Hey @marius82,
How do you get your inverters to publish a pblic page like this?

Hi,

Thanks a lot for this. I also noticed the different codes used. As you already have a nodeJS application built, would you mind sharing it with me? It would be highly appreciated.
Once again a big thank you for this!

Maxime

log into sunnyportal and on first page in the bottom there is a configuration option. within that you can find a custom link for your system.

BUT in my Experience its really bad on updating comparing to the data you get when you logged in.

since i want to use the data for current consumption right now it does not work for me

1 Like

Anyone have a working integration to newer SMA Inverters right now? The SMA sensor does not work on my inverter, think they skipped the the service on tcp/ip in later firmwares/devices.
Or iam doing something wrong since i cant connect to it locally at all via ip.

Hey @nsim, thanks for sharing the tip on making the info public.

On newer SMA Sunny Boy inverters (with -40 at the end of the model number), you should see the Sunny Boy on your local network by using an app like Fing. If not, then it is not using your Wifi and probably does not connect to the Internet.
In that case, you should be able to connect directly to the inverter’s Wifi SSID. With an installer account you can change the Wifi settings. While you are there, enable ModBus TCP and WebConnect connections. These are the two ways you can read the sensors from the inverter in the most easy fashion. Neither are perfect:

  1. WebConnect allows many sensors to be read, including daily consumption. It’s a pain to find the sensor keys: connect to the inverter with Google Chrome, click the Instantaneous values tab, right click the value you want and click the Inspect feature, then write down the sensor key. It does not work, if, like me, you have a Home Manager, as WebConnect connections are reset to off within minutes.
  2. ModBus is fairly easy to use. Issue is you can only read sensors from one ModBus device with the current Home Assistant integration. I had to make a special instance of Home Assistance just to read a second device… You also need to get register keys from SMA’s clumsy Excel sheets.

If you need pre-written code for Sunny Boy and/or Sunny Island, I’ve shared my config elsewhere here:
https://community.home-assistant.io/t/sma-energy-meter-in-home-assistant/47482/42?u=monkey-house

Thanks for taking the time. Iam currently stuck trying to connect to the SMA inverter. I see it on the network. But it does not respond. I should have written this before that I have a SMA tripower and not a sunny boy.

Should exist a BT connection to it for configuration so will try to see if I have better luck that way of communicating the over IP.

Thanks for the link and description. Will try to analyze this more

Yup, no experience with TriPower so no idea. However the Home Manager I use is no help and you cannot connect to it via LAN at all… Unfortunately, SMA does not seem very Home Automation friendly. I even got an email from their Germany-based international services saying their inverters were not allowing for local integration: “A extended integration in your house system is not possible.”!
Makes me wish I’d chosen another brand.

2 Likes

@nsim, OK I found the custom link, but need to log in to access data. Do you need to enable this option?

Approval to use data via the online tool Sonnenertrag.eu:

all i done is just to use the link that is below.
Can use the link from link from othere devices when not loged in

I guess your installer must have set data release to public. I need to get an installer account for Sunny Portal, if that is the case…

OK, got the public page released. Unfortunately, there is very little data obtainable this way. On top of the ModBus sensor (Yield, Daily Yield, Total Yield, Grid Consumption, Grid Feed from Sunny Boy & Battery Charge, Battery Charging/Discharging Power, Grid Voltage, Grid Frequency from Sunny Island), I want to get data like daily total consumption. Did anyone manage to compute this data through Home Assistant from Total current consumption?