Subflows. Inputs and outputs not matching between machines

I have written a subflow.

It works - as best I can say - on all but one machine.

All machines send back their temperature reading, a PING reply and that indicates they are working.

So: I'm guessing I have the sub-flow wired in correctly.
One for each machine.

There are lots of inputs to it and a few outputs.
The one of interest is this message - for machine#1

{"payload":"<font color = \"lime\" i class=\"fa fa-bullseye fa-2x\"></i>","host":"83","topic":"BedPi/On-line","device_ID":"BedPi","background":"lime","_msgid":"a2c057de.049818"}

Great! Things work. You can clearly see the lime part of the message. AND the rest of the bigger message.

Machine #2's output form the sub-flow is this:

<font color = "lime" i class="fa fa-bullseye fa-2x"></i>

Then straight after that message is this one:

<font color = "yellow" i class="fa fa-bullseye fa-2x"></i>

Now, putting aside any syntactical errors, why it is that for machine #1 I get that lovely bigger message.
Machine #2 is that short message?
And why is it putting out two, rather than one?

All other machines work nicely.

The inputs to the node for machine #1 is:

{"topic":"TEMPERATURE/BedPi","payload":"49.8","qos":2,"retain":false,"_msgid":"574a0cc2.c74914"}
{"topic":"192.168.0.83","host":"192.168.0.83","_msgid":"a2c057de.049818","_topic":"BedPi","payload":"On-line"}

Machine #2's inputs are:

{"topic":"TEMPERATURE/EyeSpyPi","payload":"58.4","qos":2,"retain":false,"_msgid":"3bc0ba7d.c3b4a6"}
{"topic":"192.168.0.89","host":"192.168.0.89","_msgid":"a2c057de.049818","_topic":"EyeSpyPi","payload":"On-line"}

So given how a sub-flow is supposed to work, I am missing something why machine #1 gets the correct output while machine #2 doesn't.

Hi Andrew,

I'm going to point you back to a few previous posts I made recently in other threads. I haven't looked yet at what might be the issue here, but try to solve those first as I see the same problems are seeping into this post/code again. Afterwards I'm willing to come back to this problem.

Start here, then move onwards to the link in there. Go back to that thread and try to understand why it failed there. If you can't figure that out, check the links and instructions from that post. If still not, ask for help there. I'm willing to explain it again, but the same error from that thread in June is now again slipping into your recent flows. Better to have that one solved once and for all, then figure out what is going wrong here and in other flows.

3 Likes

Yeah, I am getting that there was a problem with how I was constructing the HTML packets.

the <font>, and <i> things.

I had bad starting examples and that has made/grown on parts of the flows because I didn't know of the problem when I did it.

And that I need to keep the nesting of what is started and ended correct.
So if I have.....
<font> <i> code

I need to close it with
</i> </font> and not </font> </i>

Now,

I won't argue with you on that, but my take is that there are syntactical (formatting?) errors in how things are declared.
It was said (by my recollection) that because different people wrote the two packages, how they are used is allowed to be different.

I get that.

But I was also tripped with - I think - it was the button node and the icon.
I can/could go back and re-read the thread.

For reasons I don't really feel comfortable discussing, it is mostly meaningless.
That isn't an insult to who wrote them. I can't contextualise it.

It would be great if I could. It would be even better if I could remember the actual problem.
Other than the idea I have had the problem and it was resolved is about the limit of what I remember.

Something is wrong with me. I get that. I have to live with this all day, every day.

I am guessing I am making the same error over and over because I am still not getting the bigger picture. Sure than needs effort by me to learn.

But when I am not seeing something I fully understand I don't remember it the way I should.
I'll go back and again read it. But I am not seeing . . . . . . something.

Thanks.

1 Like

(not wanting to babble on)

Ok, reading that link and sub-link to Button icons example I already am . . . confused with the flow.

In the function node:
var state = context.state || false;

I went through a horrible learning curve with context stuff.

I thought it should be:
var state = context.get("state") || false;

I shall have to let that slip as a slicker way to do it.
But just saying when I see things like that, it makes a smooth journey less smooth.

I'm going to correct you immediately. The syntax was not different because of the different packages, the <font i> you used in your code is incorrect everywhere.

