HowTo: Node Red / FritzBox – Presence detection via FritzBox

An important event that your SmartHome should be able to react to is the presence status of the residents. For example, you can turn off the lights when you are away or turn on the radiators when you are present.
Are you by chance still in the possession of a FritzBox this presence detection is particularly easy.

All you need is a FritzBox, NodeRed and the MAC address(es) of the resident smartphones.

How you implement the presence detection with the FritzBox in NodeRed is described in the following article.

Hints for our lovely english readers: Basically, many of the articles on Nerdiy.de are translations from the original german articles. Therefore, it may happen here and there that some illustrations are not available in english and that some translations are weird/strange/full of mistakes or generally totaly wrong. So if you find some obvious (or also not obvious) mistakes don't hesitate to leave us a hint about that in the comment section. 
Also please don't get confused, that instead of a "dot" often a "comma" is used as decimal separator. 🙂


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:
Of course NodeRed should already be installed so that you can take over this configuration.
How to prepare a RaspberryPi and then install NodeRed on it, is described in the following articles.

Required tools:
-none-

Required material:

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


Log in to the NodeRed configuration interface

Before you can edit your NodeRed configuration you must - if activated - first log in to the NodeRed configuration interface.

View of the login screen. Here you have to enter the login details that you entered during the configuration of the login. Information about this can be found in the article NodeRed - User Login Setup.

Install FritzBox-Node

So that NodeRed can communicate with your FritzBox you have to install the node “node-red-contrib-fritz”. How to install Nodes is described in the article NodeRed – Install New Nodes.


Enter FritzBox node configuration

So that the just installed FritzBox node can also communicate with your FritzBox, you have to specify your FritzBox login data in the configuration of the node.

Click on the node “Fritz! Box Call Monitor”. This opens a new window in which you can select “Add new fritzbox-config” in the line “Device”. Select this and then click on the Pen icon to the right of it.
In the now opening window you have to enter the login data to your FritzBox. So first the name, so that the configuration does not remain nameless and then the user name and the password. If the FritzBox is in your private network you can leave the information at Host at “fritz.box”. Only if you access a remote FritzBox you have to enter the URL to the desired FritzBox. Then you should also ensure that this connection is encrypted by HTTPS. In this case, the hook must be set to “Is SSL connection”. Once you have entered everything you confirm this by clicking on “Add”.
This will redirect you back to the previous window. The new FritzBox configuration is already selected. You just have to confirm the window by clicking on “Done”.

Node code for presence detection

The presence detection on you FritzBox works in principle on the fact that it checks periodically which smartphones are logged in the Wi-Fi or network of the FritzBox.

First, you need to insert the Node Code listed below into your NodeRed configuration.
Then you need the MAC addresses of the smartphones whose presence you want to recognize. This you have to then enter in a further step in the configuration of the Fritz! Box node.

Node structure in the NodeRed configuration

Node-Code:

[{"id":"cf98613.60e11a","type":"comment","z":"26fe5591.f8118a","name":"AnwesenheitHandy1","info":"","x":150,"y":1980,"wires":[]},{"id":"eedc08fb.12b8f8","type":"inject","z":"26fe5591.f8118a","name":"AnwesenheitHandy1","topic":"","payload":"{\"NewMACAddress\": \"XX:XX:XX:XX:XX:XX\" }","payloadType":"json","repeat":"60","crontab":"","once":true,"onceDelay":"1","x":200,"y":2040,"wires":[["38b70c39.68f504"]]},{"id":"c546f3f1.387d1","type":"debug","z":"26fe5591.f8118a","name":"AnwesenheitHandy1","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.NewActive","x":620,"y":2020,"wires":[]},{"id":"1c07ae94.c6b621","type":"trigger","z":"26fe5591.f8118a","op1":"AnwesenheitHandy1 ist im Netzwerk angemeldet","op2":"0","op1type":"str","op2type":"str","duration":"0","extend":false,"units":"ms","reset":"0","bytopic":"all","name":"","x":890,"y":2040,"wires":[["38b38282.c0058e"]]},{"id":"3c25ea32.a803d6","type":"change","z":"26fe5591.f8118a","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.NewActive","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":2100,"wires":[["1c07ae94.c6b621","379d6bd2.312594"]]},{"id":"379d6bd2.312594","type":"trigger","z":"26fe5591.f8118a","op1":"AnwesenheitHandy1 ist nicht mehr im Netzwerk angemeldet","op2":"0","op1type":"str","op2type":"str","duration":"0","extend":false,"units":"ms","reset":"1","bytopic":"all","name":"","x":890,"y":2120,"wires":[["59fcf739.918c68"]]},{"id":"38b38282.c0058e","type":"pushbullet","z":"26fe5591.f8118a","config":"274f4530.883c1a","pushtype":"note","title":"Anwesenheit","chan":"","name":"","x":1110,"y":2040,"wires":[]},{"id":"59fcf739.918c68","type":"pushbullet","z":"26fe5591.f8118a","config":"274f4530.883c1a","pushtype":"note","title":"Anwesenheit","chan":"","name":"","x":1110,"y":2120,"wires":[]},{"id":"38b70c39.68f504","type":"fritzbox-in","z":"26fe5591.f8118a","device":"eef817a2.74b848","name":"","service":"urn:dslforum-org:service:Hosts:1","action":"GetSpecificHostEntry","arguments":"{\"NewMACAddress\":\"value\"}","x":400,"y":2040,"wires":[["c546f3f1.387d1","3c25ea32.a803d6"]]},{"id":"274f4530.883c1a","type":"pushbullet-config","z":"","name":"FabsPushbullet"},{"id":"eef817a2.74b848","type":"fritzbox-config","z":"","name":"FasbFritzBox","host":"fritz.box","port":"49000","ssl":false}]

It is important that after importing the NodeCode you have to update the MAC address entered in the FritzBox node. This should of course correspond to the device whose presence you want to monitor. How to find out the MAC address(es) of devices in your network is mentioned in the article Viewing/discovering IP addresses of devices on the network.

View of the FritzBox node in which you should set the MAC address of the device to be monitored.

Define a fixed MAC address for your smartphone

Some smartphone manufacturers have meanwhile switched the MAC addresses of their devices to random changes. This is a security feature so that your smartphone cannot be tracked in a potentially foreign WiFi.

In our case, however, it is a hindrance because we identify the smartphones at the fixed MAC address. Therefore you should deactivate this function for your WLAN.

Disable random MAC address on Android 11:

Switch to:

  • Settings
  • Connections
  • WiFi
  • Click on the gear next to your (connected) WiFi
  • Extended
  • MAC address type -> set to “Telephone MAC”

Disable random MAC address on iOS:

On iOS, this function is hidden somewhat cryptically under the term “private WiFi address”. You can find them at:

  • Settings
  • WiFi
  • Network (the one you are currently connected to)
  • Private WiFi address -> deactivate

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. 🙂

Fab

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

2 comments

  1. Hallo zusammen,

    habe Eure Anleitung wie oben beschrieben angewendet.
    Leider erscheint bei mir in der “debug” Leiste folgendes:

    “No credentials set for pushbullet config.”

    wo kann ich die Anmeldeinformationen für die Pushbullet-Konfiguration festgelegen?
    Und was muss ich da genau einstellen?
    Hoffe Ihr könnt mir weiterhelfen 🙂
    Mit freundlichem Gruß
    Jürgen

Leave a Reply

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