diff --git a/apps/pollencount/manifest.yaml b/apps/pollencount/manifest.yaml index 759dc4905..e2fcd08bb 100644 --- a/apps/pollencount/manifest.yaml +++ b/apps/pollencount/manifest.yaml @@ -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 @@ -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' diff --git a/apps/pollencount/pollen_count.star b/apps/pollencount/pollen_count.star index 6489fce3a..a5737467e 100644 --- a/apps/pollencount/pollen_count.star +++ b/apps/pollencount/pollen_count.star @@ -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...") @@ -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: @@ -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 @@ -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", + ), ], )