Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/pollencount/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
id: pollen-count
name: Pollen Count
summary: Pollen count for your area
desc: Displays a pollen count for your area. Enter your location for updates every 12 hours on the current conditions in your town, as well as which types of pollen are in the air today. Get your Secret key by creating a developer account on tomorrow.io.
desc: Displays a pollen count for your area. Enter your location for updates every 12 hours on the current conditions in your town, as well as which types of pollen are in the air today. Requires a Google Maps Platform API key with the Pollen API enabled.
author: Nicole Brooks
fileName: pollen_count.star
packageName: pollencount
Expand All @@ -13,4 +13,4 @@ tags:
- lifestyle
- utility
published: '2022-05-05T11:29:06Z'
updated: '2026-06-02T02:30:50Z'
updated: '2026-07-19T23:48:39Z'
34 changes: 34 additions & 0 deletions apps/pollencount/pollen_count.star
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ COLORS = {
}
DEFAULT_TIMEZONE = "America/New_York"
API_URL_BASE = "https://pollen.googleapis.com/v1/forecast:lookup?days=1&location.latitude="
MIN_LEVEL_OPTIONS = [
schema.Option(display = "Always show", value = "0"),
schema.Option(display = "Low", value = "2"),
schema.Option(display = "Moderate", value = "3"),
schema.Option(display = "High", value = "4"),
schema.Option(display = "Very High", value = "5"),
]

def main(config):
print("Initializing Pollen Count...")
Expand All @@ -50,11 +57,16 @@ def main(config):
lng = float(loc.get("lng"))

dev_key = config.str("dev_key", "")
min_level = int(config.get("min_level", "0"))

# make API call and cache result
print("calling API")
todaysCount = getTodaysCount(lat, lng, dev_key)

if shouldHideBelowMinLevel(todaysCount, min_level):
print("Hiding app: all pollen types below minimum level %d" % min_level)
return []

firstMixin = None
secondMixin = None
if "message" in todaysCount:
Expand Down Expand Up @@ -215,6 +227,20 @@ def getTodaysCount(lat, lng, dev_key):

return result

def shouldHideBelowMinLevel(indexes, min_level):
if min_level <= 0:
return False

if "message" in indexes:
return False

# Missing types are out of season and count as 0.
for indexName in ["treeIndex", "grassIndex", "weedIndex"]:
if indexes.get(indexName, 0) >= min_level:
return False

return True

# Get total average of pollen indexes to two decimal points.
def getAverage(indexes):
total = 0
Expand Down Expand Up @@ -337,6 +363,14 @@ def get_schema():
icon = "key",
secret = True,
),
schema.Dropdown(
id = "min_level",
name = "Minimum Level to Show",
desc = "Hide the app when all pollen types are below this level.",
icon = "eyeSlash",
options = MIN_LEVEL_OPTIONS,
default = "0",
),
],
)

Expand Down