diff --git a/homeassistant/components/sensor/wunderground.py b/homeassistant/components/sensor/wunderground.py index 82bb3d3b245..3194afbe94e 100644 --- a/homeassistant/components/sensor/wunderground.py +++ b/homeassistant/components/sensor/wunderground.py @@ -7,6 +7,7 @@ https://home-assistant.io/components/sensor.wunderground/ from datetime import timedelta import logging +import re import requests import voluptuous as vol @@ -172,7 +173,8 @@ class WUndergroundSensor(Entity): def entity_picture(self): """Return the entity picture.""" if self._condition == 'weather': - return self.rest.data['icon_url'] + url = self.rest.data['icon_url'] + return re.sub(r'^http://', 'https://', url, flags=re.IGNORECASE) @property def unit_of_measurement(self): diff --git a/tests/components/sensor/test_wunderground.py b/tests/components/sensor/test_wunderground.py index cde94558866..05c7fc93921 100644 --- a/tests/components/sensor/test_wunderground.py +++ b/tests/components/sensor/test_wunderground.py @@ -25,7 +25,7 @@ VALID_CONFIG = { FEELS_LIKE = '40' WEATHER = 'Clear' -ICON_URL = 'http://icons.wxug.com/i/c/k/clear.gif' +HTTPS_ICON_URL = 'https://icons.wxug.com/i/c/k/clear.gif' ALERT_MESSAGE = 'This is a test alert message' @@ -61,7 +61,7 @@ def mocked_requests_get(*args, **kwargs): }, "feelslike_c": FEELS_LIKE, "weather": WEATHER, - "icon_url": ICON_URL, + "icon_url": 'http://icons.wxug.com/i/c/k/clear.gif', "display_location": { "city": "Holly Springs", "country": "US", @@ -150,7 +150,7 @@ class TestWundergroundSetup(unittest.TestCase): device.update() self.assertTrue(str(device.name).startswith('PWS_')) if device.name == 'PWS_weather': - self.assertEqual(ICON_URL, device.entity_picture) + self.assertEqual(HTTPS_ICON_URL, device.entity_picture) self.assertEqual(WEATHER, device.state) self.assertIsNone(device.unit_of_measurement) elif device.name == 'PWS_alerts':