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
pull/14080/head
c727 2018-04-25 12:37:57 +02:00 committed by Pascal Vizeli
parent f23f9465d3
commit a94864c86f
4 changed files with 3 additions and 39 deletions

View File

@ -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."""

View File

@ -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()

View File

@ -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):

View File

@ -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.')