Updating node-red in emonpi

node-red is rapidly developing, and due to dependency restrictions, some features may not work unless node-red is kept fairly up to date.
Updating a self-install on a raspberry pi is normally done via an upgrade script, which is present in a vanilla raspberry stretch OS.
See the node-red update guide.
However, the script is not currently installed in the emonpi, so here is a post from Jon detailing how to perform the update.

Paul

Updating the emonPi is very similar. There is just a few more steps. And I’d suggest running the command on the page Paul referenced:

bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)

instead of:

update-nodejs-and-nodered

so do these items:

rpi-rw
bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)
sudo reboot

I ran these commands recently to upgrade from NR 0.17 to 0.18.3 and all worked A-OK! :slightly_smiling_face:

You’ll see these items logged:

1 Like

This kind of update/upgrade is working for me but I have a credential problem after…I can see it on the console or in the log.
To solve it I have to execute the command

cd /home/pi/data/node-red
sudo mv flows_emonpi_cred.json flows_cred.json
sudo systemctl daemon-reload
sudo service nodered stop
sudo service nodered start

If somebody faces the same issue, it can maybe help

Alex

forgot to mention that after I also had to reinstall the nodes (emoncms, openweathermap, weatherunderground) manually via the palette but maybe I did not choose the correct option during the install

did the name of the device change? like from raspi to emonpi?

EDIT: or are you referring to credentials saved within node-red nodes?

The device name is still emonpi
for the credentials, I am referring to the ones used by the flows to publish the datas…without crédentials, they don’t work…
see

What is the name of your ‘flows’ file?

Paul

the encrypt/decrypt referenced on the Node-RED site I have not used before. The credentials issue may be a Node-RED issue and not a emonPi issue. The only way to know for sure is to see the error referenced in your first post.

Take a look at the Node-RED Google Group and maybe post a question there. That Group knows Node-RED better that me!

@paul : it is flows_emonpi.json
I think NodeRED is developping very fast and so it could be related to the new version 0.18.4

@Jon : I think it is related to the initial config of nodeRED on the SD image…with new version on nodeRED, credentials file is flows_cred.json and not flows_emonpi_cred.json

I can’t see how you’ve ended up with your flows & cred files having different names?
You have flows_cred.json & flows_emonpi.json, they should by default share the same name, ie either;
flows_emonpi_cred.json & flows_emonpi.json or
flows_cred.json & flows.json
v0.18.4 will accept either.

Paul

I thought this was only true if you changed the setting.js file. So the get Node-RED to accept flows_cred.json & flows.json you’d have the un-comment this line:

    //flowFile: 'flows.json',


disclaimer: I have not tested the above!

EDIT: I have 0.18.3

That’s the naming protocol for when the flow is created, but node-red will read either format in v0.18.4.
For example, I’m using NR projects, which shares the same settings.js across all projects:

    // The file containing the flows. If not set, it defaults to flows_<hostnam$
    //flowFile: 'flows.json',

In my Master_project the files are called flows_raspberrypi_cred.json & flows_raspberrypi.json
whilst my Storeroom project, the files are called flows_cred.json & flows.json

Both are read by node-red.

My point being how have the flows & cred files ended up with a different naming protocol.

Paul

I am not using NR projects (yet). I am doing something wrong (a discussion for another topic).

@alexandrecuer - did setting the flow names the same help?

OK thanks Jon and Paul…indeed, using NR projects was the solution…I had to enable projects in the settings.js file, with :
projects: {enabled: true}
in the editorTheme section

module.exports = {
// the tcp port that the Node-RED web server is listening on
uiPort: 1880,
editorTheme: { projects: {enabled: true}, menu: { “menu-item-help”: {
label: “Node-RED Pi Website”,
url: “Redirecting…
} } },

What I’ve proposed earlier (renaming the cred file) is therefore only vworking if you don’t enable projects

I have been trying to update node-red on my raspberry py with the latest emonSd image with all updates installed.
I initialized the script:
Here is the output from the terminal:

pi@emonpi(rw):~$ bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)

 
This script will remove versions of Node.js prior to version 6.x of Node.js and Node-RED
and if necessary replace them with Node.js 8.x LTS (carbon) and the latest Node-RED from Npm.
 
It also moves any Node-RED nodes that are globally installed into your user
~/.node-red/node_modules directory, and adds them to your package.json, so that
you can manage them with the palette manager.
 
It also tries to run 'npm rebuild' to refresh any extra nodes you have installed
that may have a native binary component. While this normally works ok, you need
to check that it succeeds for your combination of installed nodes.
 
To do all this it runs commands as root - please satisfy yourself that this will
not damage your Pi, or otherwise compromise your configuration.
If in doubt please backup your SD card first.
 
Are you really sure you want to do this ? [y/N] ? y


Running Node-RED update for user pi at /home/pi

