Giter VIP home page Giter VIP logo

sunnyportal-py's Introduction

sunnyportal-py

Python module to access PV systems in Sunny Portal.

sunnyportal2pvoutput

The script sunnyportal2pvoutput can be used to send data to PVOutput. It uses a config file to store the credentials for Sunny Portal and the API Key and System Id for PVOutput.

How to run

  1. Clone or download the repository.
  2. Enter the directory and run: PYTHONPATH=. ./bin/sunnyportal2pvoutput --dry-run sunnyportal.config
  3. Enter the requested information and verify that the script is able to connect to Sunny Portal.
  4. The information is saved in sunnyportal.config and can be edited/deleted if you misstype anything.
  5. Once it works, replace --dry-run with e.g. --output to upload the last seven days output data to pvoutput or --status to upload data for the current day.
  6. Add --quiet to silence the output.
$ PYTHONPATH=. ./bin/sunnyportal2pvoutput sunnyportal.config --help
usage: sunnyportal2pvoutput [-h] [-s] [-o] [-c] [-p DAYS_PAST] [-q] [-n] config

Connect Sunny Portal to PVoutput.org

positional arguments:
  config                Configuration file to use

optional arguments:
  -h, --help            show this help message and exit
  -s, --status          Report status(es)
  -o, --output          Report output(s)
  -c, --consumption     Report consumption
  -p DAYS_PAST, --days-past DAYS_PAST
                        number of DAYS in the past to go back -- default: 0 (today only)
  -q, --quiet           Silence output
  -n, --dry-run         Don't send any data

sunnyportal2file

The script sunnyportal2file can be used to save data from Sunny Portal to file/database. It uses the same config file as in sunnyportal2pvoutput to store the credentials for Sunny Portal. It will extract the fields (min, mean and max production) which are available in unit watt as numpy.uint32 along with corresponding timestamps and aggregate them into a pandas DataFrame from which it will save to file with the format specified. One file will be created for each plant your Sunny Portal account has access to.

How to run

  1. Clone or download the repository.
  2. Enter the directory and run: PYTHONPATH=. ./bin/sunnyportal2file sunnyportal.config --format csv (change --format if you prefer a different format)
  3. Enter the requested information and verify that a file was created with the format you specified with the expected content
  4. Once it works, you can specify a different start date with --start-date, and end date with --end-date (both defaults to yesterday)
  5. If a data file already exists, it will only download new data and append to previously created data file (can override --start-date)
  6. Use --include-filter if you only want to download data for a specific plant
  7. Add --quiet to silence the output.
$ PYTHONPATH=. ./bin/sunnyportal2file -h
usage: sunnyportal2file [-h] -f {json,csv,pickle,feather,parquet,excel,sqlite} [-s START_DATE] [-e END_DATE] [-i INCLUDE_FILTER] [-q] config

Save information from Sunny Portal to file

positional arguments:
  config                Configuration file to use

optional arguments:
  -h, --help            show this help message and exit
  -f {json,csv,pickle,feather,parquet,excel,sqlite}, --format {json,csv,pickle,feather,parquet,excel,sqlite}
                        Format for which the data is to be saved
  -s START_DATE, --start-date START_DATE
                        The start date of data to be saved in the format YYYY-MM-DD (default yesterday)
  -e END_DATE, --end-date END_DATE
                        The end date of data to be saved in the format YYYY-MM-DD (default yesterday)
  -i INCLUDE_FILTER, --include-filter INCLUDE_FILTER
                        A string used to filter which plants to include (default includes all plants)
  -q, --quiet           Silence output

sunnyportal-py's People

Contributors

danieltwagner avatar dvandonkelaar avatar erijo avatar joebe975 avatar michaelpeeters avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

sunnyportal-py's Issues

Does this work for EnnesOX?

I've been playing around with this repo (great work btw), and I have an SMA account connected to the ordinary SMA portal, as well as their new EnnesOX platform. The script only manages to find the sunny portal sites.

According to the SMA API website (below), EnnesOX is supported by the API?
https://developer.sma.de/sma-apis.html

Would be great to know if this repo can access EnnesOX account!

Generate signature param

There is a parameter called "signature", how is it generated?

sig = hmac.new(self.token.key.encode(), digestmod=hashlib.sha1)
sig.update(self.method.lower().encode())
sig.update(self.service.lower().encode())

ts = self.get_timestamp(self.token.server_offset)
sig.update(ts.encode())
params["timestamp"] = ts

sig.update(self.token.identifier.lower().encode())

params["signature-method"] = "auth"
params["signature-version"] = self.version
params["token"] = self.token
params["signature"] = base64.standard_b64encode(sig.digest()) <-Here!

