Option "none" in the Unit of measure setting

In the parameters of a sensors we can select a unit of measurement, but if we want no unit of measurement this is not possible.

It would be great if we could add the none choice to this list.

Remember to vote for your suggestion! :wink:

Can you give an example of a sensor that you can’t model please?

(e.g. number of loaves in the cupboard, the value of a mode setting?)

According to the dev docs, the default sensor device class is None which gives a genric sensor, or for Number. The State classes docs are more explicit:

A sensor is a read-only entity that provides some information. Information has a value and optionally, a unit of measurement.

The Python code seems to default to None if a different value is not set.

Is this an issue creating a new Sensor / Number / Entity via a particular GUI / integration / API not accepting None perhaps?

I’ve not tested it but could see issues where an existing Add-On defines a sensor with a device class (native_unit_of_measurement), and you want to change it to None as there might not be code to do a conversion?

In fact these are temperature sensors that display the temperature in degrees Celsius, so far nothing abnormal.
But since I integrate it into a state-label of a picture-elements type map, I would like not to display the unit of measurement.
Here are 2 pictures showing the result I obtained by creating a new sensor without a unit of measurement.


So what you asking for is the ability to change the GUI presentation of specifically a temperature sensor, and not the generic sensor entity (which is already explicitly supported - links to the source code above).

HASS has additional code for SensorDeviceClass.TEMPERATURE to use system / localisation setting for temperature units so it understands what temperature is, so only offers temperature unit options - e.g.:
image

A workaround is to create a template function based on the sensor, e.g.:

{{ states('sensor.study_pir_air_temperature', rounded=True, with_unit=True) }}
Gives: 22.6 °C

{{ states('sensor.study_pir_air_temperature', rounded=True, with_unit=False) }}
Gives: 22.6

{{ states('sensor.study_pir_air_temperature', rounded=True, with_unit=False) | float }}
Gives: 22.6

This method allows you to create whatever formatting you wish for.

Thanks for the reply,
Indeed we can get around the problem in different ways, but I found it interesting to have this option directly in the graphical interface of all sensors.

Another work around that more accurately meets your needs is to use the custom button-card to display the state of an entity in the name field, where you can modify the state text with JavaScript. Here’s a simple example that adds the “degrees” symbol to the value of a temperature in a picture-elements card:

type: picture-elements
elements:
  - type: custom:button-card
    style:
      top: 35%
      left: 30%
    entity: sensor.out_temperature_ha
    color_type: card
    color: rgba(0, 0, 0 ,0)
    name: |
      [[[
        return states['sensor.out_temperature_ha'].state + "°";
      ]]]
    show_icon: false
    styles:
      card:
        - '--ha-card-border-width': 0px
      name:
        - font-size: 90px
    tap_action:
      action: more-info

The style sets the placement of the text. color rgba(0,0,0,0) makes the button transparent, and setting the border width to 0px leaves a button with only the text. Obviously not the best option, but visually it works great. If you don’t want any tap action, just set the action to none.