# Flow.context values not being set as expected

**URL:** <https://discourse.nodered.org/t/flow-context-values-not-being-set-as-expected/32139>\
**Category:** General\
**Created:** [28 August 2020 09:39 UTC](https://discourse.nodered.org/t/flow-context-values-not-being-set-as-expected/32139 "2020-08-28T09:39:26Z")\
**Posts on this page:** 8\
**Page:** 1

<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:** [28 August 2020 09:39 UTC](https://discourse.nodered.org/t/flow-context-values-not-being-set-as-expected/32139/1 "2020-08-28T09:39:26Z")

</div>

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

(the flow)

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

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [28 August 2020 13:08 UTC](https://discourse.nodered.org/t/flow-context-values-not-being-set-as-expected/32139/2 "2020-08-28T13:08:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [28 August 2020 13:18 UTC](https://discourse.nodered.org/t/flow-context-values-not-being-set-as-expected/32139/3 "2020-08-28T13:18:17Z")

</div>

> [@Trying\_to\_learn](#):
>
> But why/how is/was it set to `60` and not `6000` ?

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.

---

<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:** [28 August 2020 22:38 UTC](https://discourse.nodered.org/t/flow-context-values-not-being-set-as-expected/32139/4 "2020-08-28T22:38:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Nodi.Rubrum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodi.rubrum/32/107482_2.png) [@Nodi.Rubrum](https://discourse.nodered.org/u/Nodi.Rubrum)\
**Post date:** [29 August 2020 20:05 UTC](https://discourse.nodered.org/t/flow-context-values-not-being-set-as-expected/32139/5 "2020-08-29T20:05:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [29 August 2020 20:19 UTC](https://discourse.nodered.org/t/flow-context-values-not-being-set-as-expected/32139/6 "2020-08-29T20:19:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Nodi.Rubrum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodi.rubrum/32/107482_2.png) [@Nodi.Rubrum](https://discourse.nodered.org/u/Nodi.Rubrum)\
**Post date:** [29 August 2020 20:20 UTC](https://discourse.nodered.org/t/flow-context-values-not-being-set-as-expected/32139/7 "2020-08-29T20:20:49Z")

</div>

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.

---

<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:** [12 September 2020 20:21 UTC](https://discourse.nodered.org/t/flow-context-values-not-being-set-as-expected/32139/8 "2020-09-12T20:21:04Z")

</div>

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