Units of measurement for sensor values to display stacked graph

Hi. newbie here to HA. Ive got some lorawan nodes connecting to TTN and using the integration to get their data into HA. In defining the sensor entities I realise I need to define the ‘unit_of_measurement: degC’ so that the stacked graph will display correctly the trend line for the temperature value instead of the blocky colour coded thing.
.
Ive found the following state editor in the Developer Tools which I have used to define a UoM as a new state after the friendly_name. It seems to be retained for a period and the graph displays correctly BUT the UoM state dissapears and the graph returns to the boxy coloured crap.

Can someone assist me in how to define the UoM for my sensors.

Seems as a new user I can only post 1 pic.
Thanks in appreciation Mal.

I’m not familiar with TTN but the units should be set through the integration normally.

Developer tools only sets the states temporarily so any changes you make there will not be retained.

There is a workaround you can do though by creating template sensors, I’m fairly new to HA so there may be a better way however looking at this project it seems to be the right way.

You can add this to your configuration.yaml:

template:
  - sensor:
      - name: "Sensor name"
        state_class: measurement
		unit_of_measurement: "°C"
		state: "{{ states.sensor.SENSOR_NAME.state }}"

See the templates docs for more info :slight_smile:

1 Like