How to multiply an input value by -1?

I have a ShellyPM power monitor that produces a negative value when my PV system is generating power. I know I could turn the CT sensor around by 180 degrees but that would compromise something else within HA, so I would much prefer to remove the minus from the value. How might I do this?

TIA

You need to create a template sensor.
state: "{{ states('sensor.barns_pv_power') * -1 }}"

1 Like

Or use the ‘abs’ filter.

{{ (states('sensor.barns_pv_power') | float(0)) | abs }}
2 Likes

Many thanks @Hellis81 & @VDRainer

I have added the following to the bottom of my config file, but even after restarting HA I can’t find it (ie anything containing -1xBarns) anywhere within Developer Tools. What else do I need to do to get it to appear within my Lovelace dashboard? (I know how to use Lovelace, but I can’t find an entity(?) to populate a graph.)

TIA

template:
  - sensor:
    - name: "-1xBarns PV"
      unit_of_measurement: "kW"
      state: "{{ states('sensor.barns_pv_power') * -1 }}"

The name of the sensor that will be created will not include the leading hyphen.