Meteorological Seasons sensor?

In sweden we use Meteorological Seasons besides of the calendar version so for example:

  • Winter = Average daily temperature is below 0°c for 5 consecutive days
  • Spring = Average daily temperature is below +10°c but above 0°C for 7 consecutive days
  • Summer = Average daily temperature is above +10°c for 5 consecutive days
  • Autumn = Average daily temperature is below +10°c but above 0°C for 5 consecutive days

If the condition is true then the season started on the first date of those consecutive days

Can I somehow make a template sensor for this, not sure how I can use time limits and average temperatures in that way
src: Årstider | SMHI

1 Like

Make sure your recorder has seven days of data.
Then I guess you could use a statistics sensor on the temperature (probably make a template sensor for this to extract the temperature).
I think the easiest is to make two statistics sensors, one with seven days and one with five days.

The statistics sensor should then display the average temperature the last seven days.
So with that you should be able to template it:

  - platform: template
    sensors:
      metrological_season:
        friendly_name: "Season"
        value_template: >-
                        {% set temp7 = states('sensor.statistics7') | float %}
                        {% set temp5 = states('sensor.statistics5') | float %}

                        {% if temp5 < 0 %}
                          Vinter

                        {% elif 0 <= temp7 >= 10  && now().month < 6 %}
                          Vår 

                        {% elif 0 <= temp5 >= 10 && now().month > 6 %}
                          Höst

                        {% elif temp7 > 10 %}
                          Sommar
                        {% endif %}

Ooh nice, thanks!

The problem is that I can’t just use an average sensor and set it to the last 5/7 days if I understand it correctly.
Each daily average needs to be within the value and not just the average of all the days, for example winter:

  • day 1 average: -5
  • day 2 average: -6
  • day 3 average: -4
  • day 4 average: +2
  • day 5 average; -4

That gives an average for the 5 days at -3,4 but since day 4 “resets” the counter of 5 consecutive days it fails and it would still be autumn.

Right…
The statistics senor wont work in that case.

I can’t see a way to do it easily in Home Assistant.
There is a way to do it in Node Red.
Since I don’t have an outdoor temperature sensor I just took an indoor entity, but the same principle applies.

So here I see each state and time and I could create an average per day in javascript and calculate the season and start date.

Same thing here in Finland, meteorological season is based on temps and as such, it may even alternate at some stages between say spring and summer. My intention is to use season for seelecting heating control automation.

Just installed HACS Average sensor ( GitHub - Limych/ha-average: Average Sensor for Home Assistant) in order to make seven day temp average sensor and then going to template output four seasons. This average is supposed to get around some limitations in temp handling according to documentation.