From a94864c86f2230ce0aa0c270f6aa7760f5033800 Mon Sep 17 00:00:00 2001 From: c727 Date: Wed, 25 Apr 2018 12:37:57 +0200 Subject: [PATCH] Modify weather components for "new" frontend card (#14076) * Enable weather condition for all forecasts (OWM) * Remove entity_picture from BR * Remove summary texts from Dark Sky * Update test_darksky.py --- .../components/weather/buienradar.py | 9 -------- homeassistant/components/weather/darksky.py | 22 ------------------- .../components/weather/openweathermap.py | 8 +++---- tests/components/weather/test_darksky.py | 3 --- 4 files changed, 3 insertions(+), 39 deletions(-) diff --git a/homeassistant/components/weather/buienradar.py b/homeassistant/components/weather/buienradar.py index a49a1664eec..bf1864a9c0f 100644 --- a/homeassistant/components/weather/buienradar.py +++ b/homeassistant/components/weather/buienradar.py @@ -121,15 +121,6 @@ class BrWeather(WeatherEntity): if conditions: return conditions.get(ccode) - @property - def entity_picture(self): - """Return the entity picture to use in the frontend, if any.""" - from buienradar.buienradar import (IMAGE) - - if self._data and self._data.condition: - return self._data.condition.get(IMAGE, None) - return None - @property def temperature(self): """Return the current temperature.""" diff --git a/homeassistant/components/weather/darksky.py b/homeassistant/components/weather/darksky.py index 52aa8c46046..f0712542ea5 100644 --- a/homeassistant/components/weather/darksky.py +++ b/homeassistant/components/weather/darksky.py @@ -25,9 +25,6 @@ _LOGGER = logging.getLogger(__name__) ATTRIBUTION = "Powered by Dark Sky" -ATTR_DAILY_FORECAST_SUMMARY = 'daily_forecast_summary' -ATTR_HOURLY_FORECAST_SUMMARY = 'hourly_forecast_summary' - CONF_UNITS = 'units' DEFAULT_NAME = 'Dark Sky' @@ -122,25 +119,6 @@ class DarkSkyWeather(WeatherEntity): ATTR_FORECAST_TEMP: entry.d.get('temperature')} for entry in self._ds_hourly.data] - @property - def hourly_forecast_summary(self): - """Return a summary of the hourly forecast.""" - return self._ds_hourly.summary - - @property - def daily_forecast_summary(self): - """Return a summary of the daily forecast.""" - return self._ds_daily.summary - - @property - def device_state_attributes(self): - """Return the state attributes.""" - attrs = { - ATTR_DAILY_FORECAST_SUMMARY: self.daily_forecast_summary, - ATTR_HOURLY_FORECAST_SUMMARY: self.hourly_forecast_summary - } - return attrs - def update(self): """Get the latest data from Dark Sky.""" self._dark_sky.update() diff --git a/homeassistant/components/weather/openweathermap.py b/homeassistant/components/weather/openweathermap.py index c8a1bdf8f68..a8e26d39cb3 100644 --- a/homeassistant/components/weather/openweathermap.py +++ b/homeassistant/components/weather/openweathermap.py @@ -28,7 +28,6 @@ DEFAULT_NAME = 'OpenWeatherMap' MIN_TIME_BETWEEN_FORECAST_UPDATES = timedelta(minutes=30) MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=10) -MIN_OFFSET_BETWEEN_FORECAST_CONDITIONS = 3 CONDITION_CLASSES = { 'cloudy': [804], @@ -144,12 +143,11 @@ class OpenWeatherMapWeather(WeatherEntity): data.append({ ATTR_FORECAST_TIME: entry.get_reference_time('unix') * 1000, ATTR_FORECAST_TEMP: - entry.get_temperature('celsius').get('temp') - }) - if (len(data) - 1) % MIN_OFFSET_BETWEEN_FORECAST_CONDITIONS == 0: - data[len(data) - 1][ATTR_FORECAST_CONDITION] = \ + entry.get_temperature('celsius').get('temp'), + ATTR_FORECAST_CONDITION: [k for k, v in CONDITION_CLASSES.items() if entry.get_weather_code() in v][0] + }) return data def update(self): diff --git a/tests/components/weather/test_darksky.py b/tests/components/weather/test_darksky.py index 787aca2ca17..7faa033e0a8 100644 --- a/tests/components/weather/test_darksky.py +++ b/tests/components/weather/test_darksky.py @@ -49,6 +49,3 @@ class TestDarkSky(unittest.TestCase): state = self.hass.states.get('weather.test') self.assertEqual(state.state, 'Clear') - self.assertEqual(state.attributes['daily_forecast_summary'], - 'No precipitation throughout the week, with ' - 'temperatures falling to 66°F on Thursday.')