Variables+history > custom unit of measurement

How do I set up a variable with a custom unit of measurement?

I want to set up a variable with a unit of measurement, I don’t find in all the lists. Thus I set up a new variable using the variable+history UI with a random type.
Now I see the following configuration (variables+hostory → variable → configuration → change value and attributes):

unit_of_measurement: EUR
device_class: monetary
icon: mdi:currency-eur
friendly_name: Verbrauchspreis

Now I’m changing the unit from EUR to Ct/h. But that does not apply, it will always be restored EUR.

thx

That’s not possible.

even not by changing custom_value (line 485) from config_flow.yaml to true?

No, you will break many things if you use a dynamic unit_of_measurement. If you truely want that, make a template sensor without device_class and it won’t break.

HA is not designed to have a dynamic unit of measurement. It’s designed for the UOM to be static and the user changes the dropdown in the frontend on the entity itself to change the values. Then ha automatically handles the calculation changes for you. I highly doubt it does that for monetary though because the value of each changes frequently unlike normal conversions.

Thanks. Setting up a sensor without device_class worked for me.

1 Like