FOSSPicks

Node-RED

If you've done anything with home automation, home monitoring, or web scraping, then it's likely you'll have come across a great web service called IFTTT (an acronym for "If This Then That"). IFTTT lets you easily map data from your devices, such as a temperature sensor or light switch, to a plethora of other services such as your Google Calendar, Nest account, or even Twitter. It enables you to easily turn on heaters when temperatures plummet or tweet your average heart rate after a run. But IFTTT is not open source and can't be self-hosted. While it was once completely free, it has just launched a Pro tier and limited free accounts to just a few connections.

There are a few solutions you can host locally that perform a similar job. In particular, the Domoticz home automation server includes both a Lua scripting engine and an integrated Blockly visual programming interface, but they can't marshal connections from one device to a service in the same way that IFTTT does. But Node-RED can, albeit with some effort on your part. Node-RED is a super powerful, sublimely designed and implemented, self-hosted visual programming interface you can easily run from a Raspberry Pi (or any other Linux device). It doesn't include drag-and-drop services to easily connect one device to another, but it does provide every possible function and utility to build your own interface for any device you want and process the data from those devices in any way you need.

Each function in Node-RED is a flow of data from an input to an output, with nodes used to manipulate and conditionally operate on the data as it passes through them.

Node-RED has been around for a few years. It was initially developed by IBM and released as an open source project in 2016 where it became part of the JS Foundation. As both "Node" and "JS" implies, Node-RED is written in JavaScript, and as such it integrates perfectly with many other web technologies and commonly used online data structures. But it's also easy to use and understand, even if you're not a programmer. Much like a flow diagram or modular synthesizer, you build your own functionality by controlling the flow of data. It starts with an Inject node, which can be dragged from the node palette on the left. This node lets you grab data from another device or service, or you can generate data locally using a time stamp or click of the mouse. You can attach this to a CSV parser or HTML parser to separate the contents from the Inject node, and then you operate on those using the same kind of programming logic you'd find in any language, albeit with an emphasis on flowing streams of data. There's even a group of special nodes for use on the Raspberry Pi. These will send and receive data from the GPIO pins and even interpret input from the mouse or keyboard, creating all kinds of controller potential from a simple web interface.

When installed, you access the web interface from port 1880 of your device. Even on an older Raspberry Pi, the web UI is very responsive and easy to use. There are three main areas. On the left is the node palette, while the main chunk of the view is for your "flow," which is the name given to your patchwork of code and nodes. A flow needs to be deployed before it starts running, and you can have more than one loaded at a time with each using its own tab. On the right is the info, documentation, and debug output pane. This allows you to switch between the nodes in the flow view to see which parameters they take, what they do, and any output from your network. It allows you to construct almost any kind of data grabbing, data parsing, and data forwarding function that your home automation needs, all from behind your own home's firewall.

Project Website

https://nodered.org/

It's easy to see exactly what each node does with the exceptional embedded documentation and clear info view of a node's fields.

Online shooter

batufo

This is a simple but fantastic little game for several reasons. First and foremost, it's an addictive game to play. You control a UFO that moves within a variety of 2D scrolling arenas. To steer, you rotate your craft left and right, much like you do in Asteroids, before applying short bursts of thrust to accelerate in the direction you're facing. The end result is that you can move like a billiard ball, bouncing against the walls and other obstacles, diminishing your shield as you collide. You can pick up power-ups and travel through warp points, but the premise of the game is to destroy the other players. These appear in craft similar to yours, bouncing around the walls of the maze and trying to hit the power-ups before you do. Of course, your task is to destroy these other players using either your laser or a well-placed proximity mine that explodes when you or another player goes over it. The clever thing is that these players are real humans, because batufo is effortlessly multiplayer.

The other reason why batufo is such a good game is that it has been written in Google's shiny new application framework, Flutter. Flutter applications are often developed in Dart with JavaScript, and they are quick to build and use few system resources. They're also effortlessly multiplatform, and batufo will run on Linux, macOS, Windows, Android, and even in a web browser without any difficulty. But all of this has been augmented by the developer documenting the entire game-building process from their own set of excellent videos, which are linked to from their website. These videos show every stage of the game's development and offer brilliant insight into how an indie developer approaches game design, even to the point of building a level builder anyone can download and use to create maps for the game.

Project Website

https://thlorenz.com/batufo/

Learn how to fly a UFO and defeat fellow humans, while also learning a little about game development.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus

Direct Download

Read full article as PDF:

Price $2.95

News