Dear Community, I would like to track the maximum value of my solar system and display it as a number. Unfortunately it does not work yet because on restart my already highest value disappears and it takes the current value again. After that it works again as expected and it updates the value only with the highest value. I have already read through some threads here in the forum and added the first line. Unfortunately without success. So how to solve the restart issue? Thank you so much in advance.
- sensor:
- name: "SolarPeakMax"
unit_of_measurement: "W"
state_class: "total_increasing"
state: >
{% if states("sensor.grid_power") in ['unknown', 'unavailable', '0', '0.0'] %}
{% set sensorOutput = states("sensor.SolarPeakMax") %}
{% else %}
{% set sensorGrid = states("sensor.grid_power") | int(0)%}
{% set sensorSolarPeakMax = states("sensor.SolarPeakMax") | int(0)%}
{% if sensorGrid > sensorSolarPeakMax %}
{% set sensorOutput = sensorGrid %}
{% else %}
{% set sensorOutput = sensorSolarPeakMax %}
{% endif %}
{% endif %}
{{ sensorOutput }}
This was a restart: