Detect iPhone presence in Node-Red

Detecting the presence of an iOS device in the network can be challenging because iOS does not respond to ICMP ping messages.
Fortunately, nmap can be used to check the host's availability.

Command of the exec-node:

nmap -sn 192.168.1.101

The function node is used to check if the response contains the string "Host is up":

return {
    payload: msg.payload.indexOf("Host is up") !== -1
};

The above flow responds with a boolean value in msg.payload that is 'true' if the device with the specified IP address is present in the network.

Show Comments