ha-hildebrandglow-dcc: list index out of range error
Describe the bug
2021-10-26 14:31:07 ERROR (MainThread) [custom_components.hildebrandglow_dcc.sensor] Key Error - plan (list index out of range): ({'status': 'OK', 'name': 'gas consumption', 're
sourceTypeId': '08ab415f-d851-423f-adf4-c2b1e0529e27', 'resourceId': 'b1f5af6e-3507-453c-ab8f-66ff9606b7de', 'data': [], 'classifier': 'gas.consumption'})
2021-10-26 14:31:08 ERROR (MainThread) [custom_components.hildebrandglow_dcc.sensor] Lookup Error - plan (list index out of range): ({'status': 'OK', 'name': 'gas consumption',
'resourceTypeId': '08ab415f-d851-423f-adf4-c2b1e0529e27', 'resourceId': 'b1f5af6e-3507-453c-ab8f-66ff9606b7de', 'data': [], 'classifier': 'gas.consumption'})
To Reproduce only added in my bright iOS details (im a british gas customer with a smart elec/gas/monitor all DCC with no glow hub)
Expected behaviour not sure?
Screenshots If applicable, add screenshots to help explain your problem.
Version LATEST - v0.5.0 and HA core-2021.10.6
Debug log Enable debug logging by following the instructions here TO FOLLOW
Additional context i think this error is because british gas have goofed up my gas tariff, so its showing in HA AND the bright iOS app as NO TRARIFF and its not calculating the cost either
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 27 (5 by maintainers)
That is what I’d expect.
UPDATED
“Unavailable” while it is in a boot up phase. It can be several minutes before it tries to collect data. (Or the sensor / code has been removed)
“Unknown” it has tried to get the data, but there is nothing there.
@townsmcp I’ve had a go at changing the error handling, so it only reports “no data” once. HOWEVER, as I have data, I am unable to test it!
Would you be able to replace your "custom_components/hildebrandglow_dcc/sensor.py with sensor.py and try it?
The expected behaviour is you will see the error reported only once.
@si458 rather than report a 0, it should report the sensor is unavailable.
Thanks @ColinRobbins. For me personally, point 1 is not achievable for gas tariff due to the supplier not using smart meters/able to connect to smart meters 😢- I think I was lucky when Octopus took over my electric supply that they managed to get my SMETS1 meters working and reporting back as smart. So a fix for that would be great. Notes for point 3. When a fix is in place for no tariff data I will switch back. thanks for all the great work you, @HandyHat and everyone has done with this integration
There are a few separate issues here.
You have no “data” for the gas Tariff, so the code logs an error. You should contact your energy provider and request they fix it. In the mean time, we can look at some better error handling.
You are seeing “negative” gas - this happened to me too when I switched which sensor I was using. No idea why (something to do with how the current use is calculated), but it only occurred that once during initialisation, so I’ve ignored it, left it running and it sorted itself out.
My fork and @HandyHat are now in sync - I recommend using the @HandyHat version. I’ll put a message to this effect on my fork shortly.
https://github.com/HandyHat/ha-hildebrandglow-dcc/blob/429a9b4221ceedea7beaf4846eb6a226504153d9/custom_components/hildebrandglow_dcc/sensor.py#L341
https://github.com/HandyHat/ha-hildebrandglow-dcc/blob/429a9b4221ceedea7beaf4846eb6a226504153d9/custom_components/hildebrandglow_dcc/sensor.py#L168
the above are the two lines i think are causing the issue because its checking if data[0] exists which it doesnt in our case as data is just data[] rather than data[0] so it should check if data field is blank if so then return everything as 0
EDIT: maybe still log a warning saying data ia blank contact ur supplier but return 0 so it can calculate everything correctly, are you also getting the strange gas negative figures for some reason? E.G: -0.14kWh ?
@townsmcp its 🚀 because ive been using all the gas didnt u realise? 😆 i was going to write my own module for HA as i discovered the app and the API, but then discovered these ones already partely made and working, just a few bugs that need fixing 👍