Temperature offset sensor

Hi

I have the following problem :
I want a temperature offset for a sensor

In the developers tools (template)

- platform: template
  sensors:
    keuken_temperatuur:
    friendly_name: 'Keuken temperatuur'
    unit_of_measurement: "°C"
    value_template: {{ ((states.sensor.lumi_lumi_airmonitor_acn01_temperature.state | float) -1.8) | round(1) }}

Result

- platform: template
  sensors:
    keuken_temperatuur:
    friendly_name: 'Keuken temperatuur'
    unit_of_measurement: "°C"
    value_template: 21.3

i thought this was ok but
if i check the yaml before boot, then i get the following error

Error loading /config/configuration.yaml: invalid key: “OrderedDict([(’((states.sensor.lumi_lumi_airmonitor_acn01_temperature.state | float) -1.8) | round(1)’, None)])”
in “/config/sensor.yaml”, line 6, column 0

can anyone help me?

Your template is missing outer quotes.

    value_template: '{{ ((states.sensor.lumi_lumi_airmonitor_acn01_temperature.state | float) -1.8) | round(1) }}'

Reference: Important Template Rules

The Template Editor is for testing Jinja2 templates. It doesn’t validate YAML syntax. Wrapping a single-line template in quotes is a YAML requirement and isn’t tested by the Template Editor.

1 Like

Thank you very much :ok_hand:

You’re welcome!

Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.

For more information about the Solution tag, refer to guideline 21 in the FAQ.