Node-RED meets things

Recently, a friend of us reached us with a quite unusual but nevertheless meaningful IoT use case: he was planning to have a long term trip to a foreign country. And since his house would be unoccupied during this period of time he wanted to ensure that within the cold months the heating system is still working properly in order to prevent any cold damage. He basically came up with the idea of using his existing Netatmo installation for doing this: if an indoor sensor detects low temperatures in the heating cellar there is a high chance of a technical defect and a technician should be informed to take a closer look. The ecosystem of Netatmo does not cover such a specific use case - and this is where connctd can be of relevance.

Due to a previous project we already had a well fitting Netatmo connector in place that provides us with nice abstracted sensor things and updates (see thing abstraction). But since our rule engine is still under development we had to find another way to implement the necessary business logic. And this is where Node-RED finally came into account. It's a…

[...] flow-based development tool for visual programming developed originally by IBM for wiring together hardware devices, APIs and online services [...]] [1]

...making it an ideal tool even for non technical people to graphically implement things like basic rules.

The deployment of Node-RED was like a piece of cake due to its docker image. The same holds true for the configuration. After just a couple of minutes we were ready to go to create the appropriate flows. Followed by some moments of trials and errors, we finally succeeded (extract see picture 1). The flow was like desired: in case the temperature dropped below a certain threshold the house owner as well as the technician got informed via mail. Additionally we enhanced the flow such that a weekly mail was sent to the owner reporting the last measured temperature as well as when the last sensor value change was detected. This status mail was used to signalise the owner the properly working and "armed" system.

Picture 1: Extract from Node-RED flow

Picture 1: Extract from Node-RED flow

The actual integration with our connctd platform was quite straightforward: after manually configuring the Netatmo connector all relevant things have been created. Whenever a state change occurred the appropriate events were sent by our event service directly to the running Node RED instance triggering a specific flow.

This was the second time that we have successfully realised a use case with Node-RED and we are still very satisfied with it. What we have seen so far shows us that it is a nice tool for rapidly implementing smaller use cases probably even for a smaller set of friendly-users as part of a proof of concept. We have even considered writing our own connctd node and contributing it to the Node-RED community which could make the integration of the connctd platform into flows much easier: On the one hand it could bring a new flow for automatically updating access tokens. So far this was something we had to model on our own within node red. On the other hand working with things could be simplified. Right now we are directly referencing things via their unique thing ids in order to read and control them. But due to our abstraction and semantics we could basically add a more advanced querying technique in a node like "give me a sensor reading of a thing that measures temperature in the cellar". Due to our upcoming GraphQL API this is something which could come true very soon.

References

  1. https://en.wikipedia.org/wiki/Node-RED

Sebastian Garn