nordicopen / pyeasee

Easee EV charger API python library
MIT License
39 stars 11 forks source link

Bugfix: Handle missing userRole for chargers #86

Closed jorgror closed 10 months ago

jorgror commented 10 months ago

Easee.get_chargers API call does not return userRole (at least on my user). This code will set userRole to -1 if missing in API-call.

olalid commented 10 months ago

Hmm. That's interesting... What API are you using to create the charger object? (I.e. there are a few different ways you can find a charger, possibly you are using a different method than what we use in the HA component, which would be why it was not noted before).

jorgror commented 10 months ago

Easee.get_chargers()

olalid commented 10 months ago

Does using the circuit.get_chargers() as in the example in the readme work any differently for you?

jorgror commented 10 months ago

This works:

    easee = Easee(easee_username, easee_password)
    sites = await easee.get_sites()
    circuits = sites[0].get_circuits()
    chargers = circuits[0].get_chargers()

This does not work without my fix:

    easee = Easee(easee_username, easee_password)
    chargers = await easee.get_chargers()
olalid commented 10 months ago

Ok, thanks for clearing that up.

olalid commented 10 months ago

Merging (to be tested before release).