SMA Energy Meter in Home Assistant

The what tab ? :slight_smile:

Are you even trying?
The tab as spelled above!

Where do you see it ?

Iā€™ll stop asking questions. It doesnā€™t work for me. Sad but not a problem. Thanks all for your time. Iā€™ll wait till other solutions come overā€¦

Hey, no worries, I guess I wasnā€™t sure, if you were seriousā€¦
Now you are in the main page of the WebConnect interface. This is where a lot of the keys are replaced by aliases.
Click the menu icon (3 lines in a box under the SMA logo) and open the ā€œInstantaneous Valuesā€ tab. Youā€™re gonna see a lot more stuff than on the first page!

Ok, it looks different here, but I think I am on the page you mentioned. Thanks for your patience :wink:

Ya, no worries. Make sure to post your findings on @kellerza 's GitHub page so we can try to advance pysma togetherā€¦
It does look like every different SMA model has different ways to organise data. Sucks, if you ask me. Sometimes wish I had gone with Fronius!

Some keys are the same like what you posted, but none of the valueā€™s can be seen in HA. Strange. I got no errors in the log ā€¦

edit : after 5 min I get 2018-04-26 10:35:56 ERROR (MainThread) [pysma] Max amount of sesions reached

Use the scan_interval or you will saturate Sunny Boy. Also avoid querying 20 keys at once. Please post the keys that are the same as mine on @kellerzaā€™s GitHub so everyone can benefit from your experience: https://github.com/kellerza/pysma

I have to correct myself. The keys are the same !

1 Like

Hi @Faecon, is this working well for you? Iā€™ve still got an issue where WebConnect turns itself off in the interface, meaning I get readings for no more than a few hours before having to manually turn it back onā€¦ Sucks!

Also, can you let us know the model of your inverter? This will help in making more standard sensors availableā€¦

OK, SMA Australia just got back to me with an answer on why I was getting the WebConnect interface to shut down automatically every time. Here is what they said:

It is natural for the inverterā€™s Webconnect function to be disabled because the Home Manager is the data logger that captures the data locally before sending it to Sunny Portal. This means the Sunny Boy has no insentive to itself send data out to the Portal, and lets itself be subject to what the Home Manager requests of it.

This means that your SB5.0 can still communicate with local devices including the Home Manager, but cannot send out data to the internet. As an example, if you set a static IP address on the SB5.0 and use Modbus, you should be able to pull data. However, it now depends on what protocol your home automation system works on. In my opinion, you will need to speak to the developer of your home automation system for advice on how to integrate information from our SB5.0 into their system.

Now, this does not help and means that when using Home Manager, you need to look at ModBus or scraper optionsā€¦ Back to square one, thanks SMA!

