BottlecapDave / HomeAssistant-OctopusEnergy

Unofficial Home Assistant integration for interacting with Octopus Energy
https://bottlecapdave.github.io/HomeAssistant-OctopusEnergy/
MIT License
535 stars 51 forks source link

Gas Consumption not appearing in dropdown list for Energy Dashboard #5

Closed mdeakin99 closed 2 years ago

mdeakin99 commented 2 years ago

In Configuration > Energy, when you 'Add Gas Source', the gas consumption entities do not appear. They do however appear in Electricity Grid section.

I suspect this needs to be Gas class? https://www.home-assistant.io/integrations/sensor#device-class. Worth noting that it expects m3 as unit.

I have confirmed that the Gas entity is receiving data/values.

BottlecapDave commented 2 years ago

hmm interesting. Most of this is quite simple, however Octopus Energy returns data in either kwh or m3 depending on the type of smart sensor you have. Unfortunately I can't find anywhere to get this information automatically, so will need to think of a solution to accomodate this.

cooperaj commented 2 years ago

I've been using the https://github.com/HandyHat/ha-hildebrandglow-dcc addon as it allows access to the half hourly stats of UK SMETS2 smart meters. If you buy their hardware product you can get access to 10 second stats too. There is an issue/pr there to convert to m3 from kWh. It doesn't look too hard to implement though it relies on a value that can change and is different in various locations of the UK.

BottlecapDave commented 2 years ago

I've got most of it done on a separate branch. The struggle I hit was Octopus Energy provide data in either m3 or kwh depending on the version of your gas meter. Unfortunately they don't tell you which meter you have, so I've had to add a global setting for you to specify which gas meter you have. The limitation to this is it won't work properly if you have multiple gas meters with different versions, but I hope this is an extreme edge case.

I've also updated the gas sensors with the desired settings, but they still don't seem to be appearing so I'll take a look at that PR.

BottlecapDave commented 2 years ago

These sensors have been updated to be included in the Energy Dashboard. However, it looks like some manual intervention is required as the background statistics doesn't like the unit of measurement changing for a sensor. Therefore, to get the gas sensor to appear, you'll need to update the statistics database. The easiest way to do this is install the SqLite Web add-on and run the following command:

UPDATE statistics_meta
SET unit_of_measurement = 'm³'
WHERE statistic_id IN
(
'sensor.octopus_energy_gas_XXX_previous_accumulative_consumption',
'sensor.octopus_energy_gas_XXX_latest_consumption'
)

where XXX is your gas serial number.