adding plain text to pollen label
This commit is contained in:
parent
831e4587ac
commit
2647022a7b
1 changed files with 14 additions and 1 deletions
15
main.py
15
main.py
|
@ -39,6 +39,19 @@ def format_date(dt):
|
|||
return dt.strftime("%a %d").lower()
|
||||
|
||||
|
||||
def pollen_desc(index):
|
||||
if index < 2.5:
|
||||
return f"{index} l"
|
||||
elif index < 4.9:
|
||||
return f"{index} l-m"
|
||||
elif index < 7.3:
|
||||
return f"{index} m"
|
||||
elif index < 9.7:
|
||||
return f"{index} m-h"
|
||||
else:
|
||||
return f"{index} h"
|
||||
|
||||
|
||||
def relative_day_to_date(rel_dt):
|
||||
dt = datetime.now()
|
||||
day = timedelta(days=1)
|
||||
|
@ -89,7 +102,7 @@ async def fetch_pollen(zipcode):
|
|||
datetime.fromisoformat(data["ForecastDate"])
|
||||
),
|
||||
"periods": [
|
||||
{"index": d["Index"], "period": relative_day_to_date(d["Type"])}
|
||||
{"index": pollen_desc(d["Index"]), "period": relative_day_to_date(d["Type"])}
|
||||
for d in data["Location"]["periods"]
|
||||
],
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue