Adjusting values before display?

Hi there, wasn’t sure whether to start a new thread or not, but I figured it was a new question so deserved a new thread. I’ve got some mysensors temp and humidity sensors sending data via MQTT to HASS. However, I know that the sensor I’m using (Si7021) is off with humidity by about 8%. So, is there a way to adjust this before it hits the display?

Have a look at templating:

and specifically:

This should work:

{{ value | multiply(1.08) }}

Adjust the factor according to your case.

1 Like

Thanks, I’ve now familiarized myself with those pages, but am a little unsure how to proceed. As I understand it, I need to define a value_template for the humidity sensor in my sensors.yaml file and then use this:

{{ value | minus(7) }}

But I’m unsure how to define value_template and where to add the above code?

Replying to myself, it’s quite easy actually (when you know how!), this is now how my MQTT mysensor looks in my sensors.yaml file (called from configuration.yaml)

- platform: mqtt state_topic: "mygateway1-out/4/2/1/0/1" name: "Humidity JJ room" unit_of_measurement: "%" value_template: "{{ value | minus(7) }}"

3 Likes

Anyhow to do this with arduino sensor ? i tried
sensor:
platform: arduino
pins:
2:
name: hometemperature
type: analog
value_template: “{{ value | minus(25) }}”
but its not working

No, not currently. Each component must implement support for templates for incoming values, so only components that mention this in their documentation will support it.

1 Like