Offsetting sensor data

I had an old thing that was always off. I used this code to offset it

- platform: template
  sensors:
    living_room_humidity:
      friendly_name: "Living Room Humidity"
      unique_id: "siren_h_15_humidity_offset"
      value_template: "{{ states.sensor.siren_h_15_humidity.state | float + 18 }}"
      device_class: humidity
      unit_of_measurement: "%"

Now I have a new thing in tuyalocal, and I have the entity as number.siren_humidity_15

I tried replacing the state code, but it doesn’t seem to work. I can’t test in the dev Template editor, where can I test it to work it out rather than keep rebooting to test?

Why not?

Put this in the template editor:

{{ states('number.siren_humidity_15') | float(0) + 18 }}

Oh I just put

{{ states.sensor.siren_h_15_humidity.state | float + 18 }}

as is, and it said none. I don’t really get this change to () and stuff. Now I can test. Thanks.

Not sure why you would do that if you want to use the new entity number.siren_humidity_15

Using states() is recommended to prevent errors:

https://www.home-assistant.io/docs/configuration/templating/#states

Supplying a default value for your float filter is also recommended. If your entity contains something that can not be converted to a floating point number the default will be used. e.g. if the state is unknown:

|float gives an error
|float(0) returns zero

If you want to understand more, have a read of this and practice in the template editor: