Skip to content

Commit

Permalink
Allow 6 digit post codes for better location (Fixes #10)
Browse files Browse the repository at this point in the history
  • Loading branch information
izacus committed Oct 12, 2024
1 parent b486545 commit fe9899f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions custom_components/swissweather/meteo.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

CURRENT_CONDITION_URL= 'https://data.geo.admin.ch/ch.meteoschweiz.messwerte-aktuell/VQHA80.csv'

FORECAST_URL= "https://app-prod-ws.meteoswiss-app.ch/v1/plzDetail?plz={}00"
FORECAST_URL= "https://app-prod-ws.meteoswiss-app.ch/v1/plzDetail?plz={:<06d}"
FORECAST_USER_AGENT = "android-31 ch.admin.meteoswiss-2160000"

CONDITION_CLASSES = {
Expand Down Expand Up @@ -270,8 +270,8 @@ def _get_csv_dictionary_for_url(self, url, encoding='utf-8'):

def _get_forecast_json(self, postCode, language):
try:
url = FORECAST_URL.format(postCode)
logger.debug("Requesting forecast data...")
url = FORECAST_URL.format(int(postCode))
logger.debug("Requesting forecast data from %s...", url)
return requests.get(url, headers =
{ "User-Agent": FORECAST_USER_AGENT,
"Accept-Language": language,
Expand Down

0 comments on commit fe9899f

Please sign in to comment.