Now that I can see what is sent out and returned from https://openweathermap.org/api/one-call-api via webhook, thanks @ScruffR for pointing me to the “Events” section of the Particle web console (I can even expand each query to see what was sent and received in terms of data!), I notice that when I publish an event via the web console to trigger a call to the api, the query doesn’t seem to send my parameters despite configuring it to in the “Advanced” settings of the webhook builder. All it sends is the parameter name.
I’m specifically looking for daily rainfall forecast data, a single field in a large JSON object. The api call itself narrows the query to either hour, minute, daily, or current, (daily in my case) but no further. This is where I’ve attempted to add the webhook “Query Parameter” functionality to further refine, however, when I look at console -> events - > logs -> recent and look at the request sent via webhook to the api, it ends with “Rain= HTTP/1.1”, whereas my Query Parameter is {“Rain”: “{{{daily.rain}}}” } - per variable substitution documentation. Shouldn’t it append “Rain=daily.rain”?
Edit: Maybe I should look at using the custom response mustache templates instead?
Showing the definition of your webhook and the event payload that should trigger the webhook would be helpful
BTW, when you talk about “send my parameters” you may also need to clarify what stage of the sending you are refering to.
Your device sends an event to the cloud/webhook, this in turn sends a request to the openweather server, which then sends back the data you requested to the Particle cloud which will then be send the response - according to your response template - back to your device.
So which of the four sending actions are you refering to?
After putting this together, I’m starting to think that I should look into the custom webhook response templates to do the filtering instead of filtering in the query.
the {{{PARTICLE_EVENT_VALUE}}} just holds the city I want to request the data for, but then I have the response template which actually filters the data I want forwarded to my device from the full set of data the request renders.
This is how my response template looks
I like this approach better. I mean, using C to parse variable length arrays full of unpredictable fields is fun and all, but this seems cleaner and simpler. Now just have to test out the template syntax until I start seeing the right values.
The docs have this as the only example of a response template, how’d you come up with your format?
In terms of what I’m doing, I’m using an argon controlled relay featherwing to interrupt an existing irrigation system watering cycle when the forecast calls for rain of an amount equal to or greater than the average daily water a vegetable garden needs. Could I buy a newer internet enabled controller for the system? Probably, but then I wouldn’t learn to parse JSON or to work with APIs and webhooks.
Interestingly, once I add a response template I no longer see the event go out and come back in the “Events” section of the console, even though it does pop up a notice that says “Event Published”. It does show up in the logs of the webhook itself, however, so I know it’s still working.
Now to set up the device to print the values received to see how the response template is behaving. Thanks for the head-start on the format.