Cannot get template sensor data in statictics graph card

I’m pretty new to HA, and need a bit of help …
I am trying to create a template sensor that derives its value from an other sensor, and display the result in a statistics graph card on my dashboard.

To do so, I added this to my configuration.yaml file:

  - sensor:
      - name: "GraadDag_Today"
        unique_id: 'sensor.0a7476cc-d6c1-40ba-8ae1-606518c3497f'
        unit_of_measurement: "°C"
        state: >
          {% set MeanTempToday = states('sensor.buienradar_temperature') | float %}

          {{ 18-MeanTempToday }}

And added this statistics card to my dashboard (using code editor):

type: statistic
  entity: sensor.grdag_today
      period: day
stat_type: mean
name: GrDag Vandaag
unit: °C

The problem I encounter is as follows:

  • the statistics card shows up on my dashboard, however the sensor value is not shown (blank)
  • when I click on the card, the small window that pops up shows the correct graph (info tab)

Can anyone point out what I’m doing wrong here?

First of all, you are not using statistics, e.g. have a look below
There are also other options…
Second… you sensor.grdag_today is not equal to GraadDag_Today

Statistics - Home Assistant (