Different temperature sensors ends up in different graphs

I have one temperature sensor from modbus integration and two sensors from mqtt integration. I would like to have all three in the same histogram graph. Today it looks like this:

The modbus sensor is defined like this:

- name: Nibe
  type: tcp
  host: <local IP>
  port: 502
  sensors:
  - name: "Utetemperatur (BT1)"
    device_class: temperature
    state_class: measurement
    address: 1
    count: 1
    slave: 1
    precision: 1
    input_type: input
    scale: 0.1
    scan_interval: 60

The two other sensors are defined like this:

- platform: mqtt
    name: "Uterum"
    state_topic: "Byvallen/28.E99295040000"
    unique_id: temperature.uterum
    device_class: "temperature"
    state_class: measurement
    value_template: "{{ value_json.temperature }}"
    force_update: true    
  - platform: mqtt
    name: "Växthus 2"
    state_topic: "Byvallen/28.78F52F040000"
    unique_id: temperature.vathus2
    device_class: "temperature"
    state_class: measurement
    value_template: "{{ value_json.temperature }}"
    force_update: true

I assume that I have missed something but I don’t understand why they don’t end up in the same graph.

Edit: when I hover of the lower graph I realize that I don’t have any unit for the measurement. Can that be the problem? I thought I got C by default for all temperature sensors.

I’m running 2022.2.9 of HA on Home Assistant Blue.

Yes that is the problem.

You need to give the utetemperatur_bt1 sensor a unit_of_measurement: "°C".

I still fail. My config is now

- name: Nibe
  type: tcp
  host: <local ip>
  port: 502
  sensors:
  - name: "Utetemperatur (BT1)"
    device_class: temperature
    unit_of_measurement: "°C"
    state_class: measurement
    address: 1
    count: 1
    slave: 1
    precision: 1
    input_type: input
    scale: 0.1
    scan_interval: 60

I still do not see °C as the unit while hover over the graph.
The sensor is using the modbus integration. Can that be the problem?

When I look at the documentation for modbus integration at Modbus - Home Assistant it says the following:


unit_of_measurement is an integer. Is it a documentation error or is this generated from the code which creates a problem in the integration?

It’s not auto-generated. It’s a typo. Fixed:

That was quick! :slight_smile:

My main problem still remains though. Why is the unit not used for the sensor frpm modbus integration?

Assuming that you have restarted Home Assistant after making the changes to the Modbus sensor the only other thing I can think to advise you to do is to clear your browser cache.

I restarted my HA again, I cleared browser cache, I have tested on different computers and on different browsers…
It still looks the same, there is no unit on the modbus integration temperature. :frowning:

It won’t move to the other graph until the wrong unit of measurement is purged from the system. That can take up to 10 days depending on your recorder setup.

New measurements should show up with the new unit though.

Yes, the entity will have the correct unit, however it’s unclear what OP is looking at. I would wager that he’s still looking at the graphs.

2 Likes

I created a new modbus sensor with unit_of_measurement and it worked directly. I assume @petro was correct above.