You can create Statistic Card - Home Assistant
And chose min/max and période
@EdwardTFN The statistical map is not an entity that can be reused for calculations or other purposes.
Perhaps the template could include SQL integration to retrieve the last known value. This would make it possible to withstand a restart
Example where I need to retrieve the penultimate known value of the pH of the water even if the entity is unavailable.
The automaton is limited to 1 from_state. Thanks to SQL, I can manipulate several previous values for the same trigger
SELECT s.state_id, s.state, s.last_updated_ts, s.old_state_id
FROM states s, states_meta m
WHERE s.metadata_id = m.metadata_id
-- Nom de l'entitée à suivre
AND m.entity_id = 'sensor.spa_flipr_ph'
AND s.state <> 'unavailable'
ORDER BY
last_updated_ts DESC
LIMIT 1,1
This would be a patch until HA one day knows how to retain values and automations after a system upgrade.