home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
70.83k stars 29.54k forks source link

OVO Energy not storing gas usage correctly for long term statics #81668

Closed ewenny closed 1 year ago

ewenny commented 1 year ago

The problem

Using OVO Energy, Electric usage can be found under consumption, but gas can not, gives link to https://developers.home-assistant.io/docs/core/entity/sensor/#long-term-statistics image

Can see that it does successfully download Gas usage: image

EDIT: image The Gas value is shown under Electricity.

What version of Home Assistant Core has the issue?

core-2022.11.1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

OVO Energy

Link to integration documentation on our website

https://www.home-assistant.io/integrations/ovo_energy/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 year ago

Hey there @timmo001, mind taking a look at this issue as it has been labeled with an integration (ovo_energy) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `ovo_energy` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Change the title of the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign ovo_energy` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


ovo_energy documentation ovo_energy source (message by IssueLinks)

Thorburn commented 1 year ago

I think this is a Home Assistant Core issue - I'm getting the same problem trying to use "Add Gas Source" with it showing "No matching statistics found" with the Hildebrand Glow (DCC) Integration.

I can see the Gas entities if I try to add an electrical source, but get none if I try to add gas. Related to https://github.com/home-assistant/core/issues/81496 ?

lwsrbrts commented 1 year ago

This issue has been raised before but was closed after some time automatically as there's not really an easy way to resolve it.

As @timmo001 has mentioned, the "problem" is that the Home Assistant Gas Consumption entity expects the value's unit of measurement to be reported by the sensor as cubic metres (m3).

image

The Ovo Energy integration only pulls the data from the Ovo API and that is only recorded there in kWh.

So, there's three solutions.

  1. Home Assistant Core devs permit the use of kWh to record Gas usage in the Energy dashboard/ Gas consumption entity - to me, this feels like the best solution to this particular problem.
  2. You may create your own sensor that converts kWh back in to cubic metres - I've included an example below but before jumping to that, read why you may not want to use it...
  3. If @timmo001 (or another dev with the skills) was willing, it could be included in the integration by doing the conversion and offering an alternative sensor that offers the values in cubic metres also. The challenge is that converting cubic metres to kWh (the opposite of what we want to do) involves a variable (a number between 38 and 41) which is the calorific value of the gas at a given point in time.

So, as you see, the issue is that for @timmo001 (or another dev) to do this in the integration, they either assume an average value for the calorific value of the gas at all times of year (making the conversion slightly inaccurate) or they go to the trouble of retrieving the calorific values from the http://marketinformation.natgrid.co.uk/ SOAP service, for gas delivered during a particular time period and then factor that in to the calculation. As you can see, that might be... difficult so presumably it would be easier if the Home Assistant Core devs allowed the use of kWh for gas consumption.

To overcome this for now, I have used this manual template sensor (taken from another user on a closed topic) but note the number 40 here - this sensor just assumes a calorific value of 40 for the gas delivered, when it may have been 38.5 or 40.2 etc.

template:
   sensor:
      - name: Gas Consumption (Approx)
        unit_of_measurement: 'm³'
        state: "{{ states('sensor.ovo_last_gas_reading') | float * 3.6 / 40 / 1.02264 }}"
        icon: 'mdi:fire'
        state_class: total_increasing
        device_class: gas
ewenny commented 1 year ago

Thanks for the detailed reply.

I agree, think 1 is the best option.

But I like 3, I've not looked at programming anything for home assistant, not even looked at the programming language so forgive "just" suggestions. Looking and your sample sensor code, is there anything stopping me/you multiplying two sensors together? If not, couldn't just have a second api to the market info api which stores the cubic rate, then your "40" variable is now dynamic? OK will put a dependency in for the Ovo, but the inaccuracies are reduced.

And I do have a slight concern will option 1, only from a ui perspective, users will have to pay a little more attention when selecting gas vs. electric values if both are in kwh. Second comment here, my previous gas supplier also charged by the kwh for gas - never used their api, if they had one though - so not sure how common kwh vs. Cubic volume is.

issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

ewenny commented 1 year ago

Both electric and gas usage are being displayed now. Will close this off