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?
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"
but nothing changed…
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.
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"
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?
I’m not sure how pedantic HA is but try
unit_of_measurement: 'kWh'
The capitalisation may be important ?
It may be. It is fussy about m3 vs m³.
General guide to SI units, if it is named after a person it gets capitalised.
eg
A Ampere
V Volta
m metre
s second
Did you have any luck finding solution for backfill?
Created separate thread for this topic earlier today
Great! It was the capitalisation… Now it works:
- platform: mqtt
name: "MQTTenergy"
state_topic: "home-assistant/sensor03/energy"
qos: 0
device_class: energy
state_class: total_increasing
unit_of_measurement: "kWh"
Great stuff! I integrated my solar pannels (a RPi reads the values from the inverters and stores them in an mariaDB, I load them to HA via the sql integration) and some individual devices - so far so good!
Next, I will read my power-meter using a LED / pulse reader (GER only: Mache deinen Stromzähler smart - poweropti | powerfox - they provide a nice REST-API)
Question: Due to wrong incentive from our gov. one is way better off to sell 100% of the produced solar energy and buy 100% back of what you consume. So, I return 100% of my solar energy back to the grid…
As I get it correctly, HA assumes that “return to grid” is the difference between production and consumption - correct? Is there a way to configure the setting I’m faced with?
I guess, I can just delete / disable my solar panels - but then I’ll be missing the nice graphs