For those who prefer working with Node-RED, here’s a simple flow fragment that uses the Google Pollen API to a render a human-readable pollen forecast.
[{"id":"81c628171945c3f0","type":"function","z":"b187d28b.8b454","name":"Check All Pollens and Format","func":"// Uses Google Pollen API\n\nvar pollen_details = \"\";\n\n// Get pollen levels for each type\nvar tree_level = msg.payload.dailyInfo[0].pollenTypeInfo[1].indexInfo.category;\nvar grass_level = msg.payload.dailyInfo[0].pollenTypeInfo[0].indexInfo.category;\n\n\n\n// Create wordsmithed message\nif (grass_level == tree_level) {\n pollen_details = tree_level + \" for all pollens\";\n} else {\n if (grass_level == tree_level) {\n pollen_details = tree_level + \" for tree and grass pollens.\";\n } else {\n pollen_details = tree_level + \" for tree and \" + grass_level + \" for grass pollens.\";\n }\n}\n\nmsg.payload = \"The pollen risk is \" + pollen_details;\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":770,"y":3120,"wires":[["f5a09b60e89a2a5a"]]},{"id":"895974f9e8d2409f","type":"inject","z":"b187d28b.8b454","name":"2 hours","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"7200","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":3120,"wires":[["da8aa7d838563611"]]},{"id":"da8aa7d838563611","type":"http request","z":"b187d28b.8b454","name":"Google Pollen API","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://pollen.googleapis.com/v1/forecast:lookup?key=[API_KEY]&location.longitude=-121.91&location.latitude=46.20&plantsDescription=false&days=1","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":410,"y":3120,"wires":[["81c628171945c3f0"]]},{"id":"f5a09b60e89a2a5a","type":"ha-sensor","z":"b187d28b.8b454","name":"Pollen Forecast","entityConfig":"db2a945f34d4f509","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":1080,"y":3120,"wires":[[]],"server":""},{"id":"db2a945f34d4f509","type":"ha-entity-config","server":"","deviceConfig":"","name":"sensor config for Pollen Forecast","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"weather.pollen_forecast"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""}],"resend":true,"debugEnabled":false}]
The Google Pollen API returns a lot of data, but I chose to report only tree and grass data on my dashboard.
If you want to see what other data you can access, just add a Debug node set to “Complete message object” to the output of the “Google Pollen API” node.