Updating node-red in emonpi

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.

I have seen this on updating node-red generally. It is down to how you installed them in the first place. The only solution I could find was to manually delete the node from the command line, then reinstall from the palette manager.

Thanks for the reply.
I think i missed somehow the cd ~/.node-red comand.
Need to try it again to see if was my (noobie) problem or was something that was going wrong on the update but @borpin, i already did see this happening on my emonpi (currently am trying first on raspberry pi B) but with the default node-red version that cames with latest emonSd image, installing with the palette manager and command line.
This was happening with openweathermap node.

Have you checked the node-red log to see if it reports any issues?

i think tthis is the log. Was hard to find but here is the var/syslog.
If is not the correct, please tell me.

Mar 26 16:01:05 emonpi Node-RED[513]: 26 Mar 16:01:05 - [info] Installed module: node-red-node-openweathermap
Mar 26 16:01:05 emonpi Node-RED[513]: 26 Mar 16:01:05 - [info] Added node types:
Mar 26 16:01:05 emonpi Node-RED[513]: 26 Mar 16:01:05 - [info] - node-red-node-openweathermap:openweathermap : SyntaxError: Use of const in strict mode.
Mar 26 16:01:05 emonpi Node-RED[513]: 26 Mar 16:01:05 - [info] - node-red-node-openweathermap:openweathermap in : SyntaxError: Use of const in strict mode.

Install it on palette manager and by terminal, when i re-login on node-red, it desapears.

(Use 3 backticks (rather than apostrophes) for logs code etc)

Sorry, lost track of what the issue is? Is it with EmonCMS or node-red in general? If so the node-red google group would be a more appropriate forum.

Node-red in emonsd image. I will look in Node-red google group.
Thanks!