I have an automation that turn lights on when its cloudy outside, and I have found that the “SMHI” component have better accuracy in Sweden than Dark Sky.
In order to get just the cloudiness (in %) I have made the following template sensor:
- platform: template
sensors:
smhi_cloudiness:
friendly_name: “SMHI Molntäcke”
value_template: “{{ state_attr(‘weather.smhi_home’, ‘cloudiness’) }}”
It worksgood, but sometimes have noticed some odd behaviour. Now I have finally realized that the SMHI sensor reports “None” instead of “0”…
How do I add in my template above to set “0” if the attribute is “None” else the actual figure?