HandyHat / ha-hildebrandglow-dcc

Home Assistant integration for UK SMETS (Smart) meters pulling data from the DCC via the Hildebrand Glow API
MIT License
229 stars 31 forks source link

list index out of range error #52

Closed si458 closed 2 years ago

si458 commented 2 years ago

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

townsmcp commented 2 years ago

@si458 when in the Bright app, does it show ‘Tarrif not found’ when on the Home tab?

si458 commented 2 years ago

@townsmcp it does indeed for my gas but it has a tariff for my elec, but as explained in my post i think british gas have goofed something up as my in house display doesnt display any gas at all and currently says i owe £18.65million in gas 😆 ill close this and attach onto other issue, clearly i didnt check the issues properly

si458 commented 2 years ago

sorry ill keep this open as this issue is with this repo not the other as my smart meters are DSS and the other repo doesnt work with my smart meters

townsmcp commented 2 years ago

@si458 £18.65 million? Hehehe NOW we know why utility prices have rocketed 🤣😂🤣😂 My app shows no tariff info for either gas or electric. My electric is with Octopus and gas is with Outfox The Market. I got in touch with the Bright app devs and they said the tariff info needs adding by the respective suppliers which updates the meter directly. I can do that with Octopus but not Outfox - I only recently changed electric to Octopus but before that the meter has been dumb (no feedback to supplier) so can’t resolve gas prices.

In theory, you should be able to install either repo as ColinRobins is a branch of main with updates which have been merged back into this main repo. I had to roll back ColinRobins repo on HA to the previous release while this issue is resolved

si458 commented 2 years ago

@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 👍

si458 commented 2 years ago

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 commented 2 years ago

I haven’t noticed the - values for gas yet. To be honest, I have added gas but not taken much interest in it just yet.

si458 commented 2 years ago

image

townsmcp commented 2 years ago

Ah ok. I only stayed on the new release for 20 minutes, saw that nothing was being recorded and rolled back.

Lol I’m slightly jealous after seeing your values for consumption:

E51D5AF2-8299-4B47-A1AE-C5B70FE4D9F9

si458 commented 2 years ago

@townsmcp not sure why mine is showing negative gas though? its really confusing? and it does say on the energy page it requires upto 2 hours to fully display energy on first run haha

townsmcp commented 2 years ago

Yeah very confusing. I wonder, and this is a complete stab in the dark, if it has anything at all to do with the BST hard coding fix in the latest release?

ColinRobbins commented 2 years ago

There are a few separate issues here.

1) 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.

2) 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.

3) 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.

townsmcp commented 2 years ago

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

si458 commented 2 years ago

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 😢 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

ill also tag onto this, ive been trying for 2 years to get british gas to fix gas tariff on my home display and even there own website and ive had no luck, you shouldnt just EXPECT the customer to get it fixed, the integration should accodate the fact this might not be possible so simply just send 0 as the value maybe?

ColinRobbins commented 2 years ago

@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.

si458 commented 2 years ago

@ColinRobbins thank you! that has worked! it only displays the error once now! HOWEVER the sensors for my gas tariff/gas tariff standing values are still showing as UNKNOWN instead of UNAVILABLE ?

townsmcp commented 2 years ago

@ColinRobbins done. Replaced the file content with your new code. Rebooted HA. In the logs I have this: image It hasnt come up with the error again and seems to be working :)

townsmcp commented 2 years ago

@si458 give it a bit of time - I had the same after a reboot of HA. It has now populated the sensors

si458 commented 2 years ago

@townsmcp ok I will do see if it sorts itself out image

townsmcp commented 2 years ago

DOH! I see what you mean. I have the following: image image

ColinRobbins commented 2 years ago

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.

si458 commented 2 years ago

@ColinRobbins mines still showing 'Unknown' thats even after 2 x 30min windows (i restarted after the first 30mins) any suggestions?

ColinRobbins commented 2 years ago

@si458 on reflection "unknown" is correct if the data is not available via the API.

Your "metric" shows "unavailable" as the the metric data sensor is no longer provided, as HA now support kWh.

si458 commented 2 years ago

@si458 on reflection "unknown" is correct if the data is not available via the API.

Your "metric" shows "unavailable" as the the metric data sensor is no longer provided, as HA now support kWh.

I don't have any metric values? Only the 5 entries each for gas/elec Consumption today, consumption year, cost today, tariff rate, tariff standing

And it's the tariff rate and tariff standing that's showing unknown, I would of expected it to be unavailable as it's returning None now as the is no data in the api or am I getting mixed up? (Sorry newbie to the energy stuff)

ColinRobbins commented 2 years ago

If there is no data, and the API returning “None”, then HA will show “unknown”. “Unavailable” means HA has not initialised the sensor (normally during startup).

si458 commented 2 years ago

If there is no data, and the API returning “None”, then HA will show “unknown”. “Unavailable” means HA has not initialised the sensor (normally during startup).

ahhh right ok thank you 👍 in that case it all seems to be working now, its also changed the gas to a positive now haha

lolouk44 commented 2 years ago
  1. 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.

Thanks Colin. I have tried that and my supplier (EDF) told me it won't happen, the meter will only send readings, not tariff 😢 I'm therefore awaiting the next release with the fix from https://github.com/HandyHat/ha-hildebrandglow-dcc/pull/54