node-red-contrib-device-manager
v1.0.4
Published
A group of nodes including Button, Dimmer, and Virtual for actuator & sensor access.
Downloads
28
Readme
Device Manager Node set
A group of nodes including Button, Dimmer, and Virtual for actuator & sensor access.
Motivation Behind This Project
There are many automation solutions available: OpenHAB, OpenNetHome, Nest, and many others. All of them are fine solutions for home automation. But I didn't feel like they gave me enough control; that is, there were no simple plugins for historical data, or complex scheduling, or simple PID controllers that satisfied me.
Besides that, I also wanted something that would transform as needed. For example, I'd like to automate fish-tank management & a winter greenhouse vegetable garden, and I'd like both to have unique interfaces related to their purpose - a kind of functional theme.
After looking at much of what is available, I decided that Node-RED was a reasonable foundation to build upon. Aditionally, I wanted to only use one language - ECMAScript (aka: javascript) - for the front end and the back end. Beyond that, I wanted to create my own devices using actuators & sensors.
The Intended Setup
I have decided to use Espressif's ESP32 chips for their low cost and availability. One can pick up a development board for less than $5 on AliExpress, and less than $10 on Amazon.
Because switching programing languages can be burdensome, I have used Espruino, which enables javascript on microcontrollers. It supports a wide range of MCUs, and has provided wonderful support for the ESP line (ESP32 & ESP8266). This project does not particularly care what language you program your MCU in, so long as WebSockets are implemented and the "OctoProtocol" is used.
An example device for monitoring pH, EC & water temperature is in the Water Module repository.
What You Get
This module provides 4 nodes. They consist of:
- a Device Manager, which will manage WebSocket connections and provides the i/o between the device and Node-RED;
- a Button, which provides a simple interface to On/Off services;
- a Dimmer providing read access to analog devices & write access to PWMs or DACs;
- a Virtual, which provides access to user-defined devices that might return multiple values or complex objects.
These provide an abstract way of interacting with a device, without needing to know a lot about it. An example setup might be:
|Device |Type |Output |
|-----------|---------|-----------------------------------------------------|
|bme280 |virtual |{ payload: [ "reading" { device: "bme280", value: { Temperature: 25, Humidity: 45, Preassure: 965.5 }}]}
|
|Lamp | button | { payload: [ "state", { device: "Lamp", value: { state: true }}]}
|
|Lamp Dimmer| dimmer | { payload: [ "state", { device: "Lamp", value: { state: 75 }}]}
|
Descriptions of the Nodes
Device Manager
A node that provides configuration access for the functional nodes (button, dimmer, virtual). It provides a WebSocket for devices to connect to, routes messsages to individual nodes, etc. It supports running along with Node-RED, or on another user-defined port. For user-defined ports, no path
is necessary in the configuration. For Node-RED managed WebSocket, a path is required and multiple paths may be provided by separating them with a comma.
Button
A node that connects to a GPIO on an embedded device, sending on or off commands.
The device should return a "state", (e.g. {state: 1}
for ON, & {state: 0}
for OFF)
Dimmer
A node that sets output of a PWM/DAC or other analog output / input peripheral.
The device should return a "state" e.g. {state: 79}
would indicate the PWM/Analog is at 79%
Virtual
A node that sends a predefined string (e.g. "getState", or "getTemperature") to the device, whereupon the device responds with the result of the command via a reading
packet containing an object with the results & possibly meta data about the results (e.g. Temperature, or Air Preassure units, etc.)
Example flow
An example flow can be found here