Help with why this isn't working

You should get the error:
Screen Shot 2022-09-09 at 5.09.28 AM
That I see in testing your example. And that would prevent a msg from leaving the function at the

return msg

No ; - yes?

But.... if I send a correctly structured message, things work.

I have to ask.

Oh, on the errors.

I am not seeing any.

That's why I'm asking for help to understand what is going on.

it seems that you don't always get the same data from Openweateremap' for each weather condition. You will have to take that in account in your flows and that seems to be your problem here.

Yes. I agree.

I wrote that code and had expansion for other stuff there but never used it.
SNOW is just not going to happen here.

thunderstorm is a bit rare.

Today they happened but I got the wrong icon. Or: not the one I expected.

So I went off on a journey to trace what is going on in the subflow and the messages are stopping when they get to the function node - and I no not get any errors.
So it lead me to ask.

To recap: Because some of the lines aren't defined the code stops there and so it doesn't give an ouptut.

Strange I am not getting an error.

Ok, weird.

I have error capturing code and it doesn't seem to be reporting these errors.

SORRY.

That is (now) a whole new can of worms I need to look at.
:frowning:

(expletives!)

Well, that was fun.

Some of my link nodes lost their links and so errors weren't being reported.
(and so I wasn't seeing the errors because of the error node and the capture routines)

Ok.

Sorry to all.

My fault.

Sorry - a bit late to the party.
You may have corrected this, but it looks as if you have the same test repeated twice.

if (wind > strong )

wind_strength

1 Like

Thanks.

I'll check that also. It is (probably) me making another of my many mistakes.

One would set wind strength as STRONG and the other as LIGHT, but I probably messed up how I did it.

This is better I think:

if (wind < low)
{
    flow.set("windstrength","NO");
    node.status({text:"NO"});
} else
if (wind < strong)
{
    flow.set("windstrength","LIGHT");
    node.status({text:"LIGHT"});
} else
if (wind > strong)
{
    flow.set("windstrength","STRONG");
    node.status({text:"STRONG"});
}

So if the wind is less than the low value, wind is set to NO.
If it is less than strong the value is set to LIGHT
If it is greater than strong` the value is set to STRONG.

Is that the correct structure with the if then and else?

If you wanted to be really technical, you could take the wind.speed you get from OpenWeather...
wind_speed
Then convert the value to mph or km/h and do a table lookup using the Beaufort scale.
beaufort_scale
Using numeric values might make your If/If Else construct a bit easier to follow.

Thanks.

That part of the code is for icon selection.

If there is no wind or the value is less than a nominal value the icon shows no wind.
If it is above said value and less than another, a different icon is used.
And if it is above the other value, a third icon is used.

It isn't meant to be that accurate.
What you showed is basically what I did but to more details/levels.

This is an example - but it isn't a good example for the wind part.

Screenshot from 2022-09-10 07-03-12

This is an extract from the subflow that uses the windstrength vaule.
Probably not the best but this was written a while ago and it may be able to be done differently.

[{"id":"6abc41b9.d7ed4","type":"switch","z":"10fde8b5.a8a82f","name":"Night / Day","property":"now","propertyType":"msg","rules":[{"t":"lt","v":"payload.sunrise","vt":"msg"},{"t":"gt","v":"payload.sunset","vt":"msg"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":1870,"y":770,"wires":[["16427981.3398f6"],["16427981.3398f6"],["56758975.26f77"]]},{"id":"56758975.26f77","type":"change","z":"10fde8b5.a8a82f","name":"Day rain","rules":[{"t":"set","p":"payload","pt":"msg","to":"wi wi-day-rain","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":2030,"y":790,"wires":[["1e77d751.41fac9"]]},{"id":"16427981.3398f6","type":"change","z":"10fde8b5.a8a82f","name":"Night rain","rules":[{"t":"set","p":"payload","pt":"msg","to":"wi wi-night-alt-rain","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":2030,"y":750,"wires":[["1e77d751.41fac9"]]},{"id":"3489e3d8.8c2474","type":"switch","z":"10fde8b5.a8a82f","name":"Wind strength","property":"$parent.windstrength","propertyType":"flow","rules":[{"t":"eq","v":"NO","vt":"str"},{"t":"eq","v":"LIGHT","vt":"str"},{"t":"eq","v":"STRONG","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":1550,"y":780,"wires":[["6abc41b9.d7ed4","98a4215b.6a1ef"],["8bbff73b.e2e4a"],[]]},{"id":"8bbff73b.e2e4a","type":"change","z":"10fde8b5.a8a82f","name":"Day rain wind","rules":[{"t":"set","p":"payload","pt":"msg","to":"wi wi-day-rain-wind","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":2050,"y":860,"wires":[["1e77d751.41fac9"]]}]

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.