Accuweather template sensor for displaying an image (icon) of the current weather condition

Hi!

I’m trying to set up a floor plan card and since I had a mobile display problem I decided to make a grid card that shows a calendar card in one column and a floor plan card in the other which is entirely SVG (so it’s a challenge for me)!

With the help of others, I solved everything except the display of the current weather image!

Current display after the sun has already risen

Current display after the sun has set down

I currently have a sensor template for the entity: weather.accuweather to display the current state:

  - platform: template
    sensors:
      accuweather:
        value_template: >
          {%- set state = states('weather.accuweather') -%}
          {{ state if state in ['clear_night', 'cloudy', 'exceptional', 'fog', 'hail', 'lightning', 'lightning_rainy', 'partlycloudy', 'pouring', 'rainy', 'snowy', 'snowy_rainy', 'sunny', 'windy'] else '' }}

I also have a sensor template for the entity: sun.sun to display the current state:

  - platform: template
    sensors:
      sun_state:
        friendly_name: "Vidnost sonca"
        value_template: >-
          {% if is_state('sun.sun', 'above_horizon') %}
            Nad obzorjem
          {% else %}
            Pod obzorjem
          {% endif %}

I could also use entity: sun.sun directly, because it obviously gives the same result.

I also thought of the information about % cloudiness, because there are several pictures showing different cloudiness:

My desire is to get a sensor (using a template) that would display the cloudiness according to the % of cloudiness (slightly cloudy, partly cloudy, cloudy, heavy cloudiness), I forgot to mention also the precipitation unit, which would display the rain (drizzle, light rain, rain , heavy rain) and finally the data from sun.sun, which would add `_night’ at the end (state: cloudy_night).

Did you ever figure this out?

Hi.
No I still haven’t found a local solution, although I bought a local weather station that is tied to wunderground, but it doesn’t even give an approximate state of the sensor data!

I can’t believe this is so difficult, it should be a simple: if rainy, display X, if sunny, display Y etc…

Have you tried this? I can’t get it to work but supposedly it does.

GitHub - Villhellm/lovelace-animated-background: Animated backgrounds for lovelace

1 Like

Hi. Thanks for the reply and suggestion.

The matter is much more complicated than it seems at first glance.

I started to work on something, but I’m new to programming, so I need help and I don’t know how to contact someone who has this knowledge!?

The example below is for night lighting (I should continue with creating a rain sensor “amount”, and maybe a shot sensor via the Blitzortung add-on) and already here a big problem appears!!

  - platform: template
    sensors:
      oblacnost_ponoci:  
        friendly_name: "Oblačnost ponoči"
        value_template: >
          {% set current_time = now() %}
          {% set moon_rising = strptime(states('sensor.moonnextrising'), '%Y-%m-%dT%H:%M:%S%z') %}
          {% set moon_setting = strptime(states('sensor.moonnextsetting'), '%Y-%m-%dT%H:%M:%S%z') %}
          {% set moon_illumination = states('sensor.astroweather_moon_phase') | float(0) %}

          {% if current_time >= moon_rising and current_time <= moon_setting %}
            {% set lux = states('sensor.lux_senzor') | float(0) %}

            # Prilagajanje vrednosti lux glede na lunino osvetljenost
            {% if moon_illumination > 0 %}
              {% set adjusted_lux = lux * (100 / moon_illumination) %}
            {% else %}
              {% set adjusted_lux = lux %}
            {% endif %}
            
            {% set normaliziran_lux = adjusted_lux / 10 %}

            # Končni izračun oblačnosti
            {% set prilagoditev_na_luno = normaliziran_lux * (moon_illumination / 100) %}

            {% if prilagoditev_na_luno > 0.8 %}
              Jasno
            {% elif prilagoditev_na_luno > 0.5 %}
              Delno oblačno
            {% elif prilagoditev_na_luno > 0.2 %}
              Oblačno
            {% else %}
              Močno oblačno
            {% endif %}
          {% else %}
            null
          {% endif %}

First, I need to have a separate lux sensor (light sensor) because my weather station doesn’t have one. And this is where the problem arises, if I want to monitor the cloudiness overnight due to the changing illumination of the moon (which I have to take into account, otherwise it would show one value when the moon is full and if there are no clouds, another value when it is waning, etc.)
Of course, I also have to take into account that the sun has set (nighttime condition)!

But when it’s daytime, it’s even more difficult because the sun has different strength/angle throughout the year, how do you know when it’s snowing, the outside temperature is a sufficient condition and the water reservoir in the station, which usually freezes in winter.

The most reliable website is https://www.windy.com and here again is the problem of my lack of programming, otherwise it would be easy because the page has so many different display conditions.

So to conclude! If we were more interested in this issue, we could forget what an online service is called, when, for example, you hire someone from Vietnam and they write you a code for €10.