HowTo: NodeRed – Presence detection via ping requests

In order to be able to automate your own smart home properly, one function is quite important: Are residents present or not? This is the only way the system can, for example, automatically deactivate the heating, switch certain lights on or off or even activate the alarm functions.

In the article Node Red / FritzBox – presence detection with the FritzBox, I already described how this can be implemented using the function integrated in a FritzBox. But what if you don’t use a FritzBox as a router?

In that case, there are a few other options, one of which I would like to describe in this article. The presence of different devices (e.g. the smartphones of the residents) can also be realized via regular ping requests.

These regular ping queries can be automated and evaluated with NodeRed. A first basis for this automation is described in the following article.


Safety instructions

I know the following hints are always a bit annoying and seem unnecessary. But unfortunately, many people who knew it "better" from carelessness lost their eyes, fingers or other things or hurt themselves. In comparison, a loss of data is almost not worth mentioning, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Even the coolest project is worth no injury or other annoyance. https://www.nerdiy.de/en/sicherheitshinweise/

Affiliate links / advertising links

The links to online shops listed here are so-called affiliate links. If you click on such an affiliate link and shop via this link, Nerdiy.de receives a commission from the online shop or provider concerned. The price doesn't change for you. If you do your purchases via these links, you will support Nerdiy.de in being able to offer further useful projects in the future. 🙂


Requirements

Helpful articles:
So that you can install new nodes, NodeRed should of course already be installed on your RaspberryPi.
How to prepare a RaspberryPi and then install NodeRed on it is described in the following articles.

In the following lists you will find all the parts you need to implement this article.

Required tool:

NumberLink
1xSchraubendreher Set  Bei Amazon kaufen
1xSD Kartenleser  Bei Amazon kaufen

Required material:

NumberLink
1xSONOFF Zigbee 3.0 USB Dongle Plus  Bei Amazon kaufen
1xUSB Verlängerungskabel  Bei Amazon kaufen
1x Raspberry Pi  Bei Amazon kaufen
1x Raspberry Pi Netzteil  Bei Amazon kaufen
1x Raspberry Pi Gehäuse  Bei Amazon kaufen
1x Micro SD Karte 64GB  Bei Amazon kaufen


Import Node Red code

In this section you will find the Node Red code you need. How you can import this into your NodeRed environment is described in the article NodeRed – importing and exporting node code.

In order to be able to use the node code linked below with your ESPEasy device, you have to make a few changes. These are described in the next section.

You can find the Node Red code in the Nerdiy Git repository under the following link:

Another view of the Node Red Flow in the configuration interface.

In order for the Node Red Flow to work correctly, you must enter the IP address of the device whose presence you want to query in the red area.

Information on how to find out the IP addresses of individual devices can be found in the article

The JavaScript code that converts the response time into a presence signal can be seen in the area marked in red.

So you can use the global variable “device_is-present” to evaluate the presence status of the device.


More articles related to Node Red

In the following categories you will find further links on the subject of Node Red.


Have fun with the project

I hope everything worked as described. If not or you have any other questions or suggestions, please let me know in the comments. Also, ideas for new projects are always welcome. 🙂

P.S. Many of these projects - especially the hardware projects - cost a lot of time and money. Of course I do this because I enjoy it, but if you appreciate it that I share these information with you, I would be happy about a small donation to the coffee box. 🙂

Buy Me a Coffee at ko-fi.com   

Leave a Reply

Your email address will not be published. Required fields are marked *