Rest API positive Values

Hey Guys,

I need help!
I created a resp api sensor from my Fronius GEN24 Inverter
So this sensor reads positve and negative data…i would like only read the positve Values over 0…and ignore the Values under 0
is that possible?

platform: rest
    resource: http://10.0.0.245/solar_api/v1/GetPowerFlowRealtimeData.fcgi
    method: GET
    name: "Netzbezug SAG neu"
    value_template: "{{ value_json['Body']['Data']['Site']['P_Grid'] | int | round(0) }}"
    unit_of_measurement: 'W'
    scan_interval: 2
    force_update: true

Sure. Create a state based template sensor with one of the following templates:

# positive values are from grid
from_grid: {{ max(states('sensor.power_grid_fronius_power_flow_0_http_192_168_68_10') | float, 0) }}
# negative values are to grid
to_grid: {{ max((0 - states('sensor.power_grid_fronius_power_flow_0_http_192_168_68_10') | float), 0) }}

(Entity_ids are from the Fronius integration - adapt for your specific)
Maybe you can just use max(..., 0) in your value_template as well

Thanks Matthias!

It works great!