trying to template the icon of a tab in CCH, I use this:
- tab:
'weer_klimaat':
icon: >
var weer = entity['weather.woensdrecht'].state;
'mdi:weather-' + weer;
based on the Buienradar weather integration. This should work on all conditions, except for the partlycloudy as it is configured in https://github.com/home-assistant/home-assistant/blob/b867e3314b670acd90826c2a27cf844b6495fbec/homeassistant/components/buienradar/weather.py
is this an error, and should we file an issue? all conditions (except for ‘exceptional’) match the mdi icons except the partlycloudy
which would ideally be partly-cloudy
It isn’t too hard to create a template but it might be better to correct the condition in the integration…
‘partlycloudy’ is the supported state for all weather integrations in the backend. You cannot just change this integration without also changing all the others. Furthermore, the conversion between backend state to icon type is done in the frontend I think. Therefore, you’d also have to change the logic in the front end. This would be such a large breaking change for such an edge case, that I doubt it would be accepted.
You could easily create a template sensor that has an if statement for ‘partlycloudy’ and converts it to partly-cloudy, then use that template sensor state here.
yea, I fear you might be right.
using the above until it fails, and have this as backup:
weather_dark_sky_icon:
friendly_name_template: >
{{states('sensor.weather_dark_sky_icon').split('weather')[1]|replace('-',' ')|title}}
value_template: >
{% set mapper =
{'clear-day': 'sunny',
'clear-night': 'night',
'sunny': 'sunny',
'rain': 'rainy',
'snow': 'snowy',
'sleet': 'snowy-rainy',
'wind': 'windy',
'fog': 'fog',
'cloudy': 'cloudy',
'partlycloudy': 'partlycloudy',
'partly-cloudy-day': 'partlycloudy',
'partly-cloudy-night': 'night-partly-cloudy',
'hail': 'hail',
'thunderstorm': 'lightning',
'tornado': 'hurricane'} %}
{% set state = states('weather.home_darksky') %}
{% set weather = mapper[state] if state in mapper else 'sunny-alert' %}
mdi:weather-{{weather}}
icon_template: >
{{states('sensor.weather_dark_sky_icon')}}
Ive checked the integrations for their respective condition names and mappings to the icon, but not sure I’ve covered all yet.
still think its an error going back to the beginnings of HA, and optimally should be reverted…
but, one has to choose his battles
It isnt up to individual integrations. https://developers.home-assistant.io/docs/en/entity_weather.html
I recommend your more complex approach.