mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Fix zamg station check (#49367)
This commit is contained in:
parent
2976bbbbdd
commit
623baa7964
@ -108,7 +108,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
station_id = config.get(CONF_STATION_ID) or closest_station(
|
station_id = config.get(CONF_STATION_ID) or closest_station(
|
||||||
latitude, longitude, hass.config.config_dir
|
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(
|
_LOGGER.error(
|
||||||
"Configured ZAMG %s (%s) is not a known station",
|
"Configured ZAMG %s (%s) is not a known station",
|
||||||
CONF_STATION_ID,
|
CONF_STATION_ID,
|
||||||
@ -239,9 +239,14 @@ class ZamgData:
|
|||||||
return self.data.get(variable)
|
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():
|
def _get_zamg_stations():
|
||||||
"""Return {CONF_STATION: (lat, lon)} for all stations, for auto-config."""
|
"""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(
|
req = requests.get(
|
||||||
"https://www.zamg.ac.at/cms/en/documents/climate/"
|
"https://www.zamg.ac.at/cms/en/documents/climate/"
|
||||||
"doc_metnetwork/zamg-observation-points",
|
"doc_metnetwork/zamg-observation-points",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user