klaasnicolaas / python-autarco

☀️ Asynchronous Python client for the inverters of Autarco
https://www.autarco.com
MIT License
5 stars 1 forks source link

Python-autarco with PyCharm #413

Open Quidditchspiele opened 4 weeks ago

Quidditchspiele commented 4 weeks ago

I try to take the latest Python-autarco version in operation mode with the PyCharm IDE. I use Python 3.12.3. Unfortunately I get always the following error messages.

Any idea..?

Traceback (most recent call last):
  File "C:\Users\PC\Projekte\python-autarco\examples\all_output.py", line 50, in <module>
    asyncio.run(main())
  File "C:\Program Files\Python\Python 3.12\Lib\asyncio\runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python\Python 3.12\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python\Python 3.12\Lib\asyncio\base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\PC\Projekte\python-autarco\examples\all_output.py", line 14, in main
    public_key = await autarco.get_public_key()
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\PC\Projekte\python-autarco\src\autarco\autarco.py", line 134, in get_public_key
    public_key: str = data[0]["public_key"]
klaasnicolaas commented 4 weeks ago

Looks like it can't find the public_key from the response.

./Klaas

Quidditchspiele commented 4 weeks ago

Yes, that could be, but I don´t understand why? Because the email and the password is correct. The login with a browser works fine.

klaasnicolaas commented 4 weeks ago

The public_key is retrieved from the following URL (https://my.autarco.com/api/site/), you could use Postman to see what the response is with your own login. Unfortunately I don't own an Autarco to check this myself.

./Klaas

Quidditchspiele commented 3 weeks ago

Postman response: { "current_page": 1, "data": [ { "mock": 0, "name_end_user": "My Autarco solar installation", "name_retailer": "xxxxxxxxxx", "public_key": "xxxxxxxxx", "dt_created": "2023-11-17 07:42:16", "dt_updated": "2023-11-17 07:42:16", "address_line_1": "xxxxxxxxxx", "address_line_2": null, "address_line_3": null, "city": "xxxxxxxx", "postcode": "xxxxxxxxxx", "country_code": "DE", "country_name": null, "site_id": xxxxxx, "address_id": xxxxxxx, "nominal_power": xxxx, "health": "OK", "name": "My Autarco solar installation" } ], "first_page_url": "https://my.autarco.com/api/site?page=1", "from": 1, "next_page_url": null, "path": "https://my.autarco.com/api/site", "per_page": 30, "prev_page_url": null, "to": 1 }

The response of Postman is OK. I can see the expected "public_key". I don´t believe that the handling with the public_key is the reason. I think I have done something wrong in my development environment. I will create a new setup from scratch.

Klaas, thanks for the support...

Quidditchspiele commented 1 week ago

Hi Klaas,

today I have done some investigations with the Autarco package. For me two modifications are required. Now it works fine with my development environment.

  1. Error message:

    File "C:\Users\PC\Projekte\PhotoVoltaik_NV\python-autarco\src\autarco\autarco.py", line 134, in get_public_key

    public_key: str = data[0]["public_key"]

                  ~~~~^^^

    The solution:

    data = json.loads(response)
    
    # public_key: str = data[0]["public_key"]
    
    data = data.get("data")
    
    data = data[0]
    
    public_key = data.get("public_key")
  2. Error message:

    mashumaro.exceptions.InvalidFieldValue: Field "stats" of type dict[str, dict[str, int]] in PowerResponse has invalid value {'graphs': {'pv_power'……………..

    The solution:

@dataclass class PowerResponse(DataClassORJSONMixin): inverters: dict[str, Inverter] stats: dict[str, dict[str, Any]] # Any instead of int..

Just as a info for you…

Have a nice day and thank you for your work.

Friedhelm

Von: Klaas Schoute @.> Gesendet: Montag, 10. Juni 2024 21:50 An: klaasnicolaas/python-autarco @.> Cc: Quidditchspiele @.>; Author @.> Betreff: Re: [klaasnicolaas/python-autarco] Python-autarco with PyCharm (Issue #413)

Closed #413 https://github.com/klaasnicolaas/python-autarco/issues/413 as completed.

— Reply to this email directly, view it on GitHub https://github.com/klaasnicolaas/python-autarco/issues/413#event-13106689656 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AV2332TKR2GWNJPRQDOB4DTZGX7OLAVCNFSM6AAAAABI2ERIASVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJTGEYDMNRYHE3DKNQ . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AV2332S2RVSTAGLLNY4ZOUDZGX7OLA5CNFSM6AAAAABI2ERIASWGG33NNVSW45C7OR4XAZNWJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XKUY3PNVWWK3TUL5UWJTYAAAAAGDJYGZ4A.gif Message ID: @. @.> >

klaasnicolaas commented 1 week ago

Do not respond to emails from Github, but post them directly on GitHub. Otherwise it is not readable 😅

./Klaas