Count ice days

Howdy
My intention is to count the icy days
I created several sensors, but the result is not optimal.
I am binary_sensor which reacts to temperature <0>

template:   
  - binary_sensor:
    - name: on zimní off
      state: >-
         {% if states('sensor.svetlo_balkon_t_h_si7021_temperature') | float <=0 %} on
         {% else %} off
         {% endif %}
    

Then it is the turn of the history sensor, which measures the time when the binary_sensor is off, ie the temperature is >0. Sensor time is - end today at 0:00 and the duration is 24 hours.
So, if this time = 0, the temperature during the day was not more than 0:

sensor:
  - platform: history_stats
    name: nezimní den
    entity_id: binary_sensor.on_zimni_off
    state: "off"
    type: time
    end: "{{ now().replace(hour=0, minute=0, second=0, microsecond=0) }}"
    duration:
      hours: 24

Subsequently, another sensor of history counts the days that the previous sensor as the day when the temperature was not greater than 0

  - platform: history_stats
    name: zimní den
    entity_id: sensor.nezimni_den
    state: "0.00"
    type: count
    end: "{{ now().replace(hour=0, minute=0, second=0, microsecond=0) }}"
    duration:
      days: 15
      

But somewhere I make a mistake because it doesn’t work properly.
Can someone help me please