dotKrad / hass-fpl

FPL Component for Home Assistant
MIT License
40 stars 20 forks source link

DEBT does not exist #46

Closed apetrycki closed 4 months ago

apetrycki commented 8 months ago

An exception occurs in __getDataFromBalance in FplMainRegionApiClient.py: list index out of range.

This appears to be due to DEBT not being in the data returned.

The data returned:

[{'amount': 355.77, 'details': 'BPAC', 'id': '/account/<redacted>/balance', 'individualDebitDetails': [{'codeDescription': 'BPAC', 'type': 'BB', 'totalAmount': '0000355.77', 'remainingAmount': '0000355.77', 'dueDate': '2023-12-05'}], 'errorFlag': False, 'order': 3}, {'amount': 355.77, 'details': 'TPSD', 'id': '/account/<redacted>/balance', 'errorFlag': False, 'order': 1}, {'amount': 5.34, 'details': 'NDDT', 'id': '/account/<redacted>/balance', 'individualDebitDetails': [{'codeDescription': 'NDDT', 'type': 'LPC', 'totalAmount': '0000000.00', 'remainingAmount': '0000005.34'}], 'errorFlag': False, 'order': 2}, {'amount': 361.11, 'details': 'TBAL', 'id': '/account/<redacted>/balance', 'errorFlag': False, 'order': 0}]

This appears to be something not everyone has, so it's probably better to test for it or make it a warning instead of an error.