Hello everyone,
well, I own a bunch of Shelly 2.5 and 1PM which are setup as MQTT sensors.
In addition, I own a bunch of power sockets running Tasmota.
What I would like to do is track the daily power consumption in kWh (or Wh).
I have setup InfluxDB and Grafana as well.
Current power consumption in W is easily tracked as each sensor offers this value. And hence just as easily displayed in Grafana by plotting that sensor.
However, the consumption per calendar day in kWh seems tricky because the sensors don’t all offer this natively.
For me it should be possible to create a fake sensor that simply calculates the power consumption based on the current consumption as tracked in the database.
So simply sum up all Watts between midnight and midnighr and multiply by 1000 to get kWh and then divide by 24 to get kWh.
But how is this done?
Ideally the sensor would also need to check the status before midnight because only changes in consumption trigger a new value push. So if at 23:59 1000 watts are being consumed, then this would still be the case at 00:01 but the fake sensor would think it is 0 W because there is no data point.
I think it’s going to be more complicated than you think.
watts are instantaneous power. you can’t just take those instantaneous watts and convert to kwh. you have to know how long the watts were at that value then do the conversion based on that time frame.
Oh, btw, your conversion was off.
kwh = w / 1000 x hours
for example you are running a light bulb that draws 100 watts. and that bulb is on for 2 hours.
the instantaneous draw in kw = 100 / 1000 = .1 kw
and since it ran for 2 hours kwh = .1 kw x 2 hours = .2 kwh
but you will have to do that continuously for every hour/minute/second the device is running.
you say the device only updates on a change in watts so you can take advantage of that by using the last_changed time.
So, you can create a sensor to hold the ever changing daily total of kwh then update that sensor each time the state of the first watts sensor changes.
you can calculate the new kwh total sensor by using the current number of watts for the amount of time between now and the last time the kwh sensor was updated.
and, again, the watts could change every second too so you will be doing that calculation for each sensor potentially every second.
@finity : I apologize. Of course it should habe been devided and not multiplied. Stupid of me.
@tom_l : Quick question. If I feed an energy sensor (in watts) directly into Utility Meter as a daily sensor, what happens then? What result would I get?
That’s what I thought. But I created sensors in utility meter for all of them but in Grafana they only show up with the unit “W”. So it seems the daily consumption is not converted to kWh.
Hmmm, strangely when I set the unit to kilo it miscalculated. Seemingly kept the value but added the kilo. So 1500 Wh were then 1500 kWh.
Need to look into this tomorrow.
I am wondering about the method. What is really the difference. I do have an electrical boiler. I also have a fridge, big flatscreen and also smaller items like power amps or a raspberry pi. So could I set all of them to “left” or would that not work?
Especially since to my understanding left and right belong together and the shape (trapezoidal) should be opposite rectangle etc.
And I would have thought that middle would be better than left or right.
So, I have set everything up and let it run the last few days. Switched to method left yesterday.
But what confuses me is the way the utility meter data is output.
A daily cycle should have only one single data point per day. It should show the total energy of one day.
Mine however look like this:
Upper image showing the actual sensor data, so the Watts being consumed in real-time and the bottom one showing the utility meter daily which went through the Riemann sum first.
No, that is not how it works. The Utility meter resets to 0 at the beginning of the cycle (day) and counts up during the day so you can see how much has been used so far this cycle, before resetting again at the end of the day.
And the Riemann sum keeps adding then? So it increases indefinitely whereas the utility meter resets daily?
Hmmmm… so is there another tool that gives me what I want?
I simply want to know how much I consumed per day. So, from what you say, I am gueasing this would be the max value of the daily output.
By the way, is there a way to have Riemann and utiliy meter be applied also to data recorded before creating/modifying those virtual sensors? The data of the sensors is stored in the database after all.