I seem to be unable to use this entity in any statistics elements
I have found notes that this needs to be added to a template to enable
state_class: “measurement”
But that option is not available in the number helper.
I prefer to use the UI to manage these objects rather than 60-70 files. I assume this is just not exposed to the UI. Where are the files for helper definitions are stored so I can test adding it there?
Or is there a better method to create a currency cost entity?
Seems like a very common use, is there a normal way to do this?
Seems like there should be a cost object type, and a helper that can link to a kWh, liters etc entity and create a linked money value.
A Template number is not a Template sensor… if you want statistics you need to use a Template sensor, which will give you the options to set device class, state class, and unit of measurement.
number entities, like input_number entities, are distinguished by the fact that they are designed to be changed directly by the user. These entities can be manipulated via dashboards as well as script actions like number.set_value.
A sensor’s value is not directly adjustable by the user.
A sensor is an entity that holds a value that is not entered manually. Number entities and input_number enitites are entities that allow user input.
For sensors to have statistics, they need to be numerical (having a unit_of_measurement is how Home Assistant determines if a sensor is numerical). Input numbers and numbers are numerical by design - they always have a unit of measurement (it can be an empty string).
For a sensor to have statistics, they also need to have the right state_class and device_class. Input_numbers and numbers generally do not have the state_class needed to keep statistics. That is not so strange, as they are not measurements or accumulated totals but user input.
Are you interested in manual entry, or can the value be calculated? Being a number entity and a numerical entity are not necessarily the same thing.
To get back to the topic at hand, monetary entities have weird limitations because they are reserved for price, which is considered not a measurement or total. This totally ignores the fact that a monetary is a device class type designation that is totally separate from what state class is describing.
A price can be considered a measurement, a balance can be considered a total and an energy total multiplied by the energy price can be considered total_increasing. They are all monetary. However, Home Assistant does not agree with that.
The solution is to avoid device class monetary whenever you can. Just use your favorite unit_of_measurement to represent the valuta so it is numerical. Then set the state class to what is appropriate to you. And don’t tell Frenck about it
Read the post just above yours. You probbly missed it as we typed simultaniously. Monetary is considered a special device class. It might be filtered out there.
No, Freck just needs to get of his high horse and see that monetary is a flexible term But what you say could also help settle the dispute. I just keep avoiding monetary because it does not add much value until this is fixed.
Even separating them if you have a market rate agreement, and a data feed of rates that changes through the day, Rates should also be available to statistics like high-low-mean.