timmo001 / ovoenergy

Get energy data from OVO's API.
https://timmo.dev
Apache License 2.0
30 stars 16 forks source link

Updated to remove failure when data is not returned from api #11

Closed RogerSelwyn closed 3 years ago

RogerSelwyn commented 3 years ago

Description

The retrieving data from the OVO api, the code was assuming that all data would be present, which is not always the case. This change validates for each set of data that it is present before processing it.

I believe lack of data should be handled by the calling code, so this returns None if it is not present.

I have fixed this for electricity, but since I don't have gas at my property I don't have sample data to apply the same logic. Their maybe more pythonic ways of writing the code, so happy to have it corrected.

Related issues this fixes

https://github.com/timmo001/ovoenergy/issues/10

Checklist

timmo001 commented 3 years ago

Helps fix https://github.com/home-assistant/core/issues/50256