# Settings.js - question about "myDeviceName"

**URL:** https://discourse.nodered.org/t/settings-js-question-about-mydevicename/22924
**Category:** General
**Created:** [10 March 2020 12:52 UTC](https://discourse.nodered.org/t/settings-js-question-about-mydevicename/22924 "2020-03-10T12:52:23Z")
**Posts on this page:** 12
**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: [10 March 2020 12:52 UTC](https://discourse.nodered.org/t/settings-js-question-about-mydevicename/22924/1 "2020-03-10T12:52:23Z")

</div>

Alas I am in the fun stage of re-building a machine.

I set the computer's name in the `settings.js` file.

Extract:

```auto
    functionGlobalContext: {
        // os:require('os'),
        // jfive:require("johnny-five"),
        // j5board:require("johnny-five").Board({repl:false})
        myDeviceName: "MusicPi"
    },

```

Yet, when I load the page and look at contexts:

![Screenshot from 2020-03-10 23-49-11](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/d/0dc2941f57815509d0f839e5b5e341512669123f.png)

No name.

Yet, on other machines I see it.

Yes, I have restarted NR.

![Screenshot from 2020-03-10 23-50-34](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/f/3fadcbbad552951f039efda4d38591c4408a23f8.png)

Sorry, but I just can't trust myself just now, and I kind of want to get to a point today (night) where I can be sure I have got a _mile stone_ met.

---

<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: [10 March 2020 12:58 UTC](https://discourse.nodered.org/t/settings-js-question-about-mydevicename/22924/2 "2020-03-10T12:58:36Z")

</div>

1. have you edited the _right_ settings.js file? NR logs the full path to the file it is using when it starts up. Make sure you are editing the right file.

2. Have you restarted NR since editing the settings file? Changes to the file are only picked up when NR starts.

---

<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: [10 March 2020 13:09 UTC](https://discourse.nodered.org/t/settings-js-question-about-mydevicename/22924/3 "2020-03-10T13:09:06Z")

</div>

I hope I have.

It is `~/.node-red/settings.js`  
Or,  
`/home/pi/.node-red/settings.js`

I have just rebooted the machine.

No `myDeviceName` show in the context list.

Both NR 1.0.3  
Top one not working. Second one is.

 ![Screenshot from 2020-03-11 00-02-55](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/1/312f1115e3968f5230ac54e474738abfd5b5139f.png)

 ![Screenshot from 2020-03-11 00-04-25](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/8/98bfffadf61f100129753b16311d1358f581ea7d.png)

I really hope I am not missing any elephants.

I don't think this is to do with the problem, but this is seen when I start NR.

```auto
pi@MusicPi:~/.node-red$ node-red-start

Start Node-RED
 
Once Node-RED has started, point a browser at http://192.168.0.82:1880
On Pi Node-RED works better with the Firefox or Chrome browser
 
Use node-red-stop to stop Node-RED
Use node-red-start to start Node-RED again
Use node-red-log to view the recent log output
Use sudo systemctl enable nodered.service to autostart Node-RED at every boot
Use sudo systemctl disable nodered.service to disable autostart on boot
 
To find more nodes and example flows - go to http://flows.nodered.org
 
Starting as a systemd service.
10 Mar 23:56:39 - [info]
Welcome to Node-RED
===================
10 Mar 23:56:39 - [info] Node-RED version: v1.0.3
10 Mar 23:56:39 - [info] Node.js version: v10.15.2
10 Mar 23:56:39 - [info] Linux 4.19.97-v7+ arm LE
10 Mar 23:56:43 - [info] Loading palette nodes
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named rpi_ws281x
10 Mar 23:56:48 - [warn] rpi-neopixels : rpi-gpio.errors.ignorenode
10 Mar 23:56:50 - [info] Dashboard version 2.19.4 started at /ui
10 Mar 23:56:51 - [info] Settings file : /home/pi/.node-red/settings.js
10 Mar 23:56:51 - [info] HTTP Static : /home/pi/.node-red/public
10 Mar 23:56:51 - [info] Context store : 'default' [module=memory]
10 Mar 23:56:51 - [info] User directory : /home/pi/.node-red
10 Mar 23:56:51 - [warn] Projects di

```

Lines of interest:

```auto
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named rpi_ws281x

```

Ok. I am driving NeoPixel LEDs.

But I can't find a node in the library `rpi_ws281.....`

---

<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: [10 March 2020 13:19 UTC](https://discourse.nodered.org/t/settings-js-question-about-mydevicename/22924/4 "2020-03-10T13:19:05Z")

</div>

In the top screenshot I can see you have set `exportGlobalContextKeys` to `false`. With that value set like that none of the global context values will be exported to the editor - which is why you don't see them.

Either comment out that line or change its value to `true`.

---

<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: [10 March 2020 13:22 UTC](https://discourse.nodered.org/t/settings-js-question-about-mydevicename/22924/5 "2020-03-10T13:22:17Z")

</div>

That must be new.

Looking (just checked) the _other_ machine. It doesn't have that in it's settings.

Stand by and I shall report back soon.

I did suspect the two settings files were different as that is near the bottom and on one it was visible and on the other it wasn't - the bottom of the file.

---

<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: [10 March 2020 13:26 UTC](https://discourse.nodered.org/t/settings-js-question-about-mydevicename/22924/6 "2020-03-10T13:26:26Z")

</div>

(Love ya!)

But just to put the cards on the table, this is from the other working machine and its settings.js file.

No sign of `exportGlobal` in the file.

 ![Screenshot from 2020-03-11 00-24-29](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/9/695b93a526f7a30056cf3a4a3d92b8701247931a.png)

I'm calling it a night!

Too much awake today.

---

<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: [10 March 2020 13:28 UTC](https://discourse.nodered.org/t/settings-js-question-about-mydevicename/22924/7 "2020-03-10T13:28:56Z")

</div>

I can't remember exactly which version of NR introduced the `exportGlobal...` option, but it was relatively recent - possibly 0.20.xx or 1.x. So it would have only started appearing in settings files generated by those releases. If you had a settings file that predated whatever version we added the option, then it won't have the option in.

Glad we figured it out!

---

<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: [10 March 2020 13:32 UTC](https://discourse.nodered.org/t/settings-js-question-about-mydevicename/22924/8 "2020-03-10T13:32:51Z")

</div>

Again:  
Thanks.

I shall have to let that drift until _tomorrow_.

I had to re-build the whole machine and though I _cheated_ in copying parts of the old file to the new one, that was more for the password.

The other two parts (public path and machine name) I did manually.

So I am a bit curious to how/why that is in it. But for now, sleep is 95% priority. Its 00:31 local and I have been up since 06:00 local. So it has been a long day.

And killing two machines and getting one nearly back to working is enough for me.

Thanks again.

---

<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: [10 March 2020 22:01 UTC](https://discourse.nodered.org/t/settings-js-question-about-mydevicename/22924/9 "2020-03-10T22:01:04Z")

</div>

Sorry.... But it is not all good news.

Quick explanation:  
Ok, the _problem_ was that the global context for the machine name wasn't visible when I looked at the global context list.

That is weird.  
Because the flow was/is working and sending the machine name to my main machine.

More detailed list of events:  
The machine (MusicPi) sends the CPU load and temperature to my main machine via MQTT.  
The message is the machinename and the load and another one with machinename and temperature.

The _main machine_ matches the machinename so it knows who is sending the data.  
That was matching.  
So despite the `exporteglobabl` option being set to `false`, the flow could still see it.

To check, I booted the machine this morning and set it back to `false`.  
Stopped node-red and restarted it.

The flow seems to still be able to see the _name_.

Though maybe not exactly proving it, here is a (what's the word?) from the CLI:  
I edited the `settings.js` file and set `exportglobal` to `false` and started Node-red.

```auto
pi@MusicPi:~/.node-red$ nano settings.js 
pi@MusicPi:~/.node-red$ node-red-start

Start Node-RED
 
Once Node-RED has started, point a browser at http://192.168.0.82:1880
On Pi Node-RED works better with the Firefox or Chrome browser
 
Use node-red-stop to stop Node-RED
Use node-red-start to start Node-RED again
Use node-red-log to view the recent log output
Use sudo systemctl enable nodered.service to autostart Node-RED at every boot
Use sudo systemctl disable nodered.service to disable autostart on boot
 
To find more nodes and example flows - go to http://flows.nodered.org
 
Starting as a systemd service.
11 Mar 08:48:47 - [info]
Welcome to Node-RED
===================
11 Mar 08:48:47 - [info] Node-RED version: v1.0.3
11 Mar 08:48:47 - [info] Node.js version: v10.15.2
11 Mar 08:48:47 - [info] Linux 4.19.97-v7+ arm LE
11 Mar 08:48:51 - [info] Loading palette nodes
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named rpi_ws281x
11 Mar 08:48:55 - [warn] rpi-neopixels : rpi-gpio.errors.ignorenode
11 Mar 08:48:56 - [info] Dashboard version 2.19.4 started at /ui
11 Mar 08:48:56 - [info] Settings file : /home/pi/.node-red/settings.js
11 Mar 08:48:56 - [info] HTTP Static : /home/pi/.node-red/public
11 Mar 08:48:56 - [info] Context store : 'default' [module=memory]
11 Mar 08:48:56 - [info] User directory : /home/pi/.node-red
11 Mar 08:48:56 - [warn] Projects disabled : editorTheme.projects.enabled=false
11 Mar 08:48:56 - [info] Flows file : /home/pi/.node-red/flows_MusicPi.json
11 Mar 08:48:56 - [info] Server now running at http://127.0.0.1:1880/
11 Mar 08:48:56 - [warn]
---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------
11 Mar 08:48:57 - [info] Starting flows
11 Mar 08:49:05 - [info] Started flows
11 Mar 08:49:05 - [info] [mqtt-broker:MQTT Host] Connected to broker: mqtt://192.168.0.99:1883
11 Mar 08:49:05 - [info] [mqtt-broker:MQTT host] Connected to broker: mqtt://192.168.0.99:1883
11 Mar 08:49:05 - [info] [mqtt-broker:MQTT host] Connected to broker: mqtt://192.168.0.99:1883
11 Mar 08:49:05 - [info] [mqtt-broker:MQTT host] Connected to broker: mqtt://192.168.0.99:1883
11 Mar 08:49:05 - [warn] [function:8d470685.db6a] Control signal received GO
11 Mar 08:49:06 - [warn] [vcgencmd:Other stuff] Previous vcgencmd command hasn't finished yet
^C
pi@MusicPi:~/.node-red$ node-red-stop

Stop Node-RED
 
Use node-red-start to start Node-RED again
 
pi@MusicPi:~/.node-red$ cat settings.js | grep Global
    // The following property can be used to seed Global Context with predefined
    // functionGlobalContext: { os:require('os') }
    functionGlobalContext: {
    // following property can be used to hide any property set in `functionGlobalContext`
    exportGlobalContextKeys: false,
pi@MusicPi:~/.node-red$ 

```

 ![Screenshot from 2020-03-11 08-49-45](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/f/9f6f8bbc5fe4210143c508c3ccf99cc4276cba54.png)

Have I messed up something or......?

Not urgent, but I am mentioning it because it doesn't fit with what you said.

---

<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: [10 March 2020 22:59 UTC](https://discourse.nodered.org/t/settings-js-question-about-mydevicename/22924/10 "2020-03-10T22:59:45Z")

</div>

The `exportGlobalContextKeys` setting doesn't stop you _using_ the global context values in your flows.

All its stops you from doing is:

1. seeing it in the global context sidebar
2. seeing it listed if you use the `global.keys()` api that returns a list of all keys in storage.

This setting was added due to concerns that if a user added API keys or other credentials to `functionGlobalContext` then they would be displayed in the clear in the editor sidebar. Setting the `exportGlobalContextKeys` to false stops it doing that so the won't get displayed.

But to repeat - if you _know_ the name of the key already, you can still use `global.get(...)` to retrieve its value.

---

<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: [10 March 2020 23:01 UTC](https://discourse.nodered.org/t/settings-js-question-about-mydevicename/22924/11 "2020-03-10T23:01:46Z")

</div>

Ok. (Again) My bad.

Sorry if I cried _Wolf_.

That machine is now working as expected to this point.

---

<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: [24 March 2020 23:01 UTC](https://discourse.nodered.org/t/settings-js-question-about-mydevicename/22924/12 "2020-03-24T23:01:53Z")

</div>

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