New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Entity ... (<class 'homeassistant.components.statistics.sensor.StatisticsSensor'>) is using state class 'measurement' which is impossible considering device class ('energy') it is using #87376
Comments
Hey there @fabaff, @ThomDietrich, mind taking a look at this issue as it has been labeled with an integration ( Code owner commandsCode owners of
(message by CodeOwnersMention) statistics documentation |
@tefracky I think your approach is wrong: you are trying to create a sensor with a unit_of_measurement that should be Instead you are creating a kWh-sensor, because the source-sensor has that unit I think? |
@bouwew |
@tefracky With wrong approach I mean you using the statistics platform. |
This started in 2023.2 for me. My config is
Error since 2023.2 is:
Adding a state class doesn't work either:
|
It's btw not the only thing that started acting unexpected in 2023.2, see iprak/yahoofinance#87. I don't see why "water" or "monetary" shouldn't be able to provide measurements, so to me this looks more like a bug in core than in statistics or https://github.com/iprak/yahoofinance. |
Looking at the statistics-code, the state_class can only be MEASUREMENT or None. Same for the min_max-code, also the state_class can only be MEASUREMENT, so not suitable for your purposes either. |
@tefracky @nohn have you considered using https://www.home-assistant.io/integrations/utility_meter/? |
@bouwew this doesn't work for me. I need the value as sliding window: I do not need the value for every quarter hour or every hour but the value for the last 15 oder 60 minutes. |
@nohn your |
@bouwew You are right, there are some different integrations, which might be useful. However, this will be only a workaround for the problem/bug I described. Why shoud an |
@tefracky the answer to your question can be found here: https://developers.home-assistant.io/docs/core/entity/sensor#available-state-classes, read under type: measurement. |
@bouwew No, this only describes, how it works and what is possible. As I said, there is a restriction for the using of the |
I still don't see, why statistics shouldn't work on total_increasing sensors. You don't need to justify, but explaining helps others to understand and thus accept your decisions. I've now removed |
Your base-sensor, sensor.wasserzaehler_hauptleitung, is a "current(-value)" sensor, it shows updates when water is acutally used. Also, you misunderstand what the integration-platform does, it does exactly what you want to achieve (make sure to use the left-method). I am using this one for a similar purpose. But, it's your HA system, you can choose to use whatever you like :) Also, I'm not making the rules, the HA Core Devs do this, I'm just showing you where to find the rules :) |
#84366 seems to be related. |
Hey guys,
True but I am not satisfied with that. The statistics component should be applicable to all statistics use cases. The one presented by @nohn certainly is. The example by @tefracky seems odd to me, please elaborate if you disagree. I believe the real issue here is the implicit inheritance of device classes. In the config of @nohn the source entity is of device_class "water" and represents the total volume in Solving this issue is difficult. My opinion about this:
@frenck this is comparable to the DSMR case linked, what do you think? #86690 (comment) |
@ThomDietrich I had a similar discussion with @frenck about a sensor with a m3/h unit_of_measurement in #87449. This one should have the state_class MEASUREMENT because it's a rate-measurement (rate of gasflow), was the conclusion in the end. The same applies then to a sensor with a unit_of_measurement like L/h. And, for these type of measurements there should not be a device_class. Instead there could be the possibility to add an icon. |
All, As mentioned above, I had to realize that the statistics component needs the optional configuration parameters Edit: Fix will be in release 2023.2.5 |
The problem
Similar to #86690, I have a problem with Version 2023.2:
Entity ... (<class 'homeassistant.components.statistics.sensor.StatisticsSensor'>) is using state class 'measurement' which is impossible considering device class ('energy') it is using; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+statistics%22
If I want to add
state_class: total
, the following error occurs:Invalid config for [sensor.statistics]: [state_class] is an invalid option for [sensor.statistics]. Check: sensor.statistics->state_class. (See ?, line ?).
What version of Home Assistant Core has the issue?
2023.2.1
What was the last working version of Home Assistant Core?
Not sure, but 2023.1
What type of installation are you running?
Home Assistant Supervised
Integration causing the issue
2023.01.1
Link to integration documentation on our website
https://www.home-assistant.io/integrations/statistics/
Diagnostics information
No response
Example YAML snippet
Anything in the logs that might be useful for us?
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: