Skip to content

Commit

Permalink
Remove Stookalert and update forecast
Browse files Browse the repository at this point in the history
  • Loading branch information
fwestenberg committed Nov 14, 2024
1 parent e098247 commit dacca1a
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 18 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
setup(
name = 'stookwijzer',
packages = ['stookwijzer'],
version = '1.5.0',
version = '1.5.1',
license='MIT',
description = 'Stookwijzer package',
long_description_content_type="text/markdown",
Expand Down
3 changes: 0 additions & 3 deletions stookwijzer/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@ async def main():
await sw.async_update()
print()
print(f"advice: {sw.advice}")
print(f"alert: {sw.alert}")
print(f"windspeed bft: {sw.windspeed_bft}")
print(f"windspeed ms: {sw.windspeed_ms}")
print(f"lki: {sw.lki}")
print()
print(f"forecast_advice: {sw.forecast_advice}")
print()
print(f"forecast_alert: {sw.forecast_alert}")

await session.close()

Expand Down
15 changes: 1 addition & 14 deletions stookwijzer/stookwijzerapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ def advice(self) -> str | None:
"""Return the advice."""
return self._advice

@property
def alert(self) -> bool | None:
"""Return the stookalert."""
return self._alert

@property
def windspeed_bft(self) -> int | None:
"""Return the windspeed in bft."""
Expand All @@ -52,11 +47,6 @@ def forecast_advice(self) -> list:
"""Return the forecast array for advices."""
return self.get_forecast_array(True)

@property
def forecast_alert(self) -> list:
"""Return the forecast array for alerts."""
return self.get_forecast_array(False)

@property
def last_updated(self) -> datetime | None:
"""Get the last updated date."""
Expand Down Expand Up @@ -92,7 +82,6 @@ async def async_update(self) -> None:
advice = self.get_property("advies_0")
if advice:
self._advice = self.get_color(advice)
self._alert = self.get_property("alert_0") == "1"
self._last_updated = datetime.now()

def get_forecast_array(self, advice: bool) -> list:
Expand All @@ -106,7 +95,7 @@ def get_forecast_array(self, advice: bool) -> list:
dt = datetime.strptime(runtime, "%d-%m-%Y %H:%M")
localdt = dt.astimezone(pytz.timezone("Europe/Amsterdam"))

for offset in range(2, 25, 2):
for offset in range(0, 19, 6):
forecast.append(self.get_forecast_at_offset(localdt, offset, advice))

return forecast
Expand All @@ -118,8 +107,6 @@ def get_forecast_at_offset(
dt = {"datetime": (runtime + timedelta(hours=offset)).isoformat()}
forecast = (
{"advice": self.get_color(self.get_property("advies_" + str(offset)))}
if advice
else {"alert": self.get_property("alert_" + str(offset)) == "1"}
)
dt.update(forecast)

Expand Down

0 comments on commit dacca1a

Please sign in to comment.