node-red-contrib-rfxcom install issue

I’ve just released a new version of norelite that includes some fixes to the code and I ran into some issues when doing “npm update” of my installed Node-RED modules and it might be of interest to others to know how I fixed it.

The issue was not related to norelite but to node-red-contrib-rfxcom that simply couldn’t compile serialport@2.1.2 which is a dependency. After a lot of attempts and actually a re-install of nodejs, Node-RED and npm I finally found an instruction in the Node-RED docs related to Wheezy (I’m running Jessie though) that fixed the problem.

This was the error message that I received:

Failed to execute '/usr/bin/nodejs /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/pi/.node-red/node_modules/serialport/build/Release/serialport.node --module_name=serialport --module_path=/home/pi/.node-red/node_modules/serialport/build/Release' (1)
npm ERR! Linux 4.1.13-v7+
npm ERR! argv "/usr/bin/nodejs" "/usr/local/bin/npm" "install" "serialport@2.1.2"
npm ERR! node v4.4.7
npm ERR! npm  v2.14.15
npm ERR! code ELIFECYCLE
npm ERR! serialport@2.1.2 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the serialport@2.1.2 install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! This is most likely a problem with the serialport package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-pre-gyp install --fallback-to-build
npm ERR! You can get their info via:
npm ERR!     npm owner ls serialport
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR!     /home/pi/.node-red/npm-debug.log

And I solved it as follows: I first installed serialport@2.1.2 with unsafe-perm variable set and then node-red-contrib-rfxcom as follows (you could probably just use the variable with node-red-contrib-rfxcom)

cd ~/.node-red
sudo npm install --unsafe-perm serialport@2.1.2
sudo npm install node-red-contrib-rfxcom

6 min video with norelite

To get a quick start with norelite I’ve made a short video that explains the core components and how to quickly design the flows required to implement 3 rules that will turn on/off a switch if:

  1. It is dark outside and it is before 23:00
  2. It is dark outside and I’m watching the TV – It might be that I’m watching the TV after 23:00 and I also want the lamp to be on 15 mins after I’ve turned off the TV
  3. It is dark outside and there is movement in the house – I.e. getting the input from a PIR detector and whenever it triggers and it is dark outside the lamp will turn on for 5 mins. E.g. if I wake up during the night and want to go and get a glass of water…

If any of the above rules are true, the lamp will be on and if not it will turn it off.

OWFS with hub support for Node-Red

I’ve built my home automation system based on Node-Red (as mentioned in Flexible home automation system) and I am using 1-wire sensors for humidity, temperature and to measure the daylight level.

Initially I used the Node-Red “node-red-contrib-owfs” package to communicate with my 1-wire server but I have multiple 1-wire hubs and the package simply does not support having an hierarchy of sensors so I created a my own node to resolve this – noreowfs.

Use the UI of the 1-wire server to find the attribute that you want to read and simply add to the configuration of the node and the value will be available in the output of the node.

17cdec26-a68e-11e5-88ac-f7002d8c994b

Flexible home automation system

I have, for a number of years, tried a number of different home automation solutions but I’ve not been completely satisfied with any of them due to either lack of features, too difficult to oversee or too proprietary…For years I used SwitchKing and I’ve also tried Domoticz and looked into other options such as OpenHAB but I’ve been frustrated with either the UI, only running on Windows or too much and too complex.. So I decided to base my own Home Automation-setup on Node-Red instead as it very simple to use and extend if necessary and there is a vast amount of additional nodes one can use in your own setup.

However, Node-Red is, by default, a non-stateful event engine which means that if I was to implement my turning on/off lights rules it would have to include a large amount of message flows and I would have to be using complex custom coding to share information between the flows. E.g. I would like to implement the following rules:

  • Turn on the light switch if:
    • It is dark outside and the time of day < 23:00
    • It is dark outside and the TV is on (i.e. even if the time is above 23:00)
    • It is dark outside and there is movement in the house (e.g. someone wants to go to the bathroom during the night)
  • Otherwise turn it off

To implement all of the above is quite complex if just using the standard nodes in Node-Red as it does not keep the state – e.g. turn off only if there is no valid rule. So I decided to implement e number of nodes to ease the process of defining these rules and to take action (turn off/on).

Screen Shot 2016-03-30 at 15.45.06

Example of a few rules and filters

I’ve been running it now for a number of months and I am happy with the result. It is simple to add new datasources/sensors and to create new rules and flows if necessary.

I’m running it on a Raspberry Pi 2 with a rfxtrx433 transceiver but can also be used with a Tellstick (but I haven’t tested it though)

Take a look at the demo: http://goo.gl/T6Ag9P

And if you want to try it out it is available in NPM for download: https://www.npmjs.com/package/norelite