Parameter Dashboard

Heyhey,,,

Here's a brain teaser for all you geniuses out there... Unfortunately I am not in this group!!

I am on the point of writing a "Parameter Dashboard" for my daft little setup....

My requirements are:
Parameters to be easily accessible through drop down menus and sliders.(Pretty Easy)
They must be written to a file when set/updated.
They must have a "default safe value" should the parameter file not exist.(Not Difficult)
The system must create the parameter file automatically in its "Default Location" wherever that may be and it should be a plain text file for easy external manipulation.
The system should not only read the values on cold startup, but peek at them every so often to look for changes made externally.
Any "New" parameters that come about due to system development should be appended to the setup file.

Now... The million dollar question! How would YOU go about it?

Cheers
Ed

The 10¢ answer...

You play. You learn. You watch the thousands of tutorials. You read the forum. You get stuck. You pop back with a specific question. We answer the specific question. You move on. Rinse and repeat. :slight_smile:

Clues....

  • Look into (search) persistent context (for storage)
  • install dashboard and drop some elements on screen.

Honestly, this is not as difficult as you imagine. Give stuff a go and you'll be flying in no time.

1 Like

Thanks for the pointer, @Steve-Mci ..

Went into the "Working with context" pages and tried to set:

contextStorage: {
   default: "memoryOnly",
   memoryOnly: { module: 'memory' },
   file: { module: 'localfilesystem' }
}

I appended it to the end in the settings.js file... then did the inevitable node-red-restart to get things going...

Node red wouldn't restart/start until I removed those lines... Any Idea where I am going wrong?

Tia
Ed

PS - as you probably guess, I am more than a little out of my league here!! (but I will get there!!)

Why didn't you use the section that is already there?

    // Context Storage
    // The following property can be used to enable context storage. The configuration
    // provided here will enable file-based context that flushes to disk every 30 seconds.
    // Refer to the documentation for further options: https://nodered.org/docs/api/context/
    //
    //contextStorage: {
    //    default: {
    //        module:"localfilesystem"
    //    },
    //},

If you want to learn more, take a look at this thread: A guide to understanding 'Persistent Context'

The section isnt there... I have an early version settings file carried over from a few years back, but the NR et al has been upgraded to the latest...

I did read it, and its exactly what I am after... Just trying to get the sections "enabled"...

Regds
Ed

My settings file is actually pretty basic:

/**
 * Originale latest version: https://raw.githubusercontent.com/node-red/node-red/master/settings.js
 **/

var fs = require("fs");
var i2c = require("i2c-bus");
var mySettings;
try {
	mySettings = require("/home/pi/.node-red/redvars.js");
} catch(err) {
	mySettings = {};
}

module.exports = {
    uiPort: process.env.PORT || 1880,
    mqttReconnectTime: 15000,
    serialReconnectTime: 15000,
    debugMaxLength: 1000,
    flowFile: 'flows.json',
    flowFilePretty: true,
    httpStatic: '/home/pi/.node-red/public',
    functionGlobalContext: {
        os:require('os'),
        moment:require('moment'),
        fs:require('fs'),
		i2c:require('i2c-bus'),
        mySettings:mySettings
    },
    logging: {
        console: {
            level: "info",
            metrics: false,
            audit: false
        }
    },
    adminAuth: 
//<Section Removed>

    editorTheme: { projects: { enabled: false }
    }

    // By default, credentials are encrypted in storage using a generated key. To
    // specify your own secret, set the following property.
    // If you want to disable encryption of credentials, set this property to false.
    // Note: once you set this property, do not change it - doing so will prevent
    // node-red from being able to decrypt your existing credentials and they will be
    // lost.
    //credentialSecret: "a-secret-key",

    //https: {
    //    key: fs.readFileSync('privatekey.pem'),
    //    cert: fs.readFileSync('certificate.pem')
    //},
    //requireHttps: true

    /* <Remarked this section out to keep going meantime>
     //* Context Storage
     //* The following property can be used to enable context storage. The configuration
     //* provided here will enable file-based context that flushes to disk every 30 seconds.
     //* Refer to the documentation for further options: https://nodered.org/docs/api/context/
     //* 
     //* Default is to use 'memory' only.
     //* 'memory' and 'localfilesystem' are both synchronous.
     //*
    contextStorage: {
        default: {
            module:'memory',
        },
        file: {
            module: 'localfilesystem',
            // config: {
            //     flushInterval: '30', // default is 30s
            // },
        },
    },
    */
}

Node Js Version - v14.16.0
Node Red 1.2.9
Running Pi4 - 4gb

If you look at the 2nd (full) settings.js posting you made, there is no comma , from the above section ending and the bit you added starting...

See here - your settings file MINUS the commented out parts...

module.exports = {
   // snipped out for brevity

    editorTheme: { projects: { enabled: false }
    }   <<<<<< Missing comma

    contextStorage: {
        default: {
            module:'memory',
        },
        file: {
            module: 'localfilesystem',
            // config: {
            //     flushInterval: '30', // default is 30s
            // },
        },
    },
    */
}

↑ look, no comma between editorTheme and contextStorage

Steve!!!!!!

Holy smoke.... I wouldn't have spotted that in a month of Sundays!!

Thanks ever so much!!

Now I can actually "experiment" with the file store parameters!! You are a star!!

Cheers
Ed

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