I have a sensor calculating my solar energy consumption. It works very well.
BUT, it goes below zero if I deliver back too much, but I want that to be minimum 0.
Is that possible?
power_consumption_solar:
value_template: "{{ (states('sensor.growatt_total_output_power')|float - (states('sensor.power_production')|float *1000)|round(2) }}"
unit_of_measurement: 'W'
friendly_name: Home usage Solar Energy
example of what I do not want too see:
this should be minimum 0.
This selects the maximum from a list containing your sensor calculation and zero. So you will only get 0 or positive values (0 is bigger than all negative numbers).
It looks like when you copied it over, the quotations got messed up. I just did a straight copy/paste from the code above and it worked. Try coping the above code again or replace â with â in what you currently have