Home Automation with Node-RED and OpenHAB
Live Video Stream
The screenshot below shows the final UI that we are going to build using Node-RED and the Node-RED Dashboard. We want to be able to display a JPG Stream of Images from the live video in the Node-RED dashboard.
We are going to use the node-red-contrib-mjpgcamera plugin that can be installed from Manage Palette menu in our Node-RED dashboard. The plugin is grabbing single frames from one of the 3 MJPEG Streams that our camera offers and saves them to the public directory we created earlier. We then use a Watch Node to load the image every time it was updated, add a timestamp to its name - this is to trick your browser, that would refuse to reload the image, when the image name stays the same, thinking it was already loaded - and load it into our Node-RED dashboard.
Bonus :: OpenHAB Integration
Adding to the OpenHAB tutorial we are now going to consume the Node-RED flow in our OpenHAB 2 Basic UI.
Image url="http://localhost:1880/352snap.jpg" label="Camera Video Snapshot" refresh=30000
The refresh rate (in Milliseconds) can be adjusted to your needs. We have adjusted the MJEPG plugin in our Node-RED flow to grab a new frame from the 352p stream every 20s that will be displayed in the Node-RED Dashboard. The refresh value in the line above will update the image in the OpenHAB UI every 30s.