Help with history stats- what is missing?

Hi all
I made the following binary sensor

- platform: template
    sensors:
      saloni_ac_on:
        friendly_name: "Saloni AC On"
        value_template: >-
          {{ state_attr('switch.sonoff_1000fe4991' , 'power')|float > 10 }}

In HA i get the following
image

Then I made the following history stats

  - platform: history_stats
    name: Saloni 30d
    entity_id: binary_sensor.saloni_ac_on
    state: 'on'
    type: time
    end: "{{ now().replace(hour=0, minute=0, second=0) }}"
    duration:
      days: 30

but I am getting the following
image

I also tried with

end: '{{ now().replace(hour=0, minute=0, second=0) }}'

and I have added in logbook, recorder, and history the sensor and binary sensor.

What am I missing?

Probably the binary sensor did not exist beginning of today? If so, there is no data available for the history stats sensor, therefore it will show unknown.

1 Like

It makes sense. I would prefer though to show something like 0 and not unknown
because if something goes wrong , the state is again unknown and it is confusing.