nordicopen / pyeasee

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

Add poll energy and opmode to charger #87

Closed jorgror closed 10 months ago

jorgror commented 10 months ago

poll_lifetimeenergy and poll_chargeropmode is available in the API but was not implemented in the client.

olalid commented 10 months ago

Actually, you can already poll for this data by using the charger->get_observations() method.

state_lifetimeEnergy and state_chargerOpMode are defined in const.py.

So something like

get_observations({ ChargerStreamData.state_lifetimeEnergy.value, ChargerStreamData.state_chargerOpMode.value }) 

would be equivalent to get both of those values in one API call.

jorgror commented 10 months ago

Thanks for the quick reply.

There is a difference though. poll will make easee fetch a updated state from the charger. This call does not return a value, only a 202 that the request is sent to the charger. Thats why there is a 3 minute rate limit.

The new updated lifetime energy will be available with the code you suggested soon after the poll request. You can test this by first get_observations and check the timestamp. Then do a poll, wait a few moments and do another get_observations.

olalid commented 10 months ago

I see, then I misunderstood what the purpose is. I think using "poll" in this context is confusing. I see that Easee is doing that too, but I would like to some more descriptive name for our functions. Like force_update_lifetimeenergy().

jorgror commented 10 months ago

Thanks for your comment. I have improved the code accordingly.

olalid commented 10 months ago

Merging (to be tested before release).

olalid commented 10 months ago

Note that I changed the name of one of the functions to force_update_opmode since I thought it was a bit redundant to have charger in the name. Released a new version now.