Flow.context values not being set as expected

I have an inject node set to inject once after xx that goes to a change node.

(the flow)

[{"id":"bd9fe1da.4adb68","type":"inject","z":"e2bd5a4e.5597e8","name":"","topic":"","payload":"Lcl Readings","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":4270,"y":60,"wires":[["2652945e.47481c"]]},{"id":"2652945e.47481c","type":"change","z":"e2bd5a4e.5597e8","name":"setup","rules":[{"t":"set","p":"name","pt":"flow","to":"payload","tot":"msg"},{"t":"set","p":"event_paths","pt":"global","to":"/home/pi/.node-red/public/events/","tot":"str"},{"t":"set","p":"log_paths","pt":"global","to":"/home/pi/.node-red/public/logs/","tot":"str"},{"t":"set","p":"threshold","pt":"flow","to":"6000","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":4430,"y":60,"wires":[[]]}]

Not rocket science.

So what happened?

I got home today (about 16:40) and I saw an LED indicating an NTP problem.

I booted up and looked at the machines. Sure enough there seemed to be a problem.
But they were happening every time the times were compared.
Looking further they were within a few seconds of each other.

The difference (as shown to me) was 5959 or there about. Not more than 6000.

The threshold is set to 6000. So 5959 should be under the threshold.
Looking further I noticed the machine had only just rebooted a few minutes ago.

When I opened the context data and looked at the flow context values. threshold was set to 60.

I did a search for threshold = 60 found nothing. Ok, it wouldn't find that in the change node.
But why/how is/was it set to 60 and not 6000?
All the other things were set.

what has this got to do with an inject node node working ? please use a title to reflect you question.

That is not something we can answer. You have only shared the Inject/Change node. Something else must be setting it to 60 somewhere in your flows.

Ok, I do seem to have missed a vital part.

Ok, I got home, I saw the NTP problem signal and booted my main machine to look.

The part of the flow I posted - the inject and change nodes - are triggered at boot.

What I now see I didn't include in the post is that as I was looking at the dashobard I was also informed the machine had also just rebooted.

So that part of the flow should have been invoked.

It would seem that 90% of it was just one line seems to have been left out of being applied, or somehow, something changed the value form 6000 to 60.

I searched for the context name and only found only 6 times it was used.
Only one of those sets it, and that is the change node which sets it to 6000.

Sorry I didn't include this part. I thought I had. (But you know what thought did.)

I did suspect I didn't after I went to bed, but I was tired and wanted to not keep dwelling on it for that day.

And now, after posting this appendage, I think I have found the problem.

(Yeah, should have looked harder in the first place.)
Sorry. (How many times do I have to say it?)

I prefer to ask valid questions. But I quite often get overwhelmed with things that blind side me. I need to ask or I won't get anywhere.

I found another inject node (hidden away) that was injecting 60.
Not a good start to today.

I feel for you dude...yeah, this same scenario took a bite out of my day, the other day... I swear flow context was NOT updating right, I reviewed the code, tested, and it really did feel like the flow context code was NOT working. I even posted a question about it... well, I decided to recreate the entire flow from scratch, part by part to see how or when things were going wrong... and discovered that one change node, had one extra rule, that just happened, at the right time/condition to change the flow context value I was SURE was doing something WACKO. What is it they say... the DEVIL is in the details? LOL.

That's the problem with computers. They always do what you tell them, even when that isn't actually what you meant.

1 Like

LMAO. Now I don't wonder why my dachshunds seem to be ignoring me... they are NOT dachshunds, but mobile computing platforms, optimized to consume resources, and generate noise pollution.

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