I understand that, I know what it's like to live with a short term memory where most of it is lost after 3-4 hours. Meaning I write things down all the time just to not forget it, and making notes everywhere so I can keep following along.

I'm willing to explain these things in different ways, until you understand it. And I mean that quite literally. My lack of effort won't be a problem :slight_smile:

My first suggestion would be to come up with a structure for keeping notes, to keep track of things. If you can write on paper, using paper is a good choice, with coloured sticky notes to keep track of topics. I used that in the past, it worked well. Now I have a notebook that's about an inch thick and more than half of the pages are written. I don't know what is where, and every time I need something I have to keep browsing through that notebook. Not the best solution, and sticky notes or colouring might be better to keep track of it.
If it would be better to type things out, type things out. Both are good solutions.

I understand, keep the context variables for what it is for now. What I would advise you is to go back to the very beginnings for a bit. Make notes while doing so, if possible.

The post I was referring to is specifically about syntax in HTML. Mozilla has a good beginner's guide for writing HTML. I'd suggest to start reading there, and making notes. If there's anything you don't understand or feel like it is illogical, come back here and ask. If you prefer to do that in DM I'm okay with that too.

Javascript and the use of || false when assigning things is one for a later date, same for context variables. Start with the absolute basics of HTML. I'm willing to help you through this stage, even if that stage lasts years if not more. Even if that means it won't happen at all.

And that's okay. We all have things we're dealing with. For me it means I've to come up with extremely creative on one hand, and horrible on the other hand to evade using topics that I know will cause me flashbacks or spending a day lying on the floor crying. I even encounter those when dealing with my flows, especially there sometimes. I have an IT study background, but I can hardly use any of it because of that. Things I mastered before I'm still able to use, as well as some things I learned afterwards. But don't let me do relational databases or I'll get panic attacks.

So yeah, in summary I'm willing to help you. I'm about 7-9 hours west of you, but timezones can be dealt with :slight_smile: Try reading the Mozilla guide from this post, and if you read anything that makes you frown in there, write it down. Then ask me here, or in DM. I'll try to explain it in a few different ways, or explain how you can around those. Some of those will be about logic that makes not enough sense, and you'll have to learn to accept it's not as logical and move on. That's not an easy feat, but something to write down and just type over from your notes every time you have to use it. After all, that's how I do CSS :slight_smile: We're starting simple, and reference it back to your flows every time when needed, okay.

1 Like

Thanks.

Yes, I am going to have to get time one day to go through my flows and fix all those bad things with the icons, colours etc.

