Virtual Meter Device with manipulate Value

Hi Everybody,
I am using to detect my power consumption of my PV an Sonoff device. Everything works fine, flashed tasmo.
but I have one issue, my Electric converter needs 8w if the PV doesn’t produce Power.
So i have in my Metering at night 8w which will detect as production, how can I Create an device which will have the same prop of the sensor but remove 8w.
can someone help me?

I hope I wrote the Explanation correct and understandable…

greetings
Simon

template:
  - sensor:
      - name: "Corrected PV Power"
        unit_of_measurement: "W" # or kW
        state_class: measurement
        device_class: power
        state: "{{ states(sensor.your_pv_power_sensor_here')|float(0) - 8 }}"
        availability: "{{ states(sensor.your_pv_power_sensor_here')|is_number }}"
1 Like

I have following issue

Logger: homeassistant.config
Source: config.py:867
First occurred: 09:18:37 (1 occurrences)
Last logged: 09:18:37

Invalid config for [template]: invalid template (TemplateSyntaxError: unexpected char "'" at 44) for dictionary value @ data['sensor'][0]['state']. Got "{{ states(sensor.sensor.tasmota_energy_power')|float(0) - 8 }}". (See /config/configuration.yaml, line 60).
   sensor:
      - name: "Justiert"
        unit_of_measurement: "W"
        state_class: measurement
        device_class: power
        state: "{{ states(sensor.sensor.tasmota_energy_power')|float(0) - 8 }}"

Oops. Missing a single quote. Should be:

state: "{{ states('sensor.sensor.tasmota_energy_power')|float(0) - 8 }}"
1 Like

no my fault, i have to check better what i copy paste, thanks for help tom.

Nah, it was missing in my posted config. Make sure you fix both templates.

how do you mean both templates?
currently it shows unknown, no formatting issues but the value will not calc,

Both the availability and state templates are missing the first ’ as I copied and pasted the state template into the availability template when I wrote it to save time.