Hello friends, I'm using WeatherAPI to reach out and retrieve some data from a specific location.
Amongst this data being retrieved, is wind.degree.
The value for wind.degree is returned as a integer from 1-360.
I'm trying to convert this integer into a direction (North) upon the given value.
I'm trying to make this happen with an "IF" statement and a compare statement.
something along the lines like,
If (msg.payload.wind.deg.) >=346 <=15
(msg.payload.wind.deg) = "N"
H, welcome to the forum.
Why have you dived straight into a function node?
You can do with with the built in no-code nodes - in particular, the switch node.
if you MUST, then the JS would be along the lines of:
if (msg.payload.wind.deg >=346 || msg.payload.wind.deg <=15) {
msg.payload.wind.dir = "N"
} else if (msg.payload.wind.deg > 15 && msg.payload.wind.deg <=30) {
msg.payload.wind.dir = "NNE"
} else {
// etc etc
}
return msg;
1 Like
Why do you have a period after deg
?
That was a typo, Apologies.
system
Closed
7
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.