Skip to content

Commit

Permalink
Revert "Add language to dark sky weather component" (#15142)
Browse files Browse the repository at this point in the history
* Revert "Fix #14919. Should throw exception when camera stream closed by frontend (#15028)"

This reverts commit 508d045.

* Revert "Fix pylintrc section order and option placements (#15120)"

This reverts commit dbae410.

* Revert "Add storage helper and migrate config entries (#15045)"

This reverts commit ae51dc0.

* Revert "Add language to dark sky weather component (#15130)"

This reverts commit 672a3c7.
  • Loading branch information
pvizeli authored Jun 25, 2018
1 parent 508d045 commit 42ba2a6
Showing 1 changed file with 6 additions and 22 deletions.
28 changes: 6 additions & 22 deletions homeassistant/components/weather/darksky.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,16 @@

ATTRIBUTION = "Powered by Dark Sky"

# Language Supported Codes
LANGUAGE_CODES = [
'ar', 'az', 'be', 'bg', 'bs', 'ca',
'cs', 'da', 'de', 'el', 'en', 'es',
'et', 'fi', 'fr', 'hr', 'hu', 'id',
'is', 'it', 'ja', 'ka', 'kw', 'nb',
'nl', 'pl', 'pt', 'ro', 'ru', 'sk',
'sl', 'sr', 'sv', 'tet', 'tr', 'uk',
'x-pig-latin', 'zh', 'zh-tw',
]

CONF_UNITS = 'units'
CONF_LANGUAGE = 'language'

DEFAULT_NAME = 'Dark Sky'
DEFAULT_LANGUAGE = 'en'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_API_KEY): cv.string,
vol.Optional(CONF_LATITUDE): cv.latitude,
vol.Optional(CONF_LONGITUDE): cv.longitude,
vol.Optional(CONF_UNITS): vol.In(['auto', 'si', 'us', 'ca', 'uk', 'uk2']),
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_LANGUAGE,
default=DEFAULT_LANGUAGE): vol.In(LANGUAGE_CODES),
})

MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=3)
Expand All @@ -59,15 +44,15 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up the Dark Sky weather."""
latitude = config.get(CONF_LATITUDE, hass.config.latitude)
longitude = config.get(CONF_LONGITUDE, hass.config.longitude)
name = config[CONF_NAME]
lang = config[CONF_LANGUAGE]
api_key = config[CONF_API_KEY]
name = config.get(CONF_NAME)

units = config.get(CONF_UNITS)
if not units:
units = 'si' if hass.config.units.is_metric else 'us'

dark_sky = DarkSkyData(api_key, latitude, longitude, units, lang)
dark_sky = DarkSkyData(
config.get(CONF_API_KEY), latitude, longitude, units)

add_devices([DarkSkyWeather(name, dark_sky)], True)


Expand Down Expand Up @@ -147,13 +132,12 @@ def update(self):
class DarkSkyData(object):
"""Get the latest data from Dark Sky."""

def __init__(self, api_key, latitude, longitude, units, lang):
def __init__(self, api_key, latitude, longitude, units):
"""Initialize the data object."""
self._api_key = api_key
self.latitude = latitude
self.longitude = longitude
self.requested_units = units
self.language = lang

self.data = None
self.currently = None
Expand All @@ -168,7 +152,7 @@ def update(self):
try:
self.data = forecastio.load_forecast(
self._api_key, self.latitude, self.longitude,
units=self.requested_units, lang=self.language)
units=self.requested_units)
self.currently = self.data.currently()
self.hourly = self.data.hourly()
self.daily = self.data.daily()
Expand Down

0 comments on commit 42ba2a6

Please sign in to comment.