I'm guessing that the line (working) should be:
{"payload":"<font color = \"lime\" i class=\"fa fa-bullseye fa-2x\"></i>,</font>" (and the rest)

Taking notes.
Yeah. Nostalgia. I was good at taking notes at one stage in my life.
I have a heap of books ready for notes.
For some reason I have a problem with categorising them nowadays.
I have done a lot of CCNA study and have notes, but they seriously make a chicken coop look organised.

I have basic truths written down which show me a structure. The variables are noted and explained.

Anyway, so back to this:
There is NR, JS, HTML, CSS3 and I am sure more in the equation.
I could look when I joined this group, or even the google one.
That is the length of time I have done anything with these languages.
So that is about. . . 4% of my life I think.
Then there is getting my head around RPI (debian) and Ubuntu on the NUCs.
Why I didn't get Debian on the NUC is a mystery to me. But it is a bit late now.
All part of the fun.
As well as that I am trying to learn Fusion 360 CAD.
(Sorry, I'll get off the soap box)

I'm not getting things because I don't . . . understanding something about it.
I can quite happily sit down for 6 hours writing NR code and flows.
When they work things are great.
(I also do that with F360 too, but again: I'll get off the soap box)
Alas there is a lot of code written with the wrong base of information and I have about 10 machines I need to go back to and update the flow styles to get the bad stuff out.

That is what I am sort of doing now, but am getting stuck with other things in the mean time.

I can write a whole lot of stuff down as "correct" but then a week later find out it is wrong (like the <font> thing.
So I need a big/good round if writing it the better way to un-learn the older/wrong way.

Again: I don't mind. That's how it is. Complaining won't change a thing. Other than waste time. Which is something I really don't like doing: wasting time. Anyone's.

So I really hate myself asking all these questions and the STUPID mistakes I make. But I get that this is part of learning.

So: back to the notes:
I can't find a definitive truth (or base line) on something from which I can build.
I get misinformation and can only get so far before it all falls over.

I think I have said enough for this. I am detecting repeats, so I am stopping typing.

{"payload":"<font color='lime'><i class='fa fa-bullseye fa-2x'></i>,</font>"

Not sure about that , between </i>,</font> but I guess you want it.

1 Like

I am not sure if that is just my stupidity or the fact it is 22:16 and I have been up since 06:15.

Thanks.

Fixing it for you:
{"payload":"<font color = \"lime\"><i class=\"fa fa-bullseye fa-2x\"></i>,</font>" (and the rest)
Very similar, but the missing >< between the lime and i

(As I said, not sure if that is just being awake for so long....)

I think the extra , which @bakman2 mentioned is also a problem.

B u t

Something is going on.

(I've backed up the flow)

But now with the change done, this is what I am seeing:

I'm working on it.

The colour.....

\"lime\"
Why the \?
And why are they "splitting" the "'s?

It is \" and \" which *breaks the rule about splitting things.

Ok, I found that > bug. My bad.

Interestingly now all the machines are showing yellow indicators rather than green.

So ok, I have got rid of one bug, but now found the next.

Hmmmm.

See below link, particularly the bits about escape characters.

Yes, if this was just HTML you wouldn’t have to deal with \. But this is using HTML code inside a JavaScript string in the payload. For JavaScript strings you’ve to wrap the entire thing in quotes. It will see it as string from the first quote until the second. The lime is a string value in HTML, and in HTML you have to wrap attributes in double quotes. If your JavaScript string sees that double quote for the attribute it will consider it the end of the string. So you will have to “escape” the quotes in your HTML. You do that by putting a backslash before it.

Wow, this (maybe) seems to have thrown a cat among the pidgins.

I used to have all these blocks doing things and replaced them with a sub-flow.

Good, because if I found a bug in the code, I would only need to update the sub-flow, rather than 10 sets of code.

So, fixing the payload structure problem has now shown me a whole set of new problems.
Alas being a sub-flow I can't debug it as easily.

All being good, the machines should have green (lime) bulls eye icons.

Now they all have yellow triangles. Indicating no telemetry (temperature) received from the device.

But I know that it is as they were green (lime) before.

Ok. So, @bakman2 mentioned an extra , in the line.

(reply 6)

I can 't see how it would cause a problem with what is happening, but I am a bit suspicious it is something which could be a problem.

Ok, forget that.

I see the "problem" it causes. It was the extraneous > I mentioned above.

Now to work out why it isn't acknowledging the machine being online.

the html you used was:

<font i></i></font>
it should be:
<font><i></i></font>

and you could shorten it:
<i class='fa fa-bullseye fa-2x' style='color:lime' />
ie. dropping the font tag.

1 Like

I shall apply that to the sub-flow then call it a night.

I think I am not really doing anyone justice with how I am thinking just now.

1 Like

No you cannot shorten it if you want it to work in the dashboard. This is because angular strips off style tags.

2 Likes

Thanks. @knolleary

I am sure that saved me a lot of grief.

ah got it.

Ok, this is weird. (How many times have I said that?)

Last night (local) I was going through the motion of getting the flows up to spec with syntax.

I have a particular sub-flow which was guilty of having a node in it which had SIX instances where it was wrong.

In this thread of 19 posts, I have (supposedly - and I'll get back to that specifically shortly) been shown the correct syntax.

I applied it to the six lines and deployed it.

I was getting errors like show in the screen shots.

After a lot of attempts I decided to call it a night and left well enough alone.

This morning I thought: before I go out I will get the critical part of the flow, put it on my NUC (more power) and then this afternoon I can look at why it isn't working.

Low and behold when I load the browser today/this morning: It is all working.

So: unless the gremlins have been doing good things: why was it doing the wrong thing last night when I was deploying the flows and yet this morning it is working fine. (Rhetorical I guess)

Yeah, ok, I will have to triple check by turning on other machines and seeing what happens.
But that then leads back to the original problem:

Given I do/did have some mistakes on msg.payload structure, it is in a sub-flow.
All machines send back the same formatted packets/messages.
So if one is wrong, they are all wrong.

Why would/could it be that all but one were working last night?