Allow Monetary device class in Sensor to use the Measurement State class

Pretty much what the title says. I have a few entities in which I track the price of things that fluctuate (ex. Electricity Price in Texas which can change quickly). In this case the value is a spot price not a totalization of some cost (like the total of my electric bill)

I couldn’t find a discussion anywhere on why Monetary isn’t allowed as a measurement but I’m very curious

Not sure if too late, but I stumbled across something when I was trying to solve for the same issue as you. I created a template sensor through the UI and set its Unit of Measurement to “USD”, and boom! That did the trick.
image

I.e.simply w/o defining a device_class. Ofc this works.

I’m struggling with this as well.

I want to show my bank account balance.

I’m setting:

device_class="monetary",
unit_of_measurement = "EUR",
state_class="measurement",

Homeassistant is logging that

2024-02-24 01:33:47.601 WARNING (MainThread) [homeassistant.components.sensor] Entity sensor.ing_deutschland_direkt_depot_XXXXXXXX_total_total_equity_value (<class 'homeassistant.components.mqtt.sensor.MqttSensor'>) is using state class 'measurement' which is impossible considering device class ('monetary') it is using; expected None or one of 'total'; 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+mqtt%22

According to Documentation measurement and monetary is a valid combination though: Sensor Entity | Home Assistant Developer Docs

I’m very confused what should be used though. If I leave the state_class empty it will actually not record in data recorder.

I think total would still be wrong as I don’t want it to accumulate if it resets to 0 or lowers.

I’m confused by that message as well.
I don’t see another device_class that represent a “price” (I’m monitoring fuel price, here).

EDIT: To be clear, the point of having a state_class in the first place is to be able to generate long-term statistics. The device_class is just a nice-to-have