This can take 20-30 minutes on the slower Pi versions - please wait.

  Stop Node-RED                       ✔
  Remove old version of Node-RED      ✔
  Remove old version of Node.js       ✔
  Install Node.js LTS                 ✔   Node v8.10.0   Npm 5.6.0
  Clean npm cache                     ✔
  Install Node-RED core               
┌──────────────────────────────────────────────────────┐
│               npm update check failed                │
│         Try running with sudo or get access          │
│         to the local update config store via         │
│ sudo chown -R $USER:$(id -gn $USER) /home/pi/.config │
└──────────────────────────────────────────────────────┘
  Install Node-RED core               ✔   
  Move global nodes to local          ✔/nodered-install.log
  Install extra Pi nodes              -
  Npm rebuild existing nodes          ✔
chmod: cannot access '/usr/bin/node-red-start': No such file or directory
chmod: cannot access '/usr/bin/node-red-stop': No such file or directory
chmod: cannot access '/usr/bin/node-red-log': No such file or directory
  Add menu shortcut                   ✔
sed: can't read /lib/systemd/system/nodered.service: No such file or directory
  Update systemd script               ✔
  Update update script                ✔



All done.
  You can now start Node-RED with the command  node-red-start
  or using the icon under   Menu / Programming / Node-RED
  Then point your browser to localhost:1880 or http://{your_pi_ip-address}:1880

Started  Thu Mar 22 18:04:19 UTC 2018  -  Finished  Thu Mar 22 20:02:13 UTC 2018

mv: inter-device move failed: '/tmp/update-nodejs-and-nodered' to '/usr/bin/update-nodejs-and-nodered'; unable to remove target: Read-only file system
pi@emonpi(ro):~$ 

And here is the log file

nodered-install.txt (33.8 KB)

Any idea why the raspberry pi turned to read only, even i had change it before i run the script?
Is it defined to revert to read only after some time?

"sed: can't read /lib/systemd/system/nodered.service: No such file or directory"  would that have some efect on my system?

Best regards
Celso

I dont believe the system will revert to read-only after X amount of time. I would guess another command ran and dropped the system back to read-only.

Try running the same commands again:

rpi-rw
bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)
sudo reboot

Yes ever hour from first boot it will return to read-only to ensure it’s not left rw, not a perfect solution if you start editing/updating in the 59th min of the hourly interval. If you have something important and lengthy to do you could check the syslogs for the last “ntp-backup” entry and time your activities to fit with that hourly cycle or if that’s no good there is possibly a way to disable that from happening, temporarily. eg

sudo service ntp-backup stop

and then at a later time

sudo service ntp-backup start

to restore normal ops, the time will not be persisted during that time whilst ntp-backup is stopped, so if you leave it off fo 6 hours and then pull the plug, the Pi will restart thinking it is 6-7 hours earlier until it gets a NTP update.

[edit -but what Jon says about other scripts etc is valid, even if you do disable ntp-backup as I mention (but not recommended), the OS will still return to RO if (for example) you run emonpi updates]

[edit2 - actually I’m wrong, you can’t do it from disabling the service as there is a cron to "restart@ the service, that’s how it works if memory serve’s. You would need to disable the cron and then re-enable it]

Thank you all for the reply!

The main problem is because the script update took so long working (“Started Thu Mar 22 18:04:19 UTC 2018 - Finished Thu Mar 22 20:02:13 UTC 201”, that changing to RO was inevitable.
I found 2 problems:
( please notice that i already reinstalled the emonSD latest image again, so all the logs went lost)

1- I notice that (on raspberry pi 3 B), selecting emonpi update, it doesn’t really update emonpi ( at least don’t change the version). (to make it work it i had to do this: emonPi update Emoncms V9.8.28 - #7 by glyn.hudson)

2-when using the script, having a wired connection (i have 100MB/s connection in my home) it takes “hours” (4kb/s average) to download the packages, probably because raspberry pi not having the latest software update.

3- after a new reinstall of the image and a new try on the script, at first script try, didn’t work well, i had to try it again as John advised and then it worked well, all after update raspberry pi with the latest updates.

Now it is working well but installing some nodes by terminal, some of them don’t appear on node-red, even if on pallete manager says installed.

It should work unless you are using an old incompatible image, emoncms is only one part of the software on an emonpi so updating to > v9.8.28 will only do that one bit not the rest.

Oh dear, could you not take it into work one day or “borrow” a friends network to get the larger part of it done?

@Jon might be able to assist you, I don’t use node-red.

Exactly what commands were used to install via Terminal?

if you did something like:

rpi-rw
cd ~/.node-red
npm install node-red-node-emoncms 

without the -g (global) in the npm command then you should be fine.

FYI - the cd ~/.node-red should place you in the /home/pi/data/node-red/ directory.