No, itā€™s not working for me. I cannot read any value
i have the SMA Sunny Boy SB 3.0 ( https://www.sma-benelux.com/producten/sunny-boy-30-36-40-50.html)

Yea, well Iā€™m exploring ModBusā€¦ Iā€™ll write my config when I get it working. Your inverter should work the same as mine (- the Home Manager, I guess)!

I wish i could help but I know sh$^$ about it :slight_smile: I can test and do some research, but thatā€™s all

is this something ? Solved: convert existing python script to HA component for SMA inverters ?

Ya, no worries dude, thatā€™s what the forum is for. @Phuturist was kind enough to share his code on another thread so you may want to try it here: Solved: convert existing python script to HA component for SMA inverters

Thanks to @Phuturist for sharing! @faecon do report back when youā€™ve tried it.

I cannot change the modbus variable, because I only can login as user and not as an installer

You need to login as installer. Mine had some default password, not sure what it was anymore but Google for it and you will find it.

1 Like

So Iā€™ve been busy rewriting my .yaml to use ModBus instead of WebConnect. Trouble is HAā€™s ModBus implementation only allows for one ModBus device. With a battery charger and an inverter, I need at least 2 ModBus devicesā€¦ I decided the easiest route would be to run a separate instance of HA in Docker, have that read the ModBus values from my Sunny Boy, then publish MQTT messages with the values that I need.
Here is the configuration of the HA instance used to do the above:

homeassistant:
  name: Sunny Boy Sensors
  latitude: !secret home_latitude
  longitude: !secret home_longitude
  elevation: !secret home_elevation
  unit_system: metric
  time_zone: !secret home_time_zone
  customize: !include customize.yaml
  customize_glob: !include customize_global.yaml
config:
#frontend:
mqtt:
  broker: !secret mqtt_url
  port: !secret mqtt_port
modbus:
  type: tcp
  host: !secret sma_sb_ip
  port: !secret sma_sb_port
#http:
#conversation:
#history:
#recorder:
#logbook:
sensor:
  - platform: modbus
    scan_interval: 15
    registers:
      - name: Modbus SB Daily Yield
        unit_of_measurement: kWh
        slave: 3
        register: 30517
        count: 4
        data_type: int
        scale: 0.001
        precision: 3
      - name: Modbus SB Total Yield
        unit_of_measurement: kWh
        slave: 3
        register: 30513
        count: 4
        data_type: int
        scale: 0.001
        precision: 3
      - name: Modbus SB PV Power
        unit_of_measurement: W
        slave: 3
        register: 30775
        count: 2
        data_type: uint
      - name: Modbus SB Grid Power
        unit_of_measurement: W
        slave: 3
        register: 30865
        count: 2
        data_type: uint
      - name: Modbus SB Grid Feed
        unit_of_measurement: W
        slave: 3
        register: 30867
        count: 2
        data_type: uint
  - platform: template
    sensors:
      modbus_sb_pv_production:
        friendly_name: 'PV Output'
        value_template: >-
            {% if states('sensor.modbus_sb_pv_power')|float < 10000 %}
              {{ states('sensor.modbus_sb_pv_power') }}
            {% else %}
              0
            {% endif %}
        unit_of_measurement: "W"
      modbus_sb_total_power:
        friendly_name: 'Total consumption'
        unit_of_measurement: "W"
        value_template: '{{ (((states.sensor.modbus_sb_grid_power.state | float) +
          (states.sensor.modbus_sb_pv_production.state | float))) }}'
automation:
  - id: mqtt_publish_sb
    alias: "MQTT Publish Sunny Boy"
    trigger:
    - platform: state
      entity_id: "sensor.modbus_sb_grid_power"
    action:
    - service: mqtt.publish
      data_template:
        topic: "sma/sb"
        payload: '{"grid_feed":{{ states("sensor.modbus_sb_grid_feed") }}, "grid_consumption":{{ states("sensor.modbus_sb_grid_power") }}, "production":{{ states("sensor.modbus_sb_pv_production") }}, "daily_yield":{{ states("sensor.modbus_sb_daily_yield") }}, "total_yield":{{ states("sensor.modbus_sb_total_yield") }}}'

Here is the MQTT message:

{"grid_feed":0, "grid_consumption":1819, "production":0, "daily_yield":15.884, "total_yield":248.245}

Here are the MQTT sensors in my normal HA instance:

- platform: mqtt
  name: "MQTT SB Daily Yield"
  state_topic: "sma/sb"
  value_template: '{{ value_json["daily_yield"] }}'
  force_update: true
  retain: true
  unit_of_measurement: "kWh"
- platform: mqtt
  name: "MQTT SB Total Yield"
  state_topic: "sma/sb"
  value_template: '{{ value_json["total_yield"] }}'
  force_update: true
  retain: true
  unit_of_measurement: "kWh"
- platform: mqtt
  name: "MQTT SB Production"
  state_topic: "sma/sb"
  value_template: '{{ value_json["production"] }}'
  force_update: true
  retain: true
  unit_of_measurement: "W"
- platform: mqtt
  name: "MQTT SB Grid Feed"
  state_topic: "sma/sb"
  value_template: '{{ value_json["grid_feed"] }}'
  force_update: true
  retain: true
  unit_of_measurement: "W"
- platform: mqtt
  name: "MQTT SB Grid Consumption"
  state_topic: "sma/sb"
  value_template: '{{ value_json["grid_consumption"] }}'
  force_update: true
  retain: true
  unit_of_measurement: "W"

This works really well. The Docker container uses 32MB ram and does not use much processing. This may help someone else who is trying to do the same. I may want more sensors in the future and start scraping the Sunny Portal as there is no way to access data from the Home Manager 2.0 on the LANā€¦

For everyone trying to integrate more than one modbus device, monkey-house found a way how to do it :slight_smile:
So much cleaner than a second instance of HA!