Skip to content

Commit

Permalink
Update weather logging
Browse files Browse the repository at this point in the history
  • Loading branch information
theyosh committed Nov 25, 2024
1 parent 2f5e58b commit a4de492
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 0 additions & 2 deletions terrariumEngine.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,11 @@ def load_settings(self):
if "weather_source" in self.settings:
if "" != self.settings["weather_source"]:
try:
start = time.time()
self.weather = terrariumWeather(self.settings["weather_source"], self.units, self.active_language)
except Exception as ex:
weatherLogger.error(f"Failed loading weather data: {ex}")

elif self.weather is not None:
start = time.time()
self.weather.address = self.settings["weather_source"]
# Force an update, due to maybe changing speed units or temperature.... lazy fix... :(
self.weather.update()
Expand Down
5 changes: 3 additions & 2 deletions weather/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def update(self):
self._device["last_update"] is None
or (datetime.now() - self._device["last_update"]).total_seconds() > self.__UPDATE_TIMEOUT
):
logger.debug(f"Loading online weather data from source: {self.address}")
logger.info(f"Loading online weather data from source: {self.address}")

if self._load_data():
# Convert values to the right unit values
Expand All @@ -71,6 +71,7 @@ def update(self):
)

self._device["last_update"] = datetime.now()

else:
logger.error(f"Error loading online weather data! Please check your source address: {self.address}.")

Expand Down Expand Up @@ -109,7 +110,7 @@ def address(self, value):
reload = self.address != str(value).strip(", ")
self._device["address"] = str(value).strip(", ")
if reload:
logger.debug(f"Reloading weather data due to changing weather source to: {self.address}")
logger.info(f"Reloading weather data due to changing weather source to: {self.address}")
self._device["last_update"] = None
self.update()

Expand Down
5 changes: 2 additions & 3 deletions weather/openweathermap_org_weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ def __init__(self, address, unit_values, language):
super().__init__(address, unit_values, language)

def __load_general_data(self):
address = self.address + "&units=metric&lang=" + self._device["language"][0:2]
logger.debug("Loading weather source {}".format(address))
start = time()
address = self.address + "&units=metric&lang=" + self._device["language"][0:2]
data = terrariumUtils.get_remote_data(address)
if data:
self._data["city"] = data["name"]
Expand All @@ -37,7 +36,7 @@ def __load_general_data(self):

address = terrariumUtils.parse_url(self.address.lower())
self.__appid = address["query_params"]["appid"]
logger.info(f"Loaded basic weather data from source {address} in {time()-start:.2f} seconds.")
logger.info(f"Loaded basic weather data from source {self.address.lower()} in {time()-start:.2f} seconds.")

return True

Expand Down

0 comments on commit a4de492

Please sign in to comment.