Introduction: Day Timer Using Node Red With Persistant Memory
I extensively use Node-red for my Home Automation projects. i am not a prgrammer by progession , but with help from various contributors i try to configure things according to my requirement . Sometimes it works and sometimes it does not :)
For one of my automation project i needed Timers which i can set it from the frontend Node _red UI across multiple Day of week . There are avaiable projects wherein contributors have used the Node-red- contrib files for his purpose . But one basic thing which i never found is how to retain the time setup even after the node-red restarts ( owing to system crash etc...) . I wanted something which would resume from the last working stage and contniue thereafter
This need made me work upon this project .
There has been a constant need in my project to have a Timer feature
Step 1: Pre-requisities
1) A working Node-red program on Windows ( Or linux, Mac....). There are many instructions on the web to setup Node-red on Windows.
2) Basic knowledge of If , else logical statments
3) And a Lot of curiosity to explore things.................
Step 2: A Bit About Node - Red ( Mind You Not Too Much in Detail.....)
As their official website states
"Node-RED is a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways.
It provides a browser-based editor that makes it easy to wire together flows using the wide range of nodes in the palette that can be deployed to its runtime in a single-click."
url : https://nodered.org/
It's a powerful GUI having drag and drop functionaility for automating lot of this .
For eg: Using this Timer Tutorial you can design a flow wherein based on the Timer start an event " Water the garden" , " send an email" etc....
Step 3: Start Node - Red
After installing Node -red on your machine . go to the comand promt. Type in node-red to start the program.
Step 4: Node Red Control Box
The control Box would display tabs known as flows , initally it would be empty as it is a fresh install, go to the rightmost corner and from the drop down menu select "Manage Pallette" . This option is used to intstall different packages.
Click on Manage Pallette , it will open a window with two tabs
-- Nodes -This lists all the nodes ( packages) you have installed
-- Install - To install new nodes.
Go to the Install and install the below nodes:
-- node-red-dashboard : This will intsall the nodes which are used for creating dashboards ( buttons , graphs , switches etc..)
-- node-red-contrib-persist : This is a very recent node, this node can be used to store any Button state , Variable values incase the node-red crashes or closed abruptly.
-- node-red-contrib-simpletime: This is to convert the current time into whatever format required
Step 5: A Bit About the Node Red Elements
The Top portion comprises of the Different flows , you can create as many flows required, The left corner contains all the nodes . Some are default , some can be imported using the Manage pallete option and if you are experinces enough you can create a node .
A node is basically a element with predesignated features .
The right side of the work area comprises of The debug window , dashboard config etc...
In a flow you can use multiple nodes , and using the nodes from different flows you can design a dashboard.
The Setting Timer is one such Dashboard comprising of nodes from Flow " Setting Timer Flow" and "Day Set"
The entire flow can be exported to a clipboard or a file and this can be reused by importing the same.
enclosed the two Flows as a txt file.
for importing the flows:
save these ext files on your desktop
Go to the Right dropdown menu > Import > Clipboard
open the notepad and paste the contents here
repeat the action for the other flow .
So now you will have two Flows imported , click on Deploy to save the project.
Step 6: Dashboard View
Click on the Righmost corner of the debug window , you will find a bar grapg icon . This will open a new window with the dashboard UI,
Play with the timers , set different options .
Log in at various times of the day across different days of the week to check whether it's working as expected.
This project can be further extrapolated to include months as part of the selection criteria.
Enjoy and pls provide feedback.
Productive critisicm would be gladly accpeted as i am no programmer and there would defintely be a smarter / shorter / simpler way of doing this.