Integration Platform question

Several days ago I created a utility meter before realizing that I need to use the integration platform to convert from Watts to kWh.

I just created an integration name fridge_energy and restarted Home Assistant server. Based on the documentation I should have a sensor.fridge_energy but when I go to Developer Tools I don’t see sensor.fridge_energy

Did I do something wrong or is it not supposed to show up there?

Can you please show your config for the integration sensor?

You should be able to set a value_template to convert W to kWh on the source: sensor that is feeding data to your utility_meter

I’m having trouble understanding why I would need to do that when the Integration platform specifically states it is useful for converting Watts to kWh.

" An integration sensor is quite useful in energy billing scenarios since energy is generally billed in kWh and many sensors provide power in W (Watts).

If you have a sensor that provides you with power readings in Watts (uses W as unit_of_measurement ), then you can use the integration sensor to track how much energy is being spent. Take the next configuration as an example:

sensor:
  - platform: integration
    source: sensor.current_power
    name: energy_spent
    unit_prefix: k
    round: 2

This configuration will provide you with sensor.energy_spent who will have your energy in kWh. "

Yes

sensor:
  - platform: integration
    source: sensor.fridge_electrical_measurement
    name: fridge_energy
    unit_prefix: k
    round: 2
    method: left

I’m interested in seeing this template that does integration.

I had the integration sensor in a yaml file in the packages folder. I deleted it from that yaml and put into the sensors.yaml file and now it shows up in Developer Tools. I’ll have to see if the yaml file in the packages file has something that caused the problem.

Could you share with us, how a value template could be used right at source to convert a sensor providing power in Watt using the integration into a sensor providing kWh?

That’s not possible. You need to create an integration sensor, that converts W to kWh and then use this in the utility meter.

Yes, I did create an integration sensor

- platform: integration
  source: sensor.e3dc_power_consumption
  name: E3DC energy consumption

The problem I have is that the source sensor is providing a read out in W. This way my integration will provide Wh. I could define a unit_prefix of the integration to be k (kWh), but I still need to devide the overall value by 1000 and was wondering if this can be done straight in the integration sensor. This would spare another template sensor that is only there to convert my power sensor from W to kW.

No, you don’t need an additional sensor. The unit prefix takes care of this and does this for you.

1 Like

Okay, I thought it will only prefix a ‘k’ without converting the value. Documentation was not clear in that respect. Thanks for your help.

Actually, after having added unit_prefix: k and monitored the energy consumption for a day, I believe it does not convert the value from Wh to kWh, but only prefixes the k, still outputting the same value :frowning: So maybe I need to use an additional template sensor inbetween to convert the power consumption to kW, prior to integrating it into energy.

That would be a bug then, the code clearly does this calculation:

You are right, looking at the curve it did flatten. So it is converting correctly. It is the history that messed up the sensor. As the same sensor was used without the convertion the initial value (which was in Wh), was very large. From yesterday on it only added smaller values, as they have been calculated in kWh. I have reset the sensor to 0 and will monitor again, but I think the issue was only with myself :smiley:
Really appricate the support. Thanks for your reply.

A manual reset of the value did not seem to help, the integration carried on…
Unbenannt
Also deleting the sensor, restarting homeassistant, readding it does not seem to correctly to reset it.
is there any means to reset the sensor?

1 Like

What if you were to make a new integration sensor with the name as E3DC energy then restart HA so that the integration sensor now looks like this -

- platform: integration
  source: sensor.e3dc_power_consumption
  name: E3DC_energy
  unit_prefix: k

By doing that you should now have a sensor.E3DC_energy that will correctly have kWh that starts at 0 from the time HA is restarted. It shouldn’t matter that you have another sensor that uses the same source since it has a different name and therefore is a different sensor.

1 Like