kellerza / pysma Goto Github PK
View Code? Open in Web Editor NEWAsync library for SMA Solar's WebConnect interface
License: MIT License
Async library for SMA Solar's WebConnect interface
License: MIT License
Hi, thank you for sharing this with us !
However I cannot get it to work. I have tried several settings and options provided by other users but still get "Unknown" as values from sma. I have the correct user password and IP address of the sma and I can connect to it using Sunnyboy Explorer.
My configuration.yaml (one of the versions I tried):
- platform: sma
host: 192.168.1.118
password: !secret smaPsw
# ssl: true
# verify_ssl: false
# group: user
# scan_interval: 120
# sensors:
# - current_consumption
# - total_consumption
# - pv_power
# - total_yield
# - status
# - pv_gen_meter
No matter what options here I comment out or not .. always get the same "Unknown" values.
The HA log shows :
Logger: pysma
Source: /usr/local/lib/python3.8/site-packages/pysma/init.py:234
First occurred: 17:03:08 (2 occurrences)
Last logged: 17:03:13
Could not start session, Could not connect to SMA at http://192.168.1.118 (timeout), got {}
Anything I should do/change or check ?
Big thanks for your help !
Tony
Hi there,
first of all a big thank you for your efforts on this, it makes my day a lot more informative (multiple times :-)
Ok, so here is what i actually have (preventing me from update HA to post 21.4)
This i do have to do, because for instance the battery specific sensors are only given by the Sunny Insland, some others only given by the TriPower, some are given by both (identical readouts, but different ids or even identical ids).
I do need sensors from both devices for quite a lot of template sensors to get the bigger picture of the whole installation.
If i am right, after updating post 21.5.x i can only configure ONE device via integrations and cannot use the custom sensors anymore, right?
So i am basically stuck with 21.4.x (i am relying on my personal HA solar dashboard and some calculations that are done there)?
I would very much like to contribute to the pysma library to get the custom sensor data included (how would i do that (new to github stuff, sorry)) and foremost to work out an integration of more than one device. Is that even planned/thought of?)
Thank you very much.
PS; My YAML integration at the moment looks like this (excerpt)
################################################################################
# SMA Solar - Tripower
################################################################################
- platform: sma
host: 192.168.0.xxx
ssl: true
verify_ssl: false
password: xxx
sensors:
# - current_consumption
# - total_consumption
- pv_power
- daily_yield
- total_yield
- grid_power_supplied
- grid_power_absorbed
# - grid_power
# - grid_total_yield
################################################################################
# SMA Akku - Sunny Island 4.4
################################################################################
- platform: sma
host: 192.168.0.yyy
password: yyy
sensors:
# - total_yield
custom:
sma_si_batt:
key: '6100_00295A00'
unit: '%'
factor: 1
path: '"7"[0].val'
sma_si_lad:
key: '6100_00496900'
unit: W
factor: 1
path: '"7"[0].val'
sma_si_entlad:
key: '6100_00496A00'
unit: W
factor: 1
path: '"7"[0].val'
sma_batt_temp:
key: '6100_40495B00'
unit: °C
factor: 1
path: '"7"[0].val'`
For the NixOS package we would like to run the tests.
Could you please tag the source which would produce a release on GitHub or add the tests to the source tarball that is published on PyPI?
Thanks.
using the sma energy meter instead of the sma sunny boy. getting "no successful value decoded yet", any ideas?
config:
sensor:
# - platform: yr
- platform: sma
host: 192.168.1.6
password: !secret my_password
scan_interval: 5
ssl: true
verify_ssl: false
group: installer
sensors:
voltage_l1:
voltage_l2:
voltage_l3:
custom:
voltage_l1:
key: "6100_00464800"
unit: V
factor: 100
voltage_l2:
key: "6100_00464900"
unit: V
factor: 100
voltage_l3:
key: "6100_00464A00"
unit: V
factor: 100
logs:
2019-03-11 20:24:11 DEBUG (MainThread) [pysma] {"result": {"015D-715540E1": {"6100_00464900": {"65": [{"val": 22091}]}, "6100_00464800": {"65": [{"val": 22493}]}, "6100_00464A00": {"65": [{"val": 0}]}}}}
2019-03-11 20:24:11 DEBUG (MainThread) [pysma] Sensor voltage_l2: No successful value decoded yet: {'65': [{'val': 22091}]}
2019-03-11 20:24:11 DEBUG (MainThread) [pysma] Sensor voltage_l3: No successful value decoded yet: {'65': [{'val': 0}]}
2019-03-11 20:24:11 DEBUG (MainThread) [pysma] Sensor voltage_l1: No successful value decoded yet: {'65': [{'val': 22493}]}
Hi,
I was wondering if you would like to consider adding mqtt support. It's becoming a very common standard in home automation and it would open doors in adding support for other systems like Domoticz or Openhab for monitoring SMA inverters.
Sending value's as mqtt payloads to a broker would suffice.
Thanks!
Hi, any clues as to why I'm getting thrown this error?
pi@emonpi(rw):pysma$ python3 example.py 192.168.2.2 user 0000
DEBUG:asyncio:Using selector: EpollSelector
ERROR:pysma:Could not start session, Could not connect to SMA at http://192.168.2.2 (timeout), got {'err': 'Could not connect to SMA at http://192.168.2.2 (timeout)'}
INFO:__main__:No session ID
SBFSpot connects fine, but was hoping to get a simpler program to work, so I can send the data elsewhere.
Hello all,
I observed yesterday a total_yield value of zero during the night.
While this is a great improvement for the other sensors, this is a problem for this one.
The energy tab is now entirely incorrect because the total_yield went from 12 000 to 0 then to 12 000 kWh.
I'm not familiar enough with the library to guarantee that it is a problem or to make a PR.
Regards,
Home assistant logs are showing an error for the total_consumption sensor:
Logger: homeassistant
Source: helpers/entity.py:289
First occurred: 22:25:48 (1 occurrences)
Last logged: 22:25:48
Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sma/sensor.py", line 167, in async_sma
sensor.async_update_values()
File "/usr/src/homeassistant/homeassistant/components/sma/sensor.py", line 225, in async_update_values
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 289, in async_write_ha_state
raise RuntimeError(f"Attribute hass is None for {self}")
RuntimeError: Attribute hass is None for <Entity total_consumption: 0.0>
It is a sensor that I'm not using, so not a major issue for me, but logs without errors are allways nicer :)
I managed to get this working with Home Assistant using the predefined keys. I'm not having any luck with setting up custom values and am getting errors in the log. The docs are not very clear on how to set this up (I'm happy to update these once I understand).
@kellerza: Can you please have a quick look at the code below and let me know how to correct this?
- platform: sma
host: "192.168.xx.xx"
password: "xxxxxxxx"
sensors:
custom:
battery_charge:
key: "6100_00295A00"
unit: "%"
factor: "1"
A few questions while I'm on it.
If I can get this to work, I'd much rather use this than the Modbus integration. Seems safer not to use Modbus and to close the Modbus comm as it allows for settings to be changed remotely. This is also easier to set up and find sensor keys with just a feww clicks using Google Chrome's Inspect function.
Hello. First of all thanks for this library.
I'm a basic user of Python (thus not an expert). I'm trying to run the example provided here but I don't find where I have to define the IP, password and login of my SMA inverter.
Excuse-me for this basic question but I'm trying for hours without any results and still get this message:
usage: SMA retrieve.py [-h] ip user password
SMA retrieve.py: error: the following arguments are required: ip, user, password
Should I add some variable definition in the header like this?
ip = "192.168.1.160"
user = "istl"
password = "1234"
Anyway, it doesn't seem to work.
Thanks by advance for reply.
Hi @kellerza
My invertor does not have a instantaneous value for the Today Yield and Yesterday Yield. It would come in handy to store these in an influxdb.
Would you be able to add some code that handles this as well? The code on the homepage on the invertor looks like this:
<tbody>
<!-- ngRepeat: row in tableContent -->
<tr ng-repeat="row in tableContent" class="ng-scope">
<td translate="lYieldToday" class="ng-scope">Today:</td>
<td style="text-align: right">
<!-- ngIf: row.key -->
<!-- ngIf: row.calcValKey -->
<span ng-if="row.calcValKey" class="ng-binding ng-scope"> 12.91 kWh </span>
<!-- end ngIf: row.calcValKey -->
</td>
</tr><!-- end ngRepeat: row in tableContent -->
<tr ng-repeat="row in tableContent" class="ng-scope">
<td translate="lYieldYesterday" class="ng-scope">Yesterday:</td>
<td style="text-align: right">
<!-- ngIf: row.key -->
<!-- ngIf: row.calcValKey -->
<span ng-if="row.calcValKey" class="ng-binding ng-scope"> 20.77 kWh </span>
<!-- end ngIf: row.calcValKey -->
</td>
</tr><!-- end ngRepeat: row in tableContent -->
<tr ng-repeat="row in tableContent" class="ng-scope">
<td translate="lYieldTotal" class="ng-scope">Total:</td>
<td style="text-align: right"> <!-- ngIf: row.key -->
<!-- ngIf: row.calcValKey -->
<span ng-if="row.calcValKey" class="ng-binding ng-scope"> 394.3 kWh </span>
<!-- end ngIf: row.calcValKey -->
</td>
</tr><!-- end ngRepeat: row in tableContent -->
</tbody>
I will add the page itself + screenshot too.
Could you provide an example for the correct syntax to call example.py?
I have problems to handover the parameter (ip. user, passwd).
Pysma/pysma $ python3.6 example.py "192.168.2.116" "user" "0000"
DEBUG:asyncio:Using selector: EpollSelector
Traceback (most recent call last):
File "example.py", line 73, in
main()
File "example.py", line 70, in main
loop, user=args.user, password=args.password, ip=args.ip))
File "/usr/local/lib/python3.6/asyncio/base_events.py", line 467, in run_until_complete
return future.result()
File "example.py", line 27, in main_loop
if VAR['sma'].sma_sid is None:
AttributeError: 'SMA' object has no attribute 'sma_sid'
Anyone that have an example how to get data for one or more keys?
I don't want to ask for all keys.
I tried the example in https://github.com/kellerza/pysma/blob/master/docs/getting_started.rst but it doesn't work.
Hi,
this is not really an issue but rather a question. Details see https://community.home-assistant.io/t/sma-energy-meter-in-home-assistant/47482/69.
Seems as if pysma is only reading the value of input [A] of the inverter, but not [B]. Or is this just a wrong configuration on my end?
Sorry, if this is not the right place for this, but i don't know, where to leave it.
I set up the SMA in HA and get all the standard readings correct, except for the
total_consumption and current consumption - sensors. These are giving me a
No values for sensors: total_consumption [6400_00543A00],current_consumption [6100_00543100]
in the logs. The remaining sensors provided are working as expected.
I dove into my converter and found the sensor to be
6400_00462500
- for total_consumption.
The current_consumption i am not able to find in my web-interface, but would very much like to provide, if given directions what to look for.
Thanks and sorry for bothering you.
Hi all,
Thanks for spending time getting this together. Just got a Sunny Boy and Sunny Island with Home Manager 2 installed.
I'd love to access a lot more sensors from Home Assistant. Is there a method to find sensor keys? I would love to get access to things like battery charge, battery temperature, PV production, etc...
Alternatively, any link to a page with more SMA sensor keys would be welcomed...
I am getting the following error twice each poll:
ERROR (MainThread) [pysma] 'int' object is not iterable
I am connecting to our sunny boy 2.5 with Hassio SMA component
It has been working very good for a couple of weeks now.
Suddenly this night around 2 a.m. SMA gives None on all vales.
Anyone seen this before and know a solution.
Restart of SMA didn't work.
I also have an SMA Energy Meter.
EDIT: data is visible in GUI for the SMA
I can get lots of data with your code, very nice tool :)
But I do not get all of the values, some is None.
Is this possible to fix?
I also have SMA Energy Meter.
I am missing metering_current_consumption, metering_total_consumption
Sensor(key='6180_08214800', name='status', unit='', factor=None, path=('"{}"[{}].val[0].tag', 'val[0].tag'), enabled=True, l10n_translate=True, value=None)
Sensor(key='6380_40251E00', name='pv_power_a', unit='W', factor=None, path=None, enabled=True, l10n_translate=False, value=None)
Sensor(key='6380_40251E00', name='pv_power_b', unit='W', factor=None, path=None, enabled=True, l10n_translate=False, value=None)
Sensor(key='6380_40251E00', name='pv_power_c', unit='W', factor=None, path=None, enabled=False, l10n_translate=False, value=None)
Sensor(key='6380_40451F00', name='pv_voltage_a', unit='V', factor=100, path=None, enabled=False, l10n_translate=False, value=None)
Sensor(key='6380_40451F00', name='pv_voltage_b', unit='V', factor=100, path=None, enabled=False, l10n_translate=False, value=None)
Sensor(key='6380_40451F00', name='pv_voltage_c', unit='V', factor=100, path=None, enabled=False, l10n_translate=False, value=None)
Sensor(key='6380_40452100', name='pv_current_a', unit='A', factor=1000, path=None, enabled=True, l10n_translate=False, value=None)
Sensor(key='6380_40452100', name='pv_current_b', unit='A', factor=1000, path=None, enabled=True, l10n_translate=False, value=None)
Sensor(key='6380_40452100', name='pv_current_c', unit='A', factor=1000, path=None, enabled=False, l10n_translate=False, value=None)
Sensor(key='6100_40263F00', name='grid_power', unit='W', factor=None, path=None, enabled=True, l10n_translate=False, value=None)
Sensor(key='6100_00465700', name='frequency', unit='Hz', factor=100, path=None, enabled=False, l10n_translate=False, value=None)
Sensor(key='6100_40465300', name='current_l1', unit='A', factor=1000, path=None, enabled=False, l10n_translate=False, value=None)
Sensor(key='6100_40465400', name='current_l2', unit='A', factor=1000, path=None, enabled=False, l10n_translate=False, value=None)
Sensor(key='6100_40465500', name='current_l3', unit='A', factor=1000, path=None, enabled=False, l10n_translate=False, value=None)
Sensor(key='6100_00464800', name='voltage_l1', unit='V', factor=100, path=None, enabled=False, l10n_translate=False, value=None)
Sensor(key='6100_00464900', name='voltage_l2', unit='V', factor=100, path=None, enabled=False, l10n_translate=False, value=None)
Sensor(key='6100_00464A00', name='voltage_l3', unit='V', factor=100, path=None, enabled=False, l10n_translate=False, value=None)
Sensor(key='6100_40464000', name='power_l1', unit='W', factor=None, path=None, enabled=False, l10n_translate=False, value=None)
Sensor(key='6100_40464100', name='power_l2', unit='W', factor=None, path=None, enabled=False, l10n_translate=False, value=None)
Sensor(key='6100_40464200', name='power_l3', unit='W', factor=None, path=None, enabled=False, l10n_translate=False, value=None)
Sensor(key='6400_00260100', name='total_yield', unit='kWh', factor=1000, path=None, enabled=True, l10n_translate=False, value=None)
Sensor(key='6400_00262200', name='daily_yield', unit='Wh', factor=None, path=None, enabled=True, l10n_translate=False, value=None)
Sensor(key='6400_0046C300', name='pv_gen_meter', unit='kWh', factor=1000, path=None, enabled=True, l10n_translate=False, value=None)
Sensor(key='6100_40463600', name='metering_power_supplied', unit='W', factor=None, path=None, enabled=True, l10n_translate=False, value=None)
Sensor(key='6100_40463700', name='metering_power_absorbed', unit='W', factor=None, path=None, enabled=True, l10n_translate=False, value=None)
Sensor(key='6100_00468100', name='metering_frequency', unit='Hz', factor=100, path=None, enabled=True, l10n_translate=False, value=None)
Sensor(key='6400_00462400', name='metering_total_yield', unit='kWh', factor=1000, path=None, enabled=True, l10n_translate=False, value=None)
Sensor(key='6400_00462500', name='metering_total_absorbed', unit='kWh', factor=1000, path=None, enabled=True, l10n_translate=False, value=None)
Sensor(key='6100_40466500', name='metering_current_l1', unit='A', factor=1000, path=None, enabled=True, l10n_translate=False, value=None)
Sensor(key='6100_40466600', name='metering_current_l2', unit='A', factor=1000, path=None, enabled=True, l10n_translate=False, value=None)
Sensor(key='6100_40466B00', name='metering_current_l3', unit='A', factor=1000, path=None, enabled=True, l10n_translate=False, value=None)
Sensor(key='6100_0046E500', name='metering_voltage_l1', unit='V', factor=100, path=None, enabled=False, l10n_translate=False, value=None)
Sensor(key='6100_0046E600', name='metering_voltage_l2', unit='V', factor=100, path=None, enabled=False, l10n_translate=False, value=None)
Sensor(key='6100_0046E700', name='metering_voltage_l3', unit='V', factor=100, path=None, enabled=False, l10n_translate=False, value=None)
Sensor(key='6100_0046E800', name='metering_active_power_feed_l1', unit='W', factor=None, path=None, enabled=True, l10n_translate=False, value=None)
Sensor(key='6100_0046E900', name='metering_active_power_feed_l2', unit='W', factor=None, path=None, enabled=True, l10n_translate=False, value=None)
Sensor(key='6100_0046EA00', name='metering_active_power_feed_l3', unit='W', factor=None, path=None, enabled=True, l10n_translate=False, value=None)
Sensor(key='6100_0046EB00', name='metering_active_power_draw_l1', unit='W', factor=None, path=None, enabled=True, l10n_translate=False, value=None)
Sensor(key='6100_0046EC00', name='metering_active_power_draw_l2', unit='W', factor=None, path=None, enabled=True, l10n_translate=False, value=None)
Sensor(key='6100_0046ED00', name='metering_active_power_draw_l3', unit='W', factor=None, path=None, enabled=True, l10n_translate=False, value=None)
Sensor(key='6100_00543100', name='metering_current_consumption', unit='W', factor=None, path=None, enabled=False, l10n_translate=False, value=None)
Sensor(key='6400_00543A00', name='metering_total_consumption', unit='kWh', factor=1000, path=None, enabled=False, l10n_translate=False, value=None)
I has been working fine for a very long time but today it started to give Timeout. Before when this happened I just waited a few hours and then it started to work again or restart of Inverter also solved it.
But now nothing works it just give timeout.
I can access the Inverter through webpage.
Any ideas?
Since yesterday afternoon, my SMA integration doesn't work properly anymore. The sensors aren't giving any output.
Logbook:
`Logger: homeassistant.components.sma
Source: helpers/update_coordinator.py:212
Integration: SMA Solar (documentation, issues)
First occurred: 10:44:42 (2 occurrences)
Last logged: 10:50:45
Error fetching sma data:`
When I reload the integration, the power output sensor gets a value for a second. After that the value returns to 0 and stays that way.
Some sensor keys have no unit attached. This can be seen with status messages or features being turned on/off.
Here is an example of a sensor key I would like to integrate:
custom:
sma_status:
key: "6180_08214800"
Here is the error logged:
Invalid config for [sensor.sma]: required key not provided @ data['custom']['sma_si_battery_activity']['unit']. Got None
required key not provided @ data['custom']['sma_si_battery_cycles']['unit']. Got None. (See ?, line ?). Please check the docs at https://home-assistant.io/components/sensor.sma/
Can this be changed without too much effort?
Hello,
im a trying to use your home assistant component but i am unable to connect to my SMA Tripower Interface.
My Error:
Error doing job: Task exception was never retrieved
09:02 components/sensor/sma.py (ERROR)
Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.5/site-packages/pysma/init.py", line 45, in _fetch_json
url, data=json.dumps(payload), headers=headers, params=params)
File "/srv/homeassistant/lib/python3.5/site-packages/aiohttp/helpers.py", line 99, in iter
ret = yield from self._coro
File "/srv/homeassistant/lib/python3.5/site-packages/aiohttp/client.py", line 267, in _request
conn = yield from self._connector.connect(req)
File "/srv/homeassistant/lib/python3.5/site-packages/aiohttp/connector.py", line 402, in connect
proto = yield from self._create_connection(req)
File "/srv/homeassistant/lib/python3.5/site-packages/aiohttp/connector.py", line 748, in _create_connection
_, proto = yield from self._create_direct_connection(req)
File "/srv/homeassistant/lib/python3.5/site-packages/aiohttp/connector.py", line 831, in _create_direct_connection
req=req, client_error=client_error)
File "/srv/homeassistant/lib/python3.5/site-packages/aiohttp/connector.py", line 796, in _wrap_create_connection
return (yield from self._loop.create_connection(*args, **kwargs))
File "/usr/lib/python3.5/asyncio/base_events.py", line 762, in create_connection
yield from self.sock_connect(sock, address)
File "/usr/lib/python3.5/asyncio/selector_events.py", line 451, in sock_connect
return (yield from fut)
File "/usr/lib/python3.5/asyncio/futures.py", line 380, in iter
yield self # This tells Task to wait for completion.
File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
future.result()
File "/usr/lib/python3.5/asyncio/futures.py", line 285, in result
raise CancelledError
concurrent.futures._base.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.5/asyncio/tasks.py", line 241, in _step
result = coro.throw(exc)
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/sma.py", line 125, in async_sma
values = yield from sma.read(keys_to_query)
File "/srv/homeassistant/lib/python3.5/site-packages/pysma/init.py", line 79, in read
yield from self.new_session()
File "/srv/homeassistant/lib/python3.5/site-packages/pysma/init.py", line 52, in new_session
URL_LOGIN.format(self._ip), self._new_session_data)
File "/srv/homeassistant/lib/python3.5/site-packages/pysma/init.py", line 46, in _fetch_json
return (yield from res.json())
File "/srv/homeassistant/lib/python3.5/site-packages/async_timeout/init.py", line 35, in exit
self._do_exit(exc_type)
File "/srv/homeassistant/lib/python3.5/site-packages/async_timeout/init.py", line 80, in _do_exit
raise asyncio.TimeoutError
concurrent.futures._base.TimeoutError
How can i troubleshoot this issue ?
Best regards and thanks for your help.
I have HA running with connection tomy sma sunny boy 3.6 -40.
Nevertheless I do only get the first 4 Sensors from the list integrated:
SENSORS = [
Sensor('current_consumption', '6100_00543100', 'W'),
Sensor('current_power', '6100_40263F00', 'W'),
Sensor('total_consumption', '6400_00543A00', 'kWh', 1000),
Sensor('total_yield', '6400_00260100', 'kWh', 1000),
Sensor('grid_voltage', '6100_00464800', 'V'),
Sensor('pv_power', '6100_0046C200', 'W'),
Sensor('daily_yield', '6400_00262200', 'Wh'),
Sensor('power_supplied', '6100_00464800', 'W'),
Sensor('power_absorbed', '6100_00464800', 'W'),
Sensor('status', '6180_08214800', '', None, '."1"[].val[0].tag'),
]
adding the other sensors results in a faulty configuration.yaml. What helps is to integrate custom sensors . These sensor defintions work for me:
sensors:
current_consumption:
current_power:
total_consumption:
total_yield:
sma_grid_voltage:
sma_daily_yield:
custom:
sma_grid_voltage:
key: "6100_00464800"
unit: V
sma_daily_yield:
key: "6400_00262200"
unit: Wh
6100_00464800
is used for multiple sensors?When fetching data, pysma passes on whatever it grabs from WebConnect.
My inverter is set to Dutch, which means the decimal separator is a comma instead of a dot. In Home Assistant, the comma is not shown and the values displayed are 100 times too high.
Somewhere in the process, the comma should be converted to a dot. I don't know whether this should be done in pysma or in Home Assistant. As early as possible (=pysma) seems logical.
Hi,
Im trying to run your script but I get a timeout error.
root@OPENHABTEST:/home/user# python3 example.py 192.168.1.33 installer Password123
DEBUG:asyncio:Using selector: EpollSelector
ERROR:pysma:Could not start session, Could not connect to SMA at http://192.168.1.33 (timeout), got {'err': 'Could not connect to SMA at http://192.168.1.33 (timeout)'}
INFO:main:No session ID
Device type Sunny Boy 4.0 AV-41
Software package 1.1.32.R
Software version 1.4.63.R
There seems to be a redirect to https by default when you try to visit the webpage.
Anything I can try?
Any plans for adding support for entities in the new Energy thing in homeassistant?
Thanks!
Don't know if i need to logge issue there or in the issue tracker of home assistant, i made both to be sure :-)
I have multiple inverter and ma configuration was working with the previous version 8.5, since the new release 0.86.1 version I have a exception saying that 2 sensors with the same name are present.
With the previous version the sensors was generated like this for instence : total_yield, total_yield_2 seems that it's not the case anymore.
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 344, in _async_add_entity
raise HomeAssistantError(msg)
homeassistant.exceptions.HomeAssistantError: Entity id already exists: sensor.daily_yield. Platform sma does not generate unique IDs
Is there an option for not passing the password? I would like only to have access to public data
I've found that the key used to retrieve the pv_power
value should be 6380_40251E00
instead of 6100_0046C200
. The 6100_0046C200
key indicates the power generated by the converter, whereas the 6380_40251E00
key indicates the power generated by the solar panels.
Since converters are never 100% efficient, there's a slight difference between the two values.
Hi,
The module seems to work fine except that I do not receive the daily_yield.
Here is what I receive :
WARNING:pysma:No values for sensors: daily_yield [6400_00262200],current_consumption [6100_00543100],total_consumption [6400_00543A00]. Response from inverter: {'6380_40452100': {'1': [{'val': 1005}, {'val': 947}]}, '6100_00465700': {'1': [{'val': 4998}]}, '6100_00464900': {'1': [{'val': 23552}]}, '6100_40463600': {'1': [{'val': None}]}, '6100_40263F00': {'1': [{'val': 796}]}, '6400_0046C300': {'1': [{'val': 18080}]}, '6400_00462500': {'1': [{'val': None}]}, '6400_00462400': {'1': [{'val': None}]}, '6180_08214800': {'1': [{'val': [{'tag': 307}]}]}, '6400_00260100': {'1': [{'val': 18080}]}, '6380_40451F00': {'1': [{'val': 41274}, {'val': 42243}]}, '6100_00464800': {'1': [{'val': 23543}]}, '6100_40465500': {'1': [{'val': 1148}]}, '6100_40465300': {'1': [{'val': 1146}]}, '6100_00464A00': {'1': [{'val': 23552}]}, '6100_0046C200': {'1': [{'val': 797}]}, '6100_40465400': {'1': [{'val': 1136}]}, '6100_40463700': {'1': [{'val': None}]}}
grid_power 796 W
frequency 49.98 Hz
voltage_l1 235.43 V
voltage_l2 235.52 V
voltage_l3 235.52 V
current_l1 1.146 A
current_l2 1.136 A
current_l3 1.148 A
pv_power 797 W
pv_voltage 412.74 V
pv_current 1.005 A
pv_gen_meter 18.08 kWh
total_yield 18.08 kWh
daily_yield
grid_power_supplied
grid_power_absorbed
grid_total_yield
grid_total_absorbed
current_consumption
total_consumption
status 307
Any idea ?
Thanks a lot in advance !
Some keys in Webconnect use more than 13 characters. This is the case, for instance, for inverters with 2 separate arrays/MPTT. Here is what I found on my Sunnyboy 5.0:
custom:
sma_status:
key: "6180_08214800"
sma_power_a:
key: "6380_40251E00_0"
unit: W
sma_power_b:
key: "6380_40251E00_1"
unit: W
sma_voltage_a:
key: "6380_40451F00_0"
unit: V
sma_voltage_b:
key: "6380_40451F00_1"
unit: V
sma_current_a:
key: "6380_40452100_0"
unit: A
sma_current_b:
key: "6380_40452100_1"
unit: A
It can be interesting to be able to monitor several arrays separately rather than the entire output of an inverter. This would for example allow users to better determine the effect of shading, orientation and inclination on PV output.
Can the pysma code be corrected easily to account for these sensor keys with 15 characters?
KEY_CURRENT_POWER_W = '6100_40263F00'
KEY_CURRENT_CONSUMPTION_W = '6100_00543100'
KEY_TOTAL_YIELD_KWH = '6400_00260100'
KEY_TOTAL_CONSUMPTION_KWH = '6400_00543A00'
I want to add more data keys to pysma; for example 'KEY_DAILY_YIELD_KWH' (getting the dailly yield of the SMA converter).
In what documentation from SMA I can find the corresponding values (like 6100_40263F00)?
Follow-up to this issue: #22.
I am also experiencing
[pysma] 401 error detected, closing session to force another login attempt
This error does not recover itself. Home Assistant (0.97.2) has to be restarted in order to get data again.
Hello @kellerza ,
thanks for your work on this! I'm using the HA integration to fetch data from a Sunny Boy 5.0 . I tried the same for a Sunny Boy Storage 3.7 but it seems the data is not read in correctly, I think it might have something to do with the devices class ("1" for solar inverter and "7" for battery inverter). In the feedback from the logs below, for the battery-specific parameters, 3 values are shown because the inverter has possibility to connect up to 3 batteries (only 1 connected in this case). I assume 180 = 18°C, 15921 = 159.21 V and 1569 = 1.569 A, which fits with AC power of 233 W (DC-AC conversion efficiency of 93%)
response from inverter: '6100_00295A00': {'7': [{'val': 87}]}
response from inverter: '6100_40495B00': {'7': [{'val': 180}, {'val': None}, {'val': None}]}
response from inverter: '6100_00495C00': {'7': [{'val': 15921}, {'val': None}, {'val': None}]}
response from inverter: '6100_40495D00': {'7': [{'val': 1569}, {'val': None}, {'val': None}]}
response from inverter: '6100_40263F00': {'7': [{'val': 233}]}}
Would it be possible to adapt the code to be compatible with battery inverters as well?
Thx
Kr,
fitool
I stumbled over a strange bug when trying to execute and test the example script for pysma.
If there is a file pysma.py in the same directory I get the following error:
Traceback (most recent call last):
File "get-sma-vaules.py", line 84, in <module>
main()
File "get-sma-vaules.py", line 80, in main
loop, user=args.user, password=args.password, ip=args.ip))
File "/usr/lib/python3.5/asyncio/base_events.py", line 466, in run_until_complete
return future.result()
File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
raise self._exception
File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
result = coro.send(None)
File "get-sma-vaules.py", line 33, in main_loop
VAR['sma'] = pysma.SMA(session, ip, password=password, group=user)
AttributeError: module 'pysma' has no attribute ‚SMA‘
I can reproduce that behavior by simply create an empty file with touch pysma.py
Hi,
i sucessfully used the SMA Integration for some weeks now and greatly appreciate all your efforts on this.
Today my sensors went away and i got the following error in my logs:
`Logger: pysma
Source: /usr/local/lib/python3.8/site-packages/pysma/init.py:232
First occurred: 05:50:42 (4 occurrences)
Last logged: 05:50:56
Could not start session, Max amount of sessions reached, got {}
`
I can login into the local webUI with no problems and see, that the inverter is up and running.
Has anyone any thoughts on this?
Thank you very much.
EDIT: Nevermind, some time gone by and it's all working again. Perhaps just a hickup :-)
Hi @kellerza I have a SMA Sunny Boy 4000TL-21 solar Inverter that I'm keen to connect to my Home Assistant server. I'm running hass.io v0.103.6.
I've added the following to my configuration.yaml file:
sensor: !include sensors.yaml
And the following to the sensors.yaml file:
`
I've run the yaml parsing checker in Home Assistant which throws no flags. I've restarted HA but no sma sensors appear to have been created.
May I presume this issue is the consequence of this particular Inverter being a pre-2017 model that doesn't provide a web interface? I can access the Inverter via the SunnyPortal web interface.
Hi,
This looks very awesome - I have been using webscaper up until now, but this will be much cleaner. Unfortunately, I get errors connection errors (See below). The IP address it tries to connect to is correct, I also verified the user password on the Sunny Explorer software.
2019-10-04 00:25:29 ERROR (MainThread) [pysma] Could not start session, Could not connect to SMA at http://192.168.0.3 (timeout), got {'err': 'Could not connect to SMA at http://192.168.0.3 (timeout)'}
I have enabled all external communication on the module with their default values - Please see snippet of the settings - https://imgur.com/a/7he7joj
Your assistance will be much appreciated!
System info
Sunnyboy SB-5000TL-21 with Webconnect Module
I have a SUNNY TRIPOWER 4.0 and I get in the latest dev from HA this error:
2019-09-08 11:33:11 WARNING (MainThread) [pysma] Sensor 6100_00543100: Not found in {'6180_08214800': {'1': [{'val': [{'tag': 307}]}]}, '6100_00464900': {'1': [{'val': 23383}]}, '6100_00464A00': {'1': [{'val': 23476}]}, '6400_0046C300': {'1': [{'val': 62718}]}, '6100_40463600': {'1': [{'val': None}]}, '6100_0046C200': {'1': [{'val': 1601}]}, '6100_00464800': {'1': [{'val': 23410}]}, '6100_40463700': {'1': [{'val': None}]}, '6400_00462500': {'1': [{'val': 0}]}, '6400_00462400': {'1': [{'val': 0}]}, '6100_00465700': {'1': [{'val': 4997}]}, '6400_00260100': {'1': [{'val': 58058}]}, '6100_40263F00': {'1': [{'val': 1602}]}}
2019-09-08 11:33:11 WARNING (MainThread) [pysma] Sensor 6400_00262200: Not found in {'6180_08214800': {'1': [{'val': [{'tag': 307}]}]}, '6100_00464900': {'1': [{'val': 23383}]}, '6100_00464A00': {'1': [{'val': 23476}]}, '6400_0046C300': {'1': [{'val': 62718}]}, '6100_40463600': {'1': [{'val': None}]}, '6100_0046C200': {'1': [{'val': 1601}]}, '6100_00464800': {'1': [{'val': 23410}]}, '6100_40463700': {'1': [{'val': None}]}, '6400_00462500': {'1': [{'val': 0}]}, '6400_00462400': {'1': [{'val': 0}]}, '6100_00465700': {'1': [{'val': 4997}]}, '6400_00260100': {'1': [{'val': 58058}]}, '6100_40263F00': {'1': [{'val': 1602}]}}
2019-09-08 11:33:11 WARNING (MainThread) [pysma] Sensor 6400_00543A00: Not found in {'6180_08214800': {'1': [{'val': [{'tag': 307}]}]}, '6100_00464900': {'1': [{'val': 23383}]}, '6100_00464A00': {'1': [{'val': 23476}]}, '6400_0046C300': {'1': [{'val': 62718}]}, '6100_40463600': {'1': [{'val': None}]}, '6100_0046C200': {'1': [{'val': 1601}]}, '6100_00464800': {'1': [{'val': 23410}]}, '6100_40463700': {'1': [{'val': None}]}, '6400_00462500': {'1': [{'val': 0}]}, '6400_00462400': {'1': [{'val': 0}]}, '6100_00465700': {'1': [{'val': 4997}]}, '6400_00260100': {'1': [{'val': 58058}]}, '6100_40263F00': {'1': [{'val': 1602}]}}
2019-09-08 11:33:17 WARNING (MainThread) [pysma] Sensor 6100_00543100: Not found in {'6180_08214800': {'1': [{'val': [{'tag': 307}]}]}, '6100_00464900': {'1': [{'val': 23333}]}, '6100_00464A00': {'1': [{'val': 23484}]}, '6400_0046C300': {'1': [{'val': 62721}]}, '6100_40463600': {'1': [{'val': None}]}, '6100_0046C200': {'1': [{'val': 1594}]}, '6100_00464800': {'1': [{'val': 23385}]}, '6100_40463700': {'1': [{'val': None}]}, '6400_00462500': {'1': [{'val': 0}]}, '6400_00462400': {'1': [{'val': 0}]}, '6100_00465700': {'1': [{'val': 4997}]}, '6400_00260100': {'1': [{'val': 58061}]}, '6100_40263F00': {'1': [{'val': 1594}]}}
2019-09-08 11:33:17 WARNING (MainThread) [pysma] Sensor 6400_00262200: Not found in {'6180_08214800': {'1': [{'val': [{'tag': 307}]}]}, '6100_00464900': {'1': [{'val': 23333}]}, '6100_00464A00': {'1': [{'val': 23484}]}, '6400_0046C300': {'1': [{'val': 62721}]}, '6100_40463600': {'1': [{'val': None}]}, '6100_0046C200': {'1': [{'val': 1594}]}, '6100_00464800': {'1': [{'val': 23385}]}, '6100_40463700': {'1': [{'val': None}]}, '6400_00462500': {'1': [{'val': 0}]}, '6400_00462400': {'1': [{'val': 0}]}, '6100_00465700': {'1': [{'val': 4997}]}, '6400_00260100': {'1': [{'val': 58061}]}, '6100_40263F00': {'1': [{'val': 1594}]}}
2019-09-08 11:33:17 WARNING (MainThread) [pysma] Sensor 6400_00543A00: Not found in {'6180_08214800': {'1': [{'val': [{'tag': 307}]}]}, '6100_00464900': {'1': [{'val': 23333}]}, '6100_00464A00': {'1': [{'val': 23484}]}, '6400_0046C300': {'1': [{'val': 62721}]}, '6100_40463600': {'1': [{'val': None}]}, '6100_0046C200': {'1': [{'val': 1594}]}, '6100_00464800': {'1': [{'val': 23385}]}, '6100_40463700': {'1': [{'val': None}]}, '6400_00462500': {'1': [{'val': 0}]}, '6400_00462400': {'1': [{'val': 0}]}, '6100_00465700': {'1': [{'val': 4997}]}, '6400_00260100': {'1': [{'val': 58061}]}, '6100_40263F00': {'1': [{'val': 1594}]}}
It is generating a lot of log entries.
How can I assist on adding the values?
Add support for SMA inverters with 3 PV string inputs. Initially reported at home-assistant/core#52850 - sorry about that, didn't realize pysma
was it's own repository. Pull request coming shortly.
Any luck on resolving the multiple inverters not working issue? Sorry to clutter the thread here. I have no idea where else to ask the question and I just managed to get the component to work only to realize I can only read one inverter...
The SMA sensor in Home Assistant works fine for some time (<24h) but then stops updating. Restarting Home Assistant usually fixes the issue .
This is what I get in the logs then:
2019-06-24 06:29:16 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/opt/homeassistant/lib/python3.7/site-packages/homeassistant/components/sma/sensor.py", line 128, in async_sma
values = await sma.read(used_sensors)
File "/opt/homeassistant/lib/python3.7/site-packages/pysma/__init__.py", line 254, in read
if sen.extract_value(body):
File "/opt/homeassistant/lib/python3.7/site-packages/pysma/__init__.py", line 51, in extract_value
res = next(iter(jmespath.search(JMESPATH_BASE, json_body)))
TypeError: 'NoneType' object is not iterable
Plus
2019-06-24 06:30:11 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/opt/homeassistant/lib/python3.7/site-packages/aiohttp/connector.py", line 924, in _wrap_create_connection
await self._loop.create_connection(*args, **kwargs))
File "/usr/local/lib/python3.7/asyncio/base_events.py", line 959, in create_connection
raise exceptions[0]
File "/usr/local/lib/python3.7/asyncio/base_events.py", line 946, in create_connection
await self.sock_connect(sock, address)
File "/usr/local/lib/python3.7/asyncio/selector_events.py", line 464, in sock_connect
return await fut
File "/usr/local/lib/python3.7/asyncio/selector_events.py", line 494, in _sock_connect_cb
raise OSError(err, f'Connect call failed {address}')
OSError: [Errno 113] Connect call failed ('<SMA-IP>', 443)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/homeassistant/lib/python3.7/site-packages/homeassistant/components/sma/sensor.py", line 128, in async_sma
values = await sma.read(used_sensors)
File "/opt/homeassistant/lib/python3.7/site-packages/pysma/__init__.py", line 243, in read
body = yield from self._fetch_json(URL_VALUES, payload=payload)
File "/opt/homeassistant/lib/python3.7/site-packages/pysma/__init__.py", line 201, in _fetch_json
self._url + url, **params)
File "/opt/homeassistant/lib/python3.7/site-packages/aiohttp/client.py", line 476, in _request
timeout=real_timeout
File "/opt/homeassistant/lib/python3.7/site-packages/aiohttp/connector.py", line 522, in connect
proto = await self._create_connection(req, traces, timeout)
File "/opt/homeassistant/lib/python3.7/site-packages/aiohttp/connector.py", line 854, in _create_connection
req, traces, timeout)
File "/opt/homeassistant/lib/python3.7/site-packages/aiohttp/connector.py", line 992, in _create_direct_connection
raise last_exc
File "/opt/homeassistant/lib/python3.7/site-packages/aiohttp/connector.py", line 974, in _create_direct_connection
req=req, client_error=client_error)
File "/opt/homeassistant/lib/python3.7/site-packages/aiohttp/connector.py", line 931, in _wrap_create_connection
raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host <SMA-IP>:443 ssl:None [Connect call failed ('<SMA-IP>', 443)]
I use Tigo optimizers logged by my Sunny Tripower via a Tigo Access Point (TAP). The following custom sensors are logging Power and Temperature of each optimizer (only first two shown as example):
- platform: sma
custom:
power_tigo_1:
key: '6100_40652A00'
unit: W
factor: 1
path: '"1"[0].val'
power_tigo_2:
key: '6100_40652A00'
unit: W
factor: 1
path: '"1"[1].val'
temperature_tigo_1:
key: '6100_40652B00'
unit: °C
factor: 10
path: '"1"[0].val'
temperature_tigo_2:
key: '6100_40652B00'
unit: °C
factor: 10
path: '"1"[1].val'
To add this in the main integration may be complicated since requires additional inputs regarding the number of panels monitored, if any.
Please consider keeping the yaml custom sensor alongside the GUI integration, unless this is a hard requirement from the Homeassistant folks.
Will keep using a custom integration for now. Thanks for your work!
Cheers!
I'm currently using SBFspot to read out my SMA 2500TLST-21 inverter through speedwire connection. This is working fine, but due to some changes in my home automation stack I'd like to start using pysma.
I tried using the Home Assistant component and the library directly but both give me the error "Could not connect to SMA at http://192.168.0.128". I tried both the user and the installer password but to no avail.
Is my inverter supposed to be supported? If so, how can I troubleshoot this further.
[EDIT]
Accessing the IP of my inverter directly through browser on port 80 is not possible.
My inverter forces https. Is there any way to set a configuration option to change the protocol from http to https?
For now I have manually changed the URLs but it would be nice for this to be configurable.
My custom sensors regarding this in homeassistant no longer work since update as I suspect it is not supported to run this custom sensors anymore? Can these sensors be added? Or is there any possibility to still run custom sensors?
Iam using below sensors to monitor current incoming W on each Phase from grid.
Sensors are from SUNNY TRIPOWER 10.0 (STP10.0-3AV-40 010) with SMA energy meter installed in the house.
incoming_l1:
key: '6100_0046EB00'
unit: W
incoming_l2:
key: '6100_0046EC00'
unit: W
incoming_l3:
key: '6100_0046ED00'
unit: W
Thanks.
Hi
I was trying to get some support on HA forum, but so far, no luck.
I'm trying to connect SMA TriPower inverter, but no luck.
Thins like password, connection I checked dozen of times.
I'm using module integrated into latest HA 0.94.3.
As default, SMA module should NOT use SSL, but even disabled in configuration, it constantly have this error.
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host 192.168.1.250:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)')]
Any ideas??
Sunny Boy 2.5
Home Assistant 0.94.3
Could not start session, Session ID expected [result.sid], got {'result': {'sid': None}}
9:47 PM components/sma/sensor.py (ERROR) - message first occured at 9:47 PM and shows up 4 times
configuration:
- platform: sma
host: 192.xxx.xxx.xxx
password: !secret password
verify_ssl: false
group: user
sensors:
daily_yield:
status:
I think the current value of daily_yield
is the sum of yesterday and today.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.