Statistics Sensor - Not Continously but Triggered?

I have a Statistics Sensor with a rather big max_age:

  - platform: statistics
    name: "environment_lux_1_illuminance_lux AverageLinear_24h"
    entity_id: sensor.environment_lux_1_illuminance_lux
    state_characteristic: average_linear
    max_age:
      hours: 24

But i need its Value only once a Day. It is really unnecessary to let it permanently compute the statistic.

Is there a Way to only let it calculate the Statistics when triggered?

Use a triggered template sensor instead.

I guess thats my Problem - i know how to set up (triggered) template sensors, but not how implement that with statistics.

I tried it (for general testing i used time_pattern) with:

  - trigger:
      - platform: time_pattern
        minutes: /15
    sensor:
      - platform: statistics
        name: "environment_lux_1_illuminance_lux AverageLinear_24h"
        entity_id: sensor.environment_lux_1_illuminance_lux
        state_characteristic: average_linear
        max_age:
          hours: 24

But that obviously doesn’t work.

Invalid config for ‘template’ at configuration.yaml, line 421: ‘platform’ is an invalid option for ‘template’, check: sensor->0->platform Invalid config for ‘template’ at configuration.yaml, line 421: required key ‘state’ not provided

Can you point me in the right Direction?

PS: Congratulations for your Joining-Anniversary :slight_smile:

You can’t just add options from other integrations to the template sensor.

You need to implement a an average equation in the state option.

Which now I think about it is going to be difficult.

Thats it. I need the state_characteristic: average_linear Statistics Value. Once a Day.
I don’t know how to make that with a State Template.

Either do I.