Fix zamg station check (#49367)

This commit is contained in:
Martin 2021-05-20 09:25:31 +02:00 committed by GitHub
parent 2976bbbbdd
commit 623baa7964
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -108,7 +108,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
station_id = config.get(CONF_STATION_ID) or closest_station(
latitude, longitude, hass.config.config_dir
)
if station_id not in zamg_stations(hass.config.config_dir):
if station_id not in _get_ogd_stations():
_LOGGER.error(
"Configured ZAMG %s (%s) is not a known station",
CONF_STATION_ID,
@ -239,9 +239,14 @@ class ZamgData:
return self.data.get(variable)
def _get_ogd_stations():
"""Return all stations in the OGD dataset."""
return {r["Station"] for r in ZamgData.current_observations()}
def _get_zamg_stations():
"""Return {CONF_STATION: (lat, lon)} for all stations, for auto-config."""
capital_stations = {r["Station"] for r in ZamgData.current_observations()}
capital_stations = _get_ogd_stations()
req = requests.get(
"https://www.zamg.ac.at/cms/en/documents/climate/"
"doc_metnetwork/zamg-observation-points",