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
- Chromium is installed (not required if running on i686 CPU and not on a Raspberry Pi)
- Puppeteer is installed:
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.