Hi
Is it possible to regularly send either a static version of the web page or an image of a node red dashboard to my web host?
This means I could display my dashboard to the public without exposing my internal network.
Thanks
Hi
Is it possible to regularly send either a static version of the web page or an image of a node red dashboard to my web host?
This means I could display my dashboard to the public without exposing my internal network.
Thanks
You can use for example Puppeteer in a Node.js script for this. The below script has been tested on a Raspberry Pi 4.
Prerequisites
npm install -g puppeteer
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({
executablePath: '/usr/bin/chromium-browser'
});
const page = await browser.newPage();
await page.goto('http://localhost:1880/ui');
await page.waitFor(5000);
await page.screenshot({path: 'dashboard.png'});
await browser.close();
})();
If you're running an i686 environment, you don't need to separately install Chromium and can remove the executablePath
part and just call await puppeteer.launch()
. This should create a dashboard.png
screenshot in the folder you run the script in. You could call this script from Node-RED using the exec node and use a file watch node to trigger upload when the screenshot is updated.
You can adjust the waitFor
time in milliseconds to be as long as needed for the dashboard to fully load.
Thanks. I'll give that a try on my pi 3
@ristomatti I don't think that is what @bayesey is asking for.
The question is whether it is possible to upload a Node-RED dashboard to a static webhost, to avoid having to expose Node-RED to the internet.
The short answer is - no. The Node-RED dashboard is not a static webpage that can be copied around like that. It is a full web application that requires the node-red runtime to serve the content and handle all of the interactions.
He mentioned an image of it would be enough. I figured creating a static copy would be difficult or even impossible so I went for the screenshot solution.
Ahh yes - time for another cup of tea.
If you get it working, you can find the full Puppeteer documentation here: https://github.com/puppeteer/puppeteer/blob/v3.3.0/docs/api.md
There's likely an option for the browser window size for example if you want the screenshot to be of a specific size.
A screenshot would be acceptable but a web page would be better. I can create a webpage displaying the screenshot on the web host.
I guess another approach might be to run a python script that reads the values from a CSV created by node red and output a static page from that script.
you mean... create a dashboard !
Well if it doesn't need to look like the dashboard, then you'll gave plenty of options to fetch the required data and display it in any way you want.
I would then likely create a http in node in Node-RED to expose an endpoint where you could fetch the data as JSON. Then you could get the data directly on the custom page using JavaScript.
Pretty much, yes. Maybe I just query my particle photons variables on the cloud and create my own dashboard with plotly or something. Leave node red for my grafana dashboard at home.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.