The Statistics Integration (Statistics - Home Assistant) should accept value template instead of only entity state.