What’s the difference between “temperature” and “device temperature”?

On my Aqara sensors (RTCGQ11LM, connected via MQTT) there is “temperature” and “device temperature”. The values are quite different, and only device temperature is available as an entity.

Can anyone shed any light on this?

state_class: measurement
battery: 56
device_temperature: 31
illuminance: 30
illuminance_lux: 30
linkquality: 255
occupancy: false
power_outage_count: 23
temperature: 23
voltage: 3045
unit_of_measurement: °C
device_class: temperature

device_temperature is the temperature of the device internal board, while temperature is the room ambient temperature monitored by the device.

Thanks. That’s what I thought might be the case, but it’s odd that only the least useful temperature is available as an entity.
Do you know of any way to make the other value available?

Can you show the device page for the device?

The temperature entity shown is actually “device temperature” - I’d renamed it.

According to Zigbee2MQTT documentation this is all functioning normally. I just wondered whether there was any way to basically convert an attribute into an entity, as ambient temperature shows as an attribute only.

I’d disagree. This should not be an attribute. I’d put in an issue.

Yeah there is.

Use a template sensor:

(configuration.yaml)

template:
  - sensor:
      - name: "Living Room Temperature"
        unit_of_measurement: "°C"
        device_class: temperature
        state_class: measurement
        state: "{{ state_attr('sensor.living_room', 'temperature') }}"
        availability: "{{ state_attr('sensor.living_room', 'temperature')|is_number }}"

I guessed the entity_id of your sensor above. You will probably have to change it in both the state and availability templates.

2 Likes

Awesome. I’ll give that a go. Thanks.

One more thing, please. If I wanted to offset the value that I get from the temperature attribute, how would I do that? It seems that the sensor isn’t all that accurate, but I can’t figure out how to adjust the number to be correct.

If you just want to add (or subtract) a constant offset:

state: "{{ state_attr('sensor.living_room', 'temperature')|float(0) + 3 }}"

If you want to scale the output by some factor:

state: "{{ 1.2 * state_attr('sensor.living_room', 'temperature')|float(0)  }}"

Or both:

state: "{{ 1.2 * state_attr('sensor.living_room', 'temperature')|float(0) + 3 }}"

You can plot the temperature reported by the sensor against some standard in a spreadsheet and try to fit a linear equation for that last one.

Or if you just have two known points you can put the template sensor through this:

1 Like

Amazing. Thanks.