Sensor lambda calculation change minus to plus

  - platform: copy
    source_id: sensor_filter
    name: "Wasserstand"
    filters:
      - lambda: return x - 1000;

how do I get the result to plus
Multiplication by -1 doesn’t work

the sensor value is always below 1000 (for information)

Why not 1000 - x or perhaps -(x - 1000)

Unfortunately you have to write return x at the beginning otherwise you get an error message

  - platform: copy
    source_id: sensor_filter
    name: "Wasserstand"
    filters:
      - lambda: return - (x - 1000);

Now I understand it
I had assumed return x must always be together

Thanks for the hint

There’s also the absolute value c++ function abs().