I have spent few days trying to integrate my SMA inverter STP 10000TL-20 with HA and finally today I managed to pull all the data I needed.
The possible solutions I have found looking online didn’t quite work with my inverter, until I found this fantastic tool https://github.com/SBFspot/sbfspot-config
Let me walk you through the options I found in the forum, and the approach + configuration I used.
1: Direct integration using the SMA integration.
In my case this doesn’t work, as the inverter doesn’t accept direct connections.
2: Scraping www.sunnyportal.com public page
Register your inverter to www.sunnyportal.com, make the web page available publicly (e.g. https://www.sunnyportal.com/Templates/PublicPage.aspx?page=XXXXX) and scrape the data from there with the scrape integration.
See for example Scrape sensor for SMA Sunny Portal
Again, in my case this doesn’t work for a number of reasons:
- Public page data is obsolete - I can retrieve system power from 2/3 hours ago
- Page loads asynchronously; scrape integration can use only the original HTML, not the data updated via js calls.
- Limited data is available: not all the parameters are available.
- Custom page logic: complex templates have to be used to compensate for the web page business logic, e.g. sometime the values displayed are kW, others are W…
- Lot of timeouts
Again, no go.
3: SBFspot
This is the perfect solution, also available with installer.
This is what I like:
- It works, and connects to my inverter
- High frequency of sampling
- Solution can run fully locally
- A lot of parameters are available. As we speak, this is the list available:
# Possible keywords are (if supported by your inverter):
# SBFspot Alias Code Description
# =======================================================================
# Timestamp Current date/time
# InvTime Inverter date/time
# SunRise Sunrise time
# SunSet Sunset time
# InvSerial Serial Number
# InvName NameplateLocation Device name
# InvClass NameplateMainModel Device class
# InvType NameplateModel Device type
# InvSwVer NameplatePkgRev Software package
# InvStatus OperationHealth Condition
# InvTemperature CoolsysTmpNom Operating condition temperature
# InvGridRelay OperationGriSwStt Grid relay/contactor
# ETotal MeteringTotWhOut Total yield
# EToday MeteringDyWhOut Day yield
# PACTot GridMsTotW Power
# PDC1/PDC2 DcMsWatt DC power input String 1/2
# UDC1/UDC2 DcMsVol DC voltage input String 1/2
# IDC1/IDC2 DcMsAmp DC current input String 1/2
# OperTm MeteringTotOpTms Operating time
# FeedTm MeteringTotFeedTms Feed-in time
# PAC1 GridMsWphsA Power L1
# PAC2 GridMsWphsB Power L2
# PAC3 GridMsWphsC Power L3
# UAC1 GridMsPhVphsA Grid voltage phase L1
# UAC2 GridMsPhVphsB Grid voltage phase L2
# UAC3 GridMsPhVphsC Grid voltage phase L3
# IAC1 GridMsAphsA_1 Grid current phase L1
# IAC2 GridMsAphsB_1 Grid current phase L2
# IAC3 GridMsAphsC_1 Grid current phase L3
# GridFreq GridMsHz Grid frequency
# BatTmpVal BatTmpVal Battery temperature
# BatVol BatVol Battery voltage
# BatAmp BatAmp Battery current
# BatChaStt BatChaStt Current battery charge status
The tool runs a cron job that connects to the inverter, and stores data locally in a database or in CSV files. It also uploads the data to PVOutput. Recently also to MQTT… Bingo!
Depending on your preferences, to connect to HA you can use:
- PVOutput integration: not my favourite option, as I have to push my data to an external service and retrieve it from there. I prefer to keep the solution limited to my local network.
- Database integration: it’s an option.
- MQTT: my favourite option.
How to get it working?
1: Install SBFspot as per https://github.com/SBFspot/sbfspot-config
2: Complete the setup using the UI.
Once completed, check your setup file - in my case the path was /usr/local/bin/sbfspot.3/SBFspot.cfg
Some important settings to get MQTT working with HA:
MQTT_Topic=sbfspot/serialnumber
MQTT_ItemFormat="{key}": {value}
MQTT_ItemDelimiter=comma
MQTT_PublisherArgs=-h {host} -t {topic} -m "{{message}}"
if your MQTT has user/password, don’t forget to include them
MQTT_PublisherArgs=-h {host} -t {topic} -m "{{message}}" -u username -P password
MQTT_Data=SunRise,SunSet,InvStatus,InvTemperature,InvGridRelay,ETotal,EToday,PACTot,PDC1,PDC2,UDC1,UDC2,IDC1,IDC2,OperTm,FeedTm,PAC1,PAC2,PAC3,UAC1,UAC2,UAC3,IAC1,IAC2,IAC3,GridFreq
In MQTT_Data you can select what fields will be published.
IMPORTANT: Check the json generated, by subscribing to the topic via mosquitto_sub or HA. If the payload is too long, the json is truncated and cannot be parse by HA (bug). The list of parameters I have published above works for me.
3: Subscribe to the MQTT topic and check what is getting published. Amend your config file as required. In my case I would use:
mosquitto_sub -h localhost -t sbfspot/serialnumber -d -u username -P password
To force a reading to be generated, you can find the scripts used by running
crontab -l
In my case it was
/usr/local/bin/sbfspot.3/daydata
4: Add the setup to HA.
For my data, the setup is as follows:
configuration.yaml:
sensor Solar:
- platform: mqtt
state_topic: "sbfspot/123456"
name: "Inverter Sunrise"
value_template: "{{ value_json.SunRise }}"
- platform: mqtt
state_topic: "sbfspot/123456"
name: "Inverter Sunset"
value_template: "{{ value_json.SunSet }}"
- platform: mqtt
state_topic: "sbfspot/123456"
name: "Inverter Status"
value_template: "{{ value_json.InvStatus }}"
- platform: mqtt
state_topic: "sbfspot/123456"
name: "Inverter Temperature"
value_template: "{{ value_json.InvTemperature }}"
unit_of_measurement: '°F'
device_class: temperature
- platform: mqtt
state_topic: "sbfspot/123456"
name: "Inverter Grid Relay/Contactor"
value_template: "{{ value_json.InvGridRelay }}"
- platform: mqtt
state_topic: "sbfspot/123456"
name: "Inverter Total Yeld"
value_template: "{{ value_json.ETotal }}"
unit_of_measurement: 'kWh'
icon: mdi:solar-power
- platform: mqtt
state_topic: "sbfspot/123456"
name: "Inverter Today Yeld"
value_template: "{{ value_json.EToday }}"
unit_of_measurement: 'kWh'
icon: mdi:solar-power
- platform: mqtt
state_topic: "sbfspot/123456"
name: "Inverter Instant Power"
value_template: "{{ value_json.PACTot | int }}"
unit_of_measurement: 'W'
device_class: power
icon: mdi:solar-power
- platform: mqtt
state_topic: "sbfspot/123456"
name: "DC Power String 1"
value_template: "{{ value_json.PDC1 }}"
unit_of_measurement: 'W'
device_class: power
icon: mdi:solar-power
- platform: mqtt
state_topic: "sbfspot/123456"
name: "DC Power String 2"
value_template: "{{ value_json.PDC2 }}"
unit_of_measurement: 'W'
device_class: power
icon: mdi:solar-power
- platform: mqtt
state_topic: "sbfspot/123456"
name: "DC Voltage String 1"
value_template: "{{ value_json.UDC1 }}"
unit_of_measurement: 'V'
icon: mdi:solar-power
- platform: mqtt
state_topic: "sbfspot/123456"
name: "DC Voltage String 2"
value_template: "{{ value_json.UDC2 }}"
unit_of_measurement: 'V'
icon: mdi:solar-power
- platform: mqtt
state_topic: "sbfspot/123456"
name: "DC Current String 1"
value_template: "{{ value_json.IDC1 }}"
unit_of_measurement: 'A'
icon: mdi:solar-power
- platform: mqtt
state_topic: "sbfspot/123456"
name: "DC Current String 2"
value_template: "{{ value_json.IDC2 }}"
unit_of_measurement: 'A'
icon: mdi:solar-power
- platform: mqtt
state_topic: "sbfspot/123456"
name: "Inverter Operating time"
value_template: "{{ value_json.OperTm }}"
unit_of_measurement: 's'
- platform: mqtt
state_topic: "sbfspot/123456"
name: "Inverter Feed-in time"
value_template: "{{ value_json.FeedTm }}"
unit_of_measurement: 's'
- platform: mqtt
state_topic: "sbfspot/123456"
name: "AC Power L1"
value_template: "{{ value_json.PAC1 }}"
unit_of_measurement: 'W'
device_class: power
icon: mdi:solar-power
- platform: mqtt
state_topic: "sbfspot/123456"
name: "AC Power L2"
value_template: "{{ value_json.PAC2 }}"
unit_of_measurement: 'W'
device_class: power
icon: mdi:solar-power
- platform: mqtt
state_topic: "sbfspot/123456"
name: "AC Power L3"
value_template: "{{ value_json.PAC3 }}"
unit_of_measurement: 'W'
device_class: power
icon: mdi:solar-power
- platform: mqtt
state_topic: "sbfspot/123456"
name: "AC Voltage L1"
value_template: "{{ value_json.UAC1 }}"
unit_of_measurement: 'V'
icon: mdi:solar-power
- platform: mqtt
state_topic: "sbfspot/123456"
name: "AC Voltage L2"
value_template: "{{ value_json.UAC2 }}"
unit_of_measurement: 'V'
icon: mdi:solar-power
- platform: mqtt
state_topic: "sbfspot/123456"
name: "AC Voltage L3"
value_template: "{{ value_json.UAC3 }}"
unit_of_measurement: 'V'
icon: mdi:solar-power
- platform: mqtt
state_topic: "sbfspot/123456"
name: "AC Current L1"
value_template: "{{ value_json.IAC1 }}"
unit_of_measurement: 'A'
icon: mdi:solar-power
- platform: mqtt
state_topic: "sbfspot/123456"
name: "AC Current L2"
value_template: "{{ value_json.IAC2 }}"
unit_of_measurement: 'A'
icon: mdi:solar-power
- platform: mqtt
state_topic: "sbfspot/123456"
name: "AC Current L3"
value_template: "{{ value_json.IAC3 }}"
unit_of_measurement: 'A'
icon: mdi:solar-power
- platform: mqtt
state_topic: "sbfspot/123456"
name: "Inverter Grid Frequency"
value_template: "{{ value_json.GridFreq }}"
unit_of_measurement: 'hz'
icon: mdi:solar-power
groups.yaml:
sma_inverter:
name: SMA Inverter
entities:
- sensor.ac_current_l1
- sensor.ac_current_l2
- sensor.ac_current_l3
- sensor.ac_power_l1
- sensor.ac_power_l2
- sensor.ac_power_l3
- sensor.ac_voltage_l1
- sensor.ac_voltage_l2
- sensor.ac_voltage_l3
- sensor.dc_current_string_1
- sensor.dc_current_string_2
- sensor.dc_power_string_1
- sensor.dc_power_string_2
- sensor.dc_voltage_string_1
- sensor.dc_voltage_string_2
- sensor.inverter_feed_in_time
- sensor.inverter_operating_time
- sensor.inverter_grid_frequency
- sensor.inverter_grid_relay_contactor
- sensor.inverter_status
- sensor.inverter_sunrise
- sensor.inverter_sunset
- sensor.inverter_temperature
- sensor.inverter_instant_power
- sensor.inverter_today_yeld
- sensor.inverter_total_yeld
5: Restart everything, and it should work!
Forgot to mention… Once the sun is down, you won’t be able to connect to the inverter, hence all the “unknown” in my screenshot!