I don't program in python, I would like you to help me understand, there is a key when authenticating with email and password, but this part is confusing to me, it has sha1 and base64, can you clarify?

sunnyportal errors

new program installed via git.
PYTHONPATH=. ./bin/sunnyportal2pvoutput /home/jerry/programs/sunnyportal-py/sunnyportal.config -p 2 -o
errors:
2021-10-02 12:35:43,951 DEBUG: POST to /service/r2/addoutput.jsp: {'data': '20211001,15826,,,2728,10:15'}
2021-10-02 12:35:44,021 DEBUG: HTTP response: 400 (Bad Request): Bad request 400: Peak time [2728] invalid on 20211001
2021-10-02 12:35:44,021 DEBUG: POST to /service/r2/addoutput.jsp: {'data': '20211001,15826,,,2728,10:15'}
2021-10-02 12:35:44,091 DEBUG: HTTP response: 400 (Bad Request): Bad request 400: Peak time [2728] invalid on 20211001
2021-10-02 12:35:44,091 ERROR: Failed to add output batch: Bad request 400: Peak time [2728] invalid on 20211001
Traceback (most recent call last):
File "/home/jerry/programs/sunnyportal-py/./bin/sunnyportal2pvoutput", line 284, in
main()
File "/home/jerry/programs/sunnyportal-py/./bin/sunnyportal2pvoutput", line 278, in main
pvoutput.add_batch_output(data)
File "/home/jerry/programs/sunnyportal-py/./bin/sunnyportal2pvoutput", line 122, in add_batch_output
raise Exception("could not add output batch")
Exception: could not add output batch

I am having issues with the inverter, its not wanting to display some days generation from the web, the installer says its all fine, yea right.
thanks

Getting temperature and Irradiance

Hello and first at all let me thank you for your work, It has been very useful for me and my teamwork.

Additionally, for the power of plants, there are other two variables the Irradiance and the Temperature. We were looking at how to getting these with no luck.

Maybe do you have any ideas on how to construct the request for this information or maybe where we can search for it?

Thank you again.

Can plant.day_overview also show consumption?

Question as in title.
Can day_overview also capture data about consumption, battery charging, discharging, etc...?

Basically : all the info you see in the "energy balance" for each day (see graph below)
The generation info is already there, but the other information is missing.

Github_Graph

And yes, I used "day_overview" with True for "include all".

As a side question : where did you find the documentation about the service you are using? Like a manual or something...

"Sunny Portal e-mail" error with cron

Great work and thanks for making this available to use.

I got it working, but when executing using cron, I get an error that says only "Sunny Portal e-mail:" when logging cron output >> /var/log/cron.log
Prior to this, I had been getting the "no MTA" error so I installed postfix in local only mode. Just guessing these are tied together and the error I'm having now means it can't send the message out to the recorded "Sunny Portal e-mail" from the config file. Maybe?

I'm wondering if/how it could be made to not require the email, assuming that would take care of it.

<enhancement> add optional "days-past" argument to sunnyportal2pvoutput

Hi, my Inverter is on an unreliable internet connection, so the updates to sunnyportal are not always available in the night.
By adding an optional "days-past" argument I can update pvoutput with data of a previous date once sunnyportal is updated.

eg:
PYTHONPATH=. ./bin/sunnyportal2pvoutput --status --days-past 1 sunnyportal.config will fetch the productiondata from today and yesterday.

Retrieving inverter level production data

Hi,

I am wondering if there is a way to extract the production data on the inverter level using the sunnyportal2file script. For example, I would like to pull production from each inverter rather than the sum total for the site.

Thanks,
Tori

Fetching external energy supply info

Hi!
I was wondering if the web services at com.sunny-portal.de have some way to return the "external energy supply" info. I could try to write a patch if they do.
Thanks!

pvoutput deprecated addbatchoutput

I found recently that pvoutput has deprecated the addbatchoutput API, batching is now part of addoutput, but batching is only available for donations mode, see jwillemsen/saj_collector#34. It looks this project needs to be updated because it uses addbatchoutput.jsp as far as I can tell.

Problem when I call plant.profile()

Hi,
I just want to have the power_peak of all my plants and so I tried this:

for plant in client.get_plants(): plant.profile().peak_power client.logout()

