My inverter only provides data every 5 minutes. I have a DSMR reader that generate data more frequently. Since that occasionaly I send more energy to the grid that my solar production. I would like to avoid this situation using conditional sensor.
There is a syntax error regarding the last conditional sensor. Do you have any idea what can be the problem?
template:
- sensor:
- name: dsmr_returned_in_watts
unit_of_measurement: "W"
state: "{{ states('sensor.dsmr_reading_electricity_currently_returned')|float * 1000 }}"
- name: dsmr_delivered_in_watts
unit_of_measurement: "W"
state: "{{ states('sensor.dsmr_reading_electricity_currently_delivered')|float * 1000 }}"
- name: "Actual PV Power"
unit_of_measurement: W
device_class: power
icon: mdi:solar-power-variant
state: >
{% set pwreturn = states('sensor.dsmr_returned_in_watts')|float %}
{% set pv = states('sensor.sma_ac_power')|float %}
{% if pwreturn > pv ) %}
{{ (pwreturn|float) %}}
{% else %} {{ (pv|float) %}}
{% endif %}