# Help with why this isn't working

**URL:** <https://discourse.nodered.org/t/help-with-why-this-isnt-working/67504>\
**Category:** General\
**Created:** [9 September 2022 07:01 UTC](https://discourse.nodered.org/t/help-with-why-this-isnt-working/67504 "2022-09-09T07:01:26Z")\
**Posts on this page:** 10\
**Page:** 2

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [9 September 2022 09:10 UTC](https://discourse.nodered.org/t/help-with-why-this-isnt-working/67504/21 "2022-09-09T09:10:40Z")

</div>

> [@Trying\_to\_learn](#):
>
> What happens if parts of the message (eg: `let low = msg.base.wind.light;`) doesn't exist?

You should get the error:  
 ![Screen Shot 2022-09-09 at 5.09.28 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/f/5f601baa6df3f22bffda8776800584038be08c63.png)  
That I see in testing your example. And that would prevent a msg from leaving the function at the

```auto
return msg

```

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [9 September 2022 09:12 UTC](https://discourse.nodered.org/t/help-with-why-this-isnt-working/67504/22 "2022-09-09T09:12:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [9 September 2022 09:13 UTC](https://discourse.nodered.org/t/help-with-why-this-isnt-working/67504/23 "2022-09-09T09:13:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [9 September 2022 09:16 UTC](https://discourse.nodered.org/t/help-with-why-this-isnt-working/67504/24 "2022-09-09T09:16:26Z")

</div>

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.  
☹

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [9 September 2022 09:23 UTC](https://discourse.nodered.org/t/help-with-why-this-isnt-working/67504/25 "2022-09-09T09:23:49Z")

</div>

# **(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.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [9 September 2022 09:33 UTC](https://discourse.nodered.org/t/help-with-why-this-isnt-working/67504/26 "2022-09-09T09:33:41Z")

</div>

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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/a/7a6e141b7c5a161d7f1195d67787ca2e9f4cfe45.png)

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [9 September 2022 09:35 UTC](https://discourse.nodered.org/t/help-with-why-this-isnt-working/67504/27 "2022-09-09T09:35:53Z")

</div>

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:

```auto
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`?

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [9 September 2022 11:29 UTC](https://discourse.nodered.org/t/help-with-why-this-isnt-working/67504/28 "2022-09-09T11:29:25Z")

</div>

If you wanted to be really technical, you could take the wind.speed you get from OpenWeather...  
 ![wind_speed](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/0/50fb56ae4533fb88235a199014b47040e734ea8e.png)  
Then convert the value to mph or km/h and do a table lookup using the Beaufort scale.  
 ![beaufort_scale](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/8/c8506975d812c11ff271a2970a40fe9227d2de3f.png)  
Using numeric values might make your` If/If Else` construct a bit easier to follow.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [9 September 2022 21:07 UTC](https://discourse.nodered.org/t/help-with-why-this-isnt-working/67504/29 "2022-09-09T21:07:55Z")

</div>

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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/e/ee2e8b52583f0ba459ba0375c38ba6e841a733d3.png)

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.

```auto
[{"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"]]}]

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [23 September 2022 21:08 UTC](https://discourse.nodered.org/t/help-with-why-this-isnt-working/67504/30 "2022-09-23T21:08:54Z")

</div>

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

[Previous page](https://discourse.nodered.org/t/help-with-why-this-isnt-working/67504.md?page=1)
