How can I change the MQTT value of the entity? Sensor value needs an offset

Hi. I have added a CO2 sensor through Tasmota, but the sensor value is 100ppm out. How can I transform the displayed value, so that when it receives say 600ppm, it actually shows 500ppm?

You may be able to add an offset via Tasmota. I only have experience of ESPHome, and you certainly can there. Within HA, you can do it with an additional template sensor. Using the new configuration format:

template:
 - sensor:
      - name: "Corrected CO2 sensor"
        unique_id: put_an_id_here
        unit_of_measurement: "ppm"
        device_class: carbon_dioxide
        state: "{{ [0, states('sensor.your_co2_sensor')|int - 100]|max }}"

Subtracts 100ppm but won’t go below 0.

The unique_id allows for customisation like assigning to an Area. I use UUID4 IDs.

Legend! I knew I had to use templates, but this is neat =)
Could not work out how to do it in Tasmota. Will play with ESPHome as well just to see if it gives a better output. Sensor itself is calibrated to 400ppm in open air, but Tasmota for some reason gives the wrong output.

hm… was complaining that through Tasmota the values were off.
Reflashed it with esphome - values are now off by +200 or so

Maybe the stress of the offset is making you breathe more heavily, influencing the results further? :wink:

must be =) so bad, that it’s influenced the outdoor co2 =)