Energy Management in Home Assistant

Hi all, I already have the power, energy, current… by PZEM sensor connected by mqtt…
This is the config:

 - platform: mqtt
      name: "MQTTvoltage"
      state_topic: "home-assistant/sensor03/voltage"
      qos: 0
      unit_of_measurement: "V"
    - platform: mqtt
      name: "MQTTcurrent"
      state_topic: "home-assistant/sensor03/current"
      qos: 0
      unit_of_measurement: "A"
    - platform: mqtt
      name: "MQTTenergy"
      state_topic: "home-assistant/sensor03/energy"
      qos: 0
      unit_of_measurement: "KWh"
    - platform: mqtt
      name: "MQTTpower"
      state_topic: "home-assistant/sensor03/power"
      qos: 0
      unit_of_measurement: "W"

Is possible the integration with energy management?

Edit : Problem solved - I shortned the names by removing 4 characters - now works fine

Response noted thanx - doesnt explain why 2 of them are selectable, whilst other 2 are not. I also have 6 other resettting sensors that come from utility_meter: that do work - also note many people are using the outputs from utility_meter: succesfully in the energy dash board?

Will stick it out to see if any one else chip in - else going to have to create extra templates for the diffierent tarrifs - someting which utility_meter: does nicely.

Is anyone succesfully using daily resetting sensors from “utility_meter:” in the energy dashboard?

Here they all are - all of them reset either daily or monthly:

This should help - Hildebrandglow - Smart Meters - SMETS2 - #94 by WhimsySpoon

1 Like

Hi, I have gas unitm m3 but I don’t see any gas entity in energy.
I tried to customize entity
state_class measurement
but I don’t see item gas in device class dropdown menu.
Any idea?

Woohoo! Exactly what I am after… Got it setup - but got a query - will post over there.

Thanks again :slight_smile:

1 Like

don’t think the last_reset customization is not necessary any longer, this is taken care of internally now by HA

1 Like

Great news, thanks. I’ll update my post.

thats strange, I opened the database with DB browser and it see that the DB stores old data (aug 9 and 10) for the price sensor. That data contains the old and wrong unit_of_measurement. That could cause the problem. I dont understand why the database does not contain more recent data but the UI does.

Is there a way to delete old data?

afbeelding

I’ve seen some posts about modifying the *.db file and opening it with DB Browser for SQLite. Theoretically that should enable us to add older data (e.g. from influxDB) and removing bad data. I will try this later this week when I have some time available. Yesterday (before I changed measurement to total_increasing) I also managed to ‘get’ 250.000 kWh of solar energy. Must have been sunny. But it does ruin all data for the current year overview…

If someone else successfully managed to edit the .db file, let us know please.

On a similar note, is there an easy way to scrap everything in the Energy panel and start from scratch? I’m talking not only about the data but also which sensors are being used for the representation… so, basically how to go back to the setup UI for Energy.
I really don’t want to reinstall HA just because I messed up the Energy view.

I added this code:

    - platform: integration
      source: sensor.mqttpower
      name: "potenza_assorbita"

and this:

    sensor.potenza_assorbita:
      state_class: measurement
      last_reset: '1970-01-01T00:00:00.000000+00:00'

but always this:

Translating…
nessuna statistica corrisponddente trovata
no matching statistics found

Ulteriori informazioni sulle statistiche
Learn more about statistics

I believe the sensor needs to be either

device_class: energy
state_class: total_increasing

or

device_class: power
state_class: measurement

Yours is measurement but is missing device_class?

My source is…

  # Add this sensor if you want to see data in the energy tab
  - platform: integration
    source: sensor.current_cost
    name: Current Cost Total Energy
    unit_prefix: k
    round: 2

Which automatically set the state and device class in the integration package but since you’re using mqtt I’m not sure how you’d resolve.

Thanks for your reply:
now this is the code:

    sensor.potenza_assorbita:
      state_class: power
      device_class: measurement
      last_reset: '1970-01-01T00:00:00.000000+00:00'
      unit_of_measurement: "W"

image

but nothing changed…

Ah, I think you need a kWh sensor…

image

It should be total increasing I think, not just a measurement-in-time sensor.
I have other devices (power plugs, etc.) that report consumed kWh and they appear as options under grid consumption, which I used at first but then I got current cost working which is the whole house consumption from the grid rather than just the 4 or 5 devices.

that seems to be a customization? If so, take that out, and just as brunt says, rely on the sensor the integration returns. last_reset shouldn’t be used anymore in the first place, and, with the others, is set without customization.

I don’t know how many damn times it needs to be said. Energy not power.

Energy is what you use in total. Power is the rate at which you use it.

A 1kW (1000W)(power) heater uses 2 kWh (energy) in 2 hours.

A 100W light takes 20 hours to use the same energy.

3 Likes

I have a PZEM004 connected to an arduino with an ethernet shield. It sends voltage, current, power, energy by mqtt and the sensors work:

    - platform: mqtt
      name: "MQTTvoltage"
      state_topic: "home-assistant/sensor03/voltage"
      qos: 0
      unit_of_measurement: "V"
    - platform: mqtt
      name: "MQTTcurrent"
      state_topic: "home-assistant/sensor03/current"
      qos: 0
      unit_of_measurement: "A"      
    - platform: mqtt
      name: "MQTTenergy"
      state_topic: "home-assistant/sensor03/energy"
      qos: 0
      unit_of_measurement: "KWh"
    - platform: mqtt
      name: "MQTTpower"
      state_topic: "home-assistant/sensor03/power"
      qos: 0
      unit_of_measurement: "W"

I tried this:

    sensor.MQTTenergy:
      device_class: energy
      state_class: total_increasing
      last_reset: '1970-01-01T00:00:00.000000+00:00'
      unit_of_measurement: "KWh"

image

but nothing…

I guess once or twice more!

Mine did not show up right away after adding the currentcost integration. I tried a lot of things but in the end I think it just appeared on its own in its own good time. I could see the sensor in HA but it was not offered as an option in energy config…but then it was. It may take time for statistics to accumulate?