I’m not sure if I’m misunderstanding how to use these, so am looking for someone to check my thinking. I’ll give a simple example for concreteness:
Let’s say I have a simple sensor entity which acts as a basic energy meter that just tracks total energy usage (in kWh) by some device (for instance, a charger for an electric car) since the meter was initiated. The sensor is a “total cumulative” kind of sensor, which starts at zero and never resets - it only ever increases as energy is consumed. Let’s say it gets a new value every 15 minutes, and that the entity is called sensor.electric_car_energy
.
A common thing to want to do is to track the daily, monthly, and yearly energy usage by this device. Then according to the documentation, it is suggested that a good way to do this is to use the Utility Meter integration, and define something like this:
utility_meter:
daily_energy:
source: sensor.electric_car_energy
cycle: daily
monthly_energy:
source: sensor.electric_car_energy
cycle: monthly
yearly_energy:
source: sensor.electric_car_energy
cycle: yearly
1) Question About Duplication
After putting the above into your configuration.yaml, then each of these utility meters automatically generates an associated entity (which will be something like sensor.daily
, sensor.monthly
, sensor.yearly
). Now, since all three of these have the same source (sensor.electric_car_energy
), and this source updates every 15 minutes, then the data points that arrive every 15 minutes will all appear duplicated in all 4 entities. Is my understanding correct here? If so, what is the logic to justify this duplication?
2) Question About Plotting
Let’s consider now the simple case where I just want plot some bar charts:
- a daily chart, showing energy used each day over the last 7 days
- a monthly chart, showing energy used each month over the last 12 months
- a yearly chart, showing energy used each year for the last 5 years
Take for instance the daily chart. Then in order to make it I need x7 data points - total energy used on Monday, total used on Tuesday, … etc. Is my understanding correct that the sensor.daily
entity alone cannot do this directly? because it seems to be that only the value from the last_period is saved as a single attribute (i.e. the previous day’s total, before the meter reset it back to zero). Instead, are people using some “group by” statistics or something, which looks back over the past 7 days and grabs only the max from each period? Because this would require a lot more overhead if it’s done on-the-fly directly in the dashboard chart with such a large amount of historical data stored by the sensor.
3) Question About Unnecessary Fine-Grained Data Being Saved
If my energy meter sensor.electric_car_energy
updates every 15 minutes, then is all this data stored in the long-term statistics and recorder history for all three utility meter sensors as well? Because it seems to me that the logic of defining a “daily” sensor in the first place is implicitly because we only care about the final daily value. I have seen some justification of the reason for this being because people generally want to see a value for “how much have I used so far today”, and not have to wait until the end of the day to see it. This makes total sense, and therefore makes sense save the most recent value - but why save every single fine-grained 15 minute data point over multiple days?
I’m for sure not complaining here, but just hope someone can correct / enhance my understanding. I’m not sure I’m using the utility meter in the right way, and the documentation gives the example of setting up the utility meter sensors without talking about these limitations I’ve mentioned above.
It seems that its main appeal is that it provides an automatic reset function at the end of each cycle. So are people generally turning off the recorder history on all these utility sensors, and grabbing only the very few important (e.g. daily, monthly, yearly) values using template sensors?
Interested to hear anyone’s thoughts on this. Thanks.