Folks, I'm confused.
I have my openweather
node and see it's output.
I am interested in the rain
output.
If it isn't raining, I'm stuck how to filter the message.
Example/s:
No rain:
{"_msgid":"02bbdb546cecd8f5","payload":{"id":804,"weather":"Clouds","detail":"overcast clouds","icon":"04d","tempk":288.3,"tempc":15.1,"temp_maxc":15.1,"temp_minc":15.1,"humidity":87,"pressure":1017,"maxtemp":288.3,"mintemp":288.3,"windspeed":0.83,"winddirection":128,"location":"Cooma","sunrise":1677786638,"sunset":1677832851,"clouds":100,"description":"The weather in Cooma at coordinates: -36.2333, 149.1333 is Clouds (overcast clouds)."},"topic":"","icon":"<i class=\"fa fa-refresh fa-spin\"></i>","background":"#333333","font":"red","location":{"lon":149.1333,"lat":-36.2333,"city":"Cooma","country":"AU"},"data":{"coord":{"lon":149.1333,"lat":-36.2333},"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04d"}],"base":"stations","main":{"temp":288.3,"feels_like":288.14,"temp_min":288.3,"temp_max":288.3,"pressure":1017,"humidity":87,"sea_level":1017,"grnd_level":926},"visibility":10000,"wind":{"speed":0.83,"deg":128,"gust":1.36},"clouds":{"all":100},"dt":1677792992,"sys":{"country":"AU","sunrise":1677786638,"sunset":1677832851},"timezone":39600,"id":2170577,"name":"Cooma","cod":200},"time":"2023-03-02T21:36:32.000Z","title":"Current Weather Information","description":"Current weather information at coordinates: -36.2333, 149.1333"}
Rain:
{"_msgid":"400e17eaad85a668","payload":{"id":500,"weather":"Rain","detail":"light rain","icon":"10d","tempk":293.15,"tempc":20,"temp_maxc":21.7,"temp_minc":18.7,"humidity":89,"pressure":1016,"maxtemp":294.87,"mintemp":291.85,"windspeed":3.09,"winddirection":200,"location":"Ashfield","sunrise":1677786271,"sunset":1677832260,"clouds":75,"rain":0.87,"description":"The weather in Ashfield at coordinates: -33.8886, 151.1314 is Rain (light rain)."},"topic":"","location":{"lon":151.1314,"lat":-33.8886,"city":"Ashfield","country":"AU"},"data":{"coord":{"lon":151.1314,"lat":-33.8886},"weather":[{"id":500,"main":"Rain","description":"light rain","icon":"10d"}],"base":"stations","main":{"temp":293.15,"feels_like":293.53,"temp_min":291.85,"temp_max":294.87,"pressure":1016,"humidity":89},"visibility":10000,"wind":{"speed":3.09,"deg":200},"rain":{"1h":0.87},"clouds":{"all":75},"dt":1677792601,"sys":{"type":2,"id":2010638,"country":"AU","sunrise":1677786271,"sunset":1677832260},"timezone":39600,"id":7839683,"name":"Ashfield","cod":200},"time":"2023-03-02T21:30:01.000Z","title":"Current Weather Information","description":"Current weather information at coordinates: -33.8886, 151.1314"}
What I am looking at:
And so you see this rain
property.
Just after the openweather
node I have a switch
node.
(code below)
But that won't work if the rain
property isn't there.
So I have the switch
node set to this:
IS NOT EMPTY
But that doesn't pass the payload if/when it is raining.
Below is the modified code that works now - while it is raining.
But what's going to happen when it isn't raining?
I fear an error
will happen.
The node is basically set to > 0
- to save you importing the node.
(Sorry)
[{"id":"19a82bda1a7ebdf3","type":"switch","z":"05319bbbba06da29","name":"Raining?","property":"data.rain[\"1h\"]","propertyType":"msg","rules":[{"t":"gt","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":655,"y":310,"wires":[["2fdfdb709240ab4e","bbf430450a163bba"]],"l":false}]