Sensor weather_icon combining weather integrations

just thought I’d share a template sensor I made, using 2 different weather integrations and their respective special icons.

      weather_icon:
        friendly_name_template: >
          {{states('sensor.weather_icon').split('weather')[1]|replace('-',' ')|title}}
        value_template: >
          {% set mapper_ds =
            {'clear-day': 'sunny',
             'clear-night': 'night',
             'sunny': 'sunny',
             'rain': 'rainy',
             'snow': 'snowy',
             'sleet': 'snowy-rainy',
             'wind': 'windy',
             'fog': 'fog',
             'cloudy': 'cloudy',
             'partlycloudy': 'partly-cloudy',
             'partly-cloudy-day': 'partly-cloudy',
             'partly-cloudy-night': 'night-partly-cloudy',
             'hail': 'hail',
             'thunderstorm': 'lightning',
             'tornado': 'hurricane'} %}
          {% set mapper_br =
            {'pouring': 'pouring',
             'lightning-rainy': 'lightning-rainy',
             'snowy-rainy': 'snowy-rainy'} %}
          {% set dark = states('weather.darksky') %}
          {% set radar = states('weather.buienradar') %}
          {% set weather = mapper_br[radar] if radar in mapper_br else 
                           mapper_ds[dark] if dark in mapper_ds else 'sunny-alert' %}
            mdi:weather-{{weather}}
        icon_template: >
          {{states('sensor.weather_icon')}}

Both integrations have conditions not met in the other (day-night for one rather important distinction, and the pouring, snowy and lightning conditions ) I like to have both in one sensor to display.

I now can eg use this sensor as icon for my CCH tab in the main menu:

46

using:

conditional_styles:
  - template:
      - tab:
          'alarm':
            icon: >
              var alarm = entity['alarm_control_panel.ha_main_alarm'].state;
              if (alarm == 'disarmed') 'mdi:shield-check';
              else if (alarm == 'armed_away') 'mdi:shield-lock';
              else if (alarm == 'armed_custom_bypass') 'mdi:security';
              else if (alarm == 'armed_home') 'mdi:shield-home';
              else if (alarm == 'armed_night') 'mdi:shield-home';
              else if (alarm == 'pending') 'mdi:shield-outline';
              else if (alarm == 'triggered') 'mdi:bell-alert';
              else 'mdi:shield-check';
      - tab:
          'phones_tablets':
            icon: >
              var family = entity['sensor.family_home'].state;
              if (family == '0') 'mdi:account-off';
              else if (family == '1') 'mdi:account';
              else if (family == '2') 'mdi:account-multiple';
              else if (family == '3') 'mdi:account-multiple-check';
              else 'mdi:account-group';
      - tab:
          'weer_klimaat':
            icon: >
              var weer = entity['sensor.weather_icon'].state;
              weer;

cheers!

2 Likes

Probably should move this over to #projects

consider it done!