and the result in the terminal is :
Traceback (most recent call last): File "c:\Users\Desktop\Stage\python\test3.py", line 57, in <module> main() File "c:\Users\Desktop\Stage\python\test3.py", line 46, in main plant.profile().peak_power File "C:\Users\AppData\Local\Programs\Python\Python38-32\lib\site-packages\sunnyportal\client.py", line 77, in profile return self.client.do_request(req) File "C:\Users\AppData\Local\Programs\Python\Python38-32\lib\site-packages\sunnyportal\client.py", line 45, in do_request return request.perform(conn) File "C:\Users\AppData\Local\Programs\Python\Python38-32\lib\site-packages\sunnyportal\requests.py", line 82, in perform return self.handle_response(data) File "C:\Users\AppData\Local\Programs\Python\Python38-32\lib\site-packages\sunnyportal\requests.py", line 131, in handle_response return responses.PlantProfileResponse(data) File "C:\Users\AppData\Local\Programs\Python\Python38-32\lib\site-packages\sunnyportal\responses.py", line 53, in __init__ self.parse(data) File "C:\Users\AppData\Local\Programs\Python\Python38-32\lib\site-packages\sunnyportal\responses.py", line 155, in parse for channel in tag.find('production-data').findall('channel'): AttributeError: 'NoneType' object has no attribute 'findall'

I just don't understand why this error appears when I happen to have plant.name correctly and even plant.day_overview ().difference correctly too.

Thanks, Tom.

SSL: CERTIFICATE_VERIFY_FAILED

Hello Erik,

I was searching for a way to get the data of my PV plant downloaded from the SMA Sunny Portal. I found your repository here on Github and started to try. I followed the readme and set up the path. This seems to work properly:

(actual) c:\sunnyportal-py>python bin\sunnyportal2file -h
usage: sunnyportal2file [-h] -f {json,csv,pickle,feather,parquet,excel,sqlite} [-s START_DATE] [-e END_DATE] [-i INCLUDE_FILTER] [-q] config

Save information from Sunny Portal to file

positional arguments:
  config                Configuration file to use

optional arguments:
  -h, --help            show this help message and exit
  -f {json,csv,pickle,feather,parquet,excel,sqlite}, --format {json,csv,pickle,feather,parquet,excel,sqlite}
                        Format for which the data is to be saved
  -s START_DATE, --start-date START_DATE
                        The start date of data to be saved in the format YYYY-MM-DD (default yesterday)
  -e END_DATE, --end-date END_DATE
                        The end date of data to be saved in the format YYYY-MM-DD (default yesterday)
  -i INCLUDE_FILTER, --include-filter INCLUDE_FILTER
                        A string used to filter which plants to include (default includes all plants)
  -q, --quiet           Silence output

But when executing sunnyportal2file I end up in the following error message:

(actual) c:\sunnyportal-py>python bin\sunnyportal2file sunnyportal.config --format csv
2021-12-19 21:27:52,625 DEBUG: GET /services/authentication/100/xxx%40yyy.com?password=<password>
Traceback (most recent call last):
  File "c:\sunnyportal-py\bin\sunnyportal2file", line 428, in <module>
    main()
  File "c:\sunnyportal-py\bin\sunnyportal2file", line 404, in main   
    for plant in client.get_plants():
  File "c:\sunnyportal-py\sunnyportal\client.py", line 64, in get_plants
    req = requests.PlantListRequest(self.get_token())
  File "c:\sunnyportal-py\sunnyportal\client.py", line 53, in get_token
    self.token = self.do_request(req)
  File "c:\sunnyportal-py\sunnyportal\client.py", line 48, in do_request
    return request.perform(conn)
  File "c:\sunnyportal-py\sunnyportal\requests.py", line 73, in perform
    connection.request(self.method, self.url)
  File "C:\Users\Sascha\.conda\envs\actual\lib\http\client.py", line 1255, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "C:\Users\Sascha\.conda\envs\actual\lib\http\client.py", line 1301, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "C:\Users\Sascha\.conda\envs\actual\lib\http\client.py", line 1250, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "C:\Users\Sascha\.conda\envs\actual\lib\http\client.py", line 1010, in _send_output
    self.send(msg)
  File "C:\Users\Sascha\.conda\envs\actual\lib\http\client.py", line 950, in send
    self.connect()
  File "C:\Users\Sascha\.conda\envs\actual\lib\http\client.py", line 1424, in connect
    self.sock = self._context.wrap_socket(self.sock,
  File "C:\Users\Sascha\.conda\envs\actual\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "C:\Users\Sascha\.conda\envs\actual\lib\ssl.py", line 1040, in _create
    self.do_handshake()
  File "C:\Users\Sascha\.conda\envs\actual\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1123)

Do you have any idea?

Thank you in advance.

Feature Request: Export all data to local file

Well, thanks a lot for your tiny tool to export the logged data to a local file. Due to my lack of python dev know how I'd like to ask if you could just add a complete export of all retrieved data. In my use case I like to know how much energy per hour (kwh) from grid was used - just to calculate my dynamic power contract (tibber hourly). Thanks so much!

API methods

Dear @erijo ,

Thanks for the amazing job you did. I am trying to adapt your code to be able to create a binding of openhab. The idea would be to create a python program that can be executed using openhab rules and items. Later on, I would like to create an opensource binding for sunnyportal.
However I am unable to find a documentation of the REST API used in your application. I would like to select different fields, I am specially interested in current production and current consumption. The first one can be obtained from the app, the second one only from the website (since it uses info from another device, the energy meter).
How was you knowing the methods of the com.sunnyportal.de API? Can you share with me?
Many thanks!

Hourly / 15 minute data

Nice code @erijo. I was wondering if you know (or if one exists) the service end point to download the hourly or inter-hourly power data? Thanks

Sunnyportal2file Not Working

Hello. I am a student trying to raise more funds for solar panels in my school. To do that I will be creating a new website and app for my campus statistics on energy generated. I managed to get Sunnyportal2pvoutput to work. However it would be best if I could get Sunnyportal2file to output to a csv for me. I run the config and I get the error listed below:

X:\Desktop\Python\Github\sunnyportal-py>python bin/sunnyportal2file -f json config 2020-06-27 17:20:45,886 DEBUG: GET /services/authentication/100/bhaga78708%40gapps.uwcsea.edu.sg?password=<password> 2020-06-27 17:20:46,979 DEBUG: Response: <?xml version="1.0" encoding="utf-8"?><sma.sunnyportal.services><service name="authentication" method="get" version="100" request-oid="4d8e9852-31d5-4afd-b242-8dd32c0cfce5" creation-date="6/27/2020 9:20:49 AM"><authentication identifier="44558b63-8cc4-452b-bda5-93983ec3fbdb" key="5e3e4345-18bf-467c-b933-f313eff91041">OK</authentication></service></sma.sunnyportal.services> 2020-06-27 17:20:46,998 DEBUG: GET /services/plantlist/100/44558b63-8cc4-452b-bda5-93983ec3fbdb?timestamp=2020-06-27T09%3A20%3A49&signature-method=auth&signature-version=100&signature=jmJfxlHv4jARbQ1tL%2FdNru3HH9A%3D 2020-06-27 17:20:48,144 DEBUG: Response: <?xml version="1.0" encoding="utf-8"?><sma.sunnyportal.services><service name="plantlist" view="list" method="get" version="100" request-oid="5d8650d8-0cd5-4ce8-b9fe-396e8a928232" creation-date="6/27/2020 9:20:50 AM"><plantlist name="PV System List" count="2"><plant oid="a794c56f-8fd9-4057-95ae-69493202bca5" identifier="6b7fa900-fa14-11d4-d2d0-00014b7952d6" name="SG-UWCSEA-PoolShelter" state="unknown" /><plant oid="5e9b755f-50ba-4b65-b036-7255b5db94c4" identifier="bf2ec080-605d-11e5-191f-0001331c94e1" name="SG-UWCSEA-JrSportsHall/ArtBlk" state="unknown" /></plantlist></service></sma.sunnyportal.services> 2020-06-27 17:20:48,146 DEBUG: Extracting DataFrame from 2020-06-26 to 2020-06-26 for plant SG-UWCSEA-PoolShelter Traceback (most recent call last): File "bin/sunnyportal2file", line 454, in <module> main() File "bin/sunnyportal2file", line 441, in main df = get_data_for_period(plant, start_date, args.end_date) File "bin/sunnyportal2file", line 307, in get_data_for_period res = get_data_for_day(plant, start_date) File "bin/sunnyportal2file", line 284, in get_data_for_day day = plant.day_overview(date, include_all=True) TypeError: day_overview() got an unexpected keyword argument 'include_all'

I tried to do something myself by removing the include_all keyword, I am not that experienced in Python and when I did that here is the message I got:

X:\Desktop\Python\Github\sunnyportal-py>python bin/sunnyportal2file -f json config 2020-06-27 17:25:46,287 DEBUG: GET /services/authentication/100/bhaga78708%40gapps.uwcsea.edu.sg?password=<password> 2020-06-27 17:25:47,480 DEBUG: Response: <?xml version="1.0" encoding="utf-8"?><sma.sunnyportal.services><service name="authentication" method="get" version="100" request-oid="fcea2e74-19da-4f0a-bcde-7526d9584f54" creation-date="6/27/2020 9:25:50 AM"><authentication identifier="4ad3602d-2668-4298-a0cb-8c16acf6145b" key="1b3c8ae2-fa44-4449-8ba6-523d334788e1">OK</authentication></service></sma.sunnyportal.services> 2020-06-27 17:25:47,497 DEBUG: GET /services/plantlist/100/4ad3602d-2668-4298-a0cb-8c16acf6145b?timestamp=2020-06-27T09%3A25%3A50&signature-method=auth&signature-version=100&signature=cWz7hmMyIJnQkUq37vRo23kQ%2B5g%3D 2020-06-27 17:25:48,775 DEBUG: Response: <?xml version="1.0" encoding="utf-8"?><sma.sunnyportal.services><service name="plantlist" view="list" method="get" version="100" request-oid="53b5bb4c-0a84-4d17-a913-071a2b89b92e" creation-date="6/27/2020 9:25:51 AM"><plantlist name="PV System List" count="2"><plant oid="a794c56f-8fd9-4057-95ae-69493202bca5" identifier="6b7fa900-fa14-11d4-d2d0-00014b7952d6" name="SG-UWCSEA-PoolShelter" state="unknown" /><plant oid="5e9b755f-50ba-4b65-b036-7255b5db94c4" identifier="bf2ec080-605d-11e5-191f-0001331c94e1" name="SG-UWCSEA-JrSportsHall/ArtBlk" state="unknown" /></plantlist></service></sma.sunnyportal.services> 2020-06-27 17:25:48,777 DEBUG: Extracting DataFrame from 2020-06-26 to 2020-06-26 for plant SG-UWCSEA-PoolShelter 2020-06-27 17:25:48,789 DEBUG: GET /services/data/100/a794c56f-8fd9-4057-95ae-69493202bca5/overview-day-fifteen-total/2020-06-26?culture=en-gb&identifier=4ad3602d-2668-4298-a0cb-8c16acf6145b&timestamp=2020-06-27T09%3A25%3A51&signature-method=auth&signature-version=100&signature=Inl0nvymJVx6l5MET929JsYsnRA%3D 2020-06-27 17:25:50,045 DEBUG: Response: <?xml version="1.0" encoding="UTF-8"?><sma.sunnyportal.services> <service name="data" method="get" version="100" request-oid="290910bd-e9fa-43f2-86c0-76511b213a87" creation-date="6/27/2020 9:25:52 AM"> <data> <overview-day-fifteen-total> <channel name="Power" meta-name="Power" unit="kW"> <day timestamp="26/06/2020"> <fiveteen timestamp="00:15" /> <fiveteen timestamp="00:30" /> <fiveteen timestamp="00:45" /> <fiveteen timestamp="01:00" /> <fiveteen timestamp="01:15" /> <fiveteen timestamp="01:30" /> <fiveteen timestamp="01:45" /> <fiveteen timestamp="02:00" /> <fiveteen timestamp="02:15" /> <fiveteen timestamp="02:30" /> <fiveteen timestamp="02:45" /> <fiveteen timestamp="03:00" /> <fiveteen timestamp="03:15" /> <fiveteen timestamp="03:30" /> <fiveteen timestamp="03:45" /> <fiveteen timestamp="04:00" /> <fiveteen timestamp="04:15" /> <fiveteen timestamp="04:30" /> <fiveteen timestamp="04:45" /> <fiveteen timestamp="05:00" /> <fiveteen timestamp="05:15" /> <fiveteen timestamp="05:30" /> <fiveteen timestamp="05:45" /> <fiveteen timestamp="06:00" /> <fiveteen timestamp="06:15" /> <fiveteen timestamp="06:30" /> <fiveteen timestamp="06:45" /> <fiveteen timestamp="07:00" /> <fiveteen timestamp="07:15" min="0" max="0" mean="0" /> <fiveteen timestamp="07:30" min="0.026" max="0.142" mean="0.081" /> <fiveteen timestamp="07:45" min="0.227" max="0.344" mean="0.287" /> <fiveteen timestamp="08:00" min="0.432" max="0.554" mean="0.496" /> <fiveteen timestamp="08:15" min="0.623" max="0.801" mean="0.71" /> <fiveteen timestamp="08:30" min="0.923" max="1.176" mean="1.049" /> <fiveteen timestamp="08:45" min="1.257" max="1.451" mean="1.347" /> <fiveteen timestamp="09:00" min="1.563" max="1.716" mean="1.632" /> <fiveteen timestamp="09:15" min="1.83" max="1.919" mean="1.885" /> <fiveteen timestamp="09:30" min="1.93" max="2.387" mean="2.143" /> <fiveteen timestamp="09:45" min="2.434" max="2.665" mean="2.552" /> <fiveteen timestamp="10:00" min="2.798" max="2.906" mean="2.838" /> <fiveteen timestamp="10:15" min="2.602" max="2.94" mean="2.752" /> <fiveteen timestamp="10:30" min="3.013" max="3.244" mean="3.126" /> <fiveteen timestamp="10:45" min="3.226" max="4.708" mean="4.047" /> <fiveteen timestamp="11:00" min="5.76" max="6.159" mean="5.914" /> <fiveteen timestamp="11:15" min="4.395" max="6.5" mean="5.204" /> <fiveteen timestamp="11:30" min="3.112" max="4.858" mean="4.023" /> <fiveteen timestamp="11:45" min="4.414" max="7.934" mean="6.195" /> <fiveteen timestamp="12:00" min="4.131" max="5.519" mean="4.984" /> <fiveteen timestamp="12:15" min="4.317" max="8.655" mean="7.012" /> <fiveteen timestamp="12:30" min="6.809" max="10.067" mean="8.932" /> <fiveteen timestamp="12:45" min="9.883" max="10.192" mean="10.009" /> <fiveteen timestamp="13:00" min="6.91" max="8.739" mean="7.609" /> <fiveteen timestamp="13:15" min="2.815" max="4.975" mean="3.902" /> <fiveteen timestamp="13:30" min="6.842" max="10.46" mean="9.155" /> <fiveteen timestamp="13:45" min="8.179" max="10" mean="9.152" /> <fiveteen timestamp="14:00" min="10.201" max="11.105" mean="10.686" /> <fiveteen timestamp="14:15" min="4.252" max="11.28" mean="7.048" /> <fiveteen timestamp="14:30" min="6.7" max="9.738" mean="7.833" /> <fiveteen timestamp="14:45" min="2.756" max="5.693" mean="4.248" /> <fiveteen timestamp="15:00" min="1.349" max="4.258" mean="2.619" /> <fiveteen timestamp="15:15" min="1.485" max="3.828" mean="2.317" /> <fiveteen timestamp="15:30" min="2.022" max="4.162" mean="3.4" /> <fiveteen timestamp="15:45" min="2.077" max="5.088" mean="3.124" /> <fiveteen timestamp="16:00" min="3.72" max="6.227" mean="4.94" /> <fiveteen timestamp="16:15" min="1.665" max="2" mean="1.779" /> <fiveteen timestamp="16:30" min="1.857" max="3.343" mean="2.592" /> <fiveteen timestamp="16:45" min="1.88" max="2.451" mean="2.237" /> <fiveteen timestamp="17:00" min="2.518" max="3.511" mean="2.895" /> <fiveteen timestamp="17:15" min="1.393" max="2.893" mean="2.093" /> <fiveteen timestamp="17:30" min="1.178" max="1.353" mean="1.248" /> <fiveteen timestamp="17:45" min="0.961" max="1.079" mean="1.034" /> <fiveteen timestamp="18:00" min="0.845" max="0.861" mean="0.853" /> <fiveteen timestamp="18:15" min="0.616" max="0.821" mean="0.713" /> <fiveteen timestamp="18:30" min="0.311" max="0.494" mean="0.394" /> <fiveteen timestamp="18:45" min="0.274" max="0.304" mean="0.294" /> <fiveteen timestamp="19:00" min="0.025" max="0.181" mean="0.096" /> <fiveteen timestamp="19:15" min="0" max="0.005" mean="0.002" /> <fiveteen timestamp="19:30" min="0" max="0" mean="0" /> <fiveteen timestamp="19:45" /> <fiveteen timestamp="20:00" /> <fiveteen timestamp="20:15" /> <fiveteen timestamp="20:30" /> <fiveteen timestamp="20:45" /> <fiveteen timestamp="21:00" /> <fiveteen timestamp="21:15" /> <fiveteen timestamp="21:30" /> <fiveteen timestamp="21:45" /> <fiveteen timestamp="22:00" /> <fiveteen timestamp="22:15" /> <fiveteen timestamp="22:30" /> <fiveteen timestamp="22:45" /> <fiveteen timestamp="23:00" /> <fiveteen timestamp="23:15" /> <fiveteen timestamp="23:30" /> <fiveteen timestamp="23:45" /> <fiveteen timestamp="00:00" /> </day> </channel> <channel name="Total yield" meta-name="Energy" unit="kWh"> <day timestamp="26/06/2020" absolute="86961.907" difference="42.403" /> </channel> </overview-day-fifteen-total> </data> </service> </sma.sunnyportal.services> Traceback (most recent call last): File "bin/sunnyportal2file", line 454, in <module> main() File "bin/sunnyportal2file", line 441, in main df = get_data_for_period(plant, start_date, args.end_date) File "bin/sunnyportal2file", line 311, in get_data_for_period min_power.append(power_measurement.min) AttributeError: 'Power' object has no attribute 'min'

Would you please be able to assist me in fixing this issue? Thank you very much.

ModuleNotFound error with sunnyportal2file

Hi all
I'm trying to use sunnyportal2file but i get this error. I haven't touched at the packages nor the init.py

File "bin/sunnyportal2pvoutput", line 26, in
import sunnyportal.client, sunnyportal.responses
ModuleNotFoundError: No module named 'sunnyportal'

Thanks in advance

Logbook Entries, Inverter Comparison Status

I'm interested in getting the latest log entries for each power plant as well as the status of the latest inverter comparison.
I'd be happy to put together a PR, but I'm not sure how to get started with reverse engineering the requests.
My usual approach would be to inspect network requests from the website, but it looks like you're connecting directly to a lower layer API than the website uses.
From what I gather, I would need to install the Sunny Portal app on my phone and somehow intercept the traffic?
Can you provide some "getting started" instructions on reverse engineering the requests?

image

image

Something Change?

Just tried the script, seems some has changed, the script completes, but no data returned.

2021-10-29 06:54:19,439 DEBUG: GET /services/authentication/100/XXX.XXX%40xxxx.com?password=<password>
2021-10-29 06:54:20,084 DEBUG: Response: <?xml version="1.0" encoding="utf-8"?><sma.sunnyportal.services><service name="authentication" method="get" version="100" request-oid="2333103e-08ac-4f9a-a5fb-e11861df94d2" creation-date="10/29/2021 11:54:20 AM"><authentication identifier="15xxxaea-xxxx-4ffb-xxx-c0xxxxxxxx" key="xxxx-b447-xxxx-a855-xxxx">OK</authentication></service></sma.sunnyportal.services>
2021-10-29 06:54:20,088 DEBUG: GET /services/plantlist/100/15xxxaea-xxxx-4ffb-xxx-c0xxxxxxxx?timestamp=2021-10-29T11%3A54%3A20&signature-method=auth&signature-version=100&signature=xxxx%3D
2021-10-29 06:54:20,748 DEBUG: Response: <?xml version="1.0" encoding="utf-8"?><sma.sunnyportal.services><service name="plantlist" view="list" method="get" version="100" request-oid="a0b05068-f6a0-4f95-8032-db84df9a7ff6" creation-date="10/29/2021 11:54:20 AM"><plantlist name="PV System List" count="1"><plant oid="xxxxd36cf84bcddb" identifier="adad16ec-a18b-403d-903d-37ebe141228d" name="xxxx xxx" state="unknown" /></plantlist></service></sma.sunnyportal.services>
2021-10-29 06:54:20,750 DEBUG: DELETE /services/authentication/100/15xxxaea-xxxx-4ffb-xxx-c0xxxxxxxx?timestamp=2021-10-29T11%3A54%3A20&signature-method=auth&signature-version=100&signature=xxxx xxx
2021-10-29 06:54:21,395 DEBUG: Response: <?xml version="1.0" encoding="utf-8"?><sma.sunnyportal.services><service name="authentication" method="delete" version="100" request-oid="xxxx xxx" creation-date="10/29/2021 11:54:21 AM"><authentication identifier="15xxxaea-xxxx-4ffb-xxx-c0xxxxxxxx">OK</authentication></service></sma.sunnyportal.services>```
Running:
```PYTHONPATH=. ./bin/sunnyportal2file sunnyportal.config --format csv``` works fine, I am able to see:```<fiveteen timestamp="08:15" mean="0.104" />
            <fiveteen timestamp="08:30" mean="0.336" />
            <fiveteen timestamp="08:45" mean="0.424" />
            <fiveteen timestamp="09:00" mean="0.456" />
            <fiveteen timestamp="09:15" mean="0.42" />
            <fiveteen timestamp="09:30" mean="0.752" />
            <fiveteen timestamp="09:45" mean="1.604" />
            <fiveteen timestamp="10:00" mean="2.38" />
            <fiveteen timestamp="10:15" mean="2.324" />
            <fiveteen timestamp="10:30" mean="2.096" />
            <fiveteen timestamp="10:45" mean="2.808" />
            <fiveteen timestamp="11:00" mean="3.444" />
            <fiveteen timestamp="11:15" mean="3.644" />
            <fiveteen timestamp="11:30" mean="3.812" />
            <fiveteen timestamp="11:45" mean="3.96" />
            <fiveteen timestamp="12:00" mean="4.076" />
            <fiveteen timestamp="12:15" mean="4.152" />
            <fiveteen timestamp="12:30" mean="4.132" />
            <fiveteen timestamp="12:45" mean="3.448" />
            <fiveteen timestamp="13:00" mean="4.372" />
            <fiveteen timestamp="13:15" mean="4.36" />
            <fiveteen timestamp="13:30" mean="4.32" />
            <fiveteen timestamp="13:45" mean="4.224" />```
and the file gets created```-rw-r--r--  1 me me  6615 Oct 29 07:05 'me.csv'```
Any advice?
Thanks

Can't connect

Hi All,

I'm new to this and have an issue when trying to run the PYTHONPATH=. ./bin/sunnyportal2pvoutput --dry-run sunnyportal.config command.

The following error stack is returned.
2022-09-23 12:30:44,125 DEBUG: GET /services/authentication/100/?password=
Traceback (most recent call last):
File "/Users/peter/Dev/sunnyportal-py/./bin/sunnyportal2pvoutput", line 284, in
main()
File "/Users/peter/Dev/sunnyportal-py/./bin/sunnyportal2pvoutput", line 228, in main
plants = client.get_plants()
File "/Users/peter/Dev/sunnyportal-py/sunnyportal/client.py", line 62, in get_plants
req = requests.PlantListRequest(self.get_token())
File "/Users/peter/Dev/sunnyportal-py/sunnyportal/client.py", line 51, in get_token
self.token = self.do_request(req)
File "/Users/peter/Dev/sunnyportal-py/sunnyportal/client.py", line 46, in do_request
return request.perform(conn)
File "/Users/peter/Dev/sunnyportal-py/sunnyportal/requests.py", line 73, in perform
connection.request(self.method, self.url)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1282, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1328, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1277, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1037, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 975, in send
self.connect()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1454, in connect
self.sock = self._context.wrap_socket(self.sock,
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 512, in wrap_socket
return self.sslsocket_class._create(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 1070, in _create
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 1341, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)

Any pointers on why I'm getting the SSL certificate failed error?

Cannot losslessly cast from float64 to uint32

Hi,
when downloading the data of 2021 i get the following error.

./bin/sunnyportal2file:127: FutureWarning: Passing unit-less datetime64 dtype to .astype is deprecated and will raise in a future version. Pass 'datetime64[ns]' instead
  self._new_df = df.astype({k: self._dtype_dict[k] for k in df.columns})
Traceback (most recent call last):
  File "/mnt/c/Users/u16v02/source/sunnyportal-py/./bin/sunnyportal2file", line 427, in <module>
    main()
  File "/mnt/c/Users/u16v02/source/sunnyportal-py/./bin/sunnyportal2file", line 415, in main
    df_handler.download_new_data()
  File "/mnt/c/Users/u16v02/source/sunnyportal-py/./bin/sunnyportal2file", line 127, in download_new_data
    self._new_df = df.astype({k: self._dtype_dict[k] for k in df.columns})
  File "/home/cornelius/.local/lib/python3.10/site-packages/pandas/core/generic.py", line 6226, in astype
    res_col = col.astype(dtype=cdt, copy=copy, errors=errors)
  File "/home/cornelius/.local/lib/python3.10/site-packages/pandas/core/generic.py", line 6240, in astype
    new_data = self._mgr.astype(dtype=dtype, copy=copy, errors=errors)
  File "/home/cornelius/.local/lib/python3.10/site-packages/pandas/core/internals/managers.py", line 445, in astype
    return self.apply("astype", dtype=dtype, copy=copy, errors=errors)
  File "/home/cornelius/.local/lib/python3.10/site-packages/pandas/core/internals/managers.py", line 347, in apply
    applied = getattr(b, f)(**kwargs)
  File "/home/cornelius/.local/lib/python3.10/site-packages/pandas/core/internals/blocks.py", line 526, in astype
    new_values = astype_array_safe(values, dtype, copy=copy, errors=errors)
  File "/home/cornelius/.local/lib/python3.10/site-packages/pandas/core/dtypes/astype.py", line 299, in astype_array_safe
    new_values = astype_array(values, dtype, copy=copy)
  File "/home/cornelius/.local/lib/python3.10/site-packages/pandas/core/dtypes/astype.py", line 230, in astype_array
    values = astype_nansafe(values, dtype, copy=copy)
  File "/home/cornelius/.local/lib/python3.10/site-packages/pandas/core/dtypes/astype.py", line 140, in astype_nansafe
    return _astype_float_to_int_nansafe(arr, dtype, copy)
  File "/home/cornelius/.local/lib/python3.10/site-packages/pandas/core/dtypes/astype.py", line 188, in _astype_float_to_int_nansafe
    raise ValueError(f"Cannot losslessly cast from {values.dtype} to {dtype}")
ValueError: Cannot losslessly cast from float64 to uint32

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.