[SOLVED] Presence detection with Network binding - false positive

I have a lot of false positive. I am on Ubuntu with iputils-arping.
A lot of times my Android phones are online but i am not connected with Wifi. Why it happens?

$ which arping
/usr/sbin/arping

network.cfg

binding.network:allowSystemPings=true
binding.network:allowDHCPlisten=false
binding.network:arpPingToolPath=arping
binding.network:cacheDeviceStateTimeInMS=2000

network.things

Thing network:pingdevice:Smartphone [ hostname="192.168.1.232", timeout=5000, refreshInterval=20000, retry=3 ]

network.items

Group:Switch:AND(OFF,ON)  gPresence
Switch Smartphone (gPresence) { channel="network:pingdevice:Smartphone:online" }

log

2019-10-29 08:58:36.037 [GroupItemStateChangedEvent] - gPresence changed from OFF to ON through Smartphone

gPresence changed from OFF to ON through Smartphone but I am not at home, so it is a false positive.

I tried to ping my phone from shell:

$ arping 192.168.1.232
ARPING 192.168.1.232
Timeout
Timeout
Timeout
Timeout
Timeout
Timeout
60 bytes from bb:6f:b4:0b:9a:32 (192.168.1.232): index=0 time=105.648 msec
Timeout

But bb:6f:b4:0b:9a:32 is not the phone and 192.168.1.232 is static assigned by DHCP

In network.cfg try adding uses_arp_pings=yes so file will look like this.

binding.network:allowSystemPings=true
binding.network:allowDHCPlisten=false
binding.network:arpPingToolPath=arping
binding,network:cacheDeviceStateTimeInMS=2000
uses_arp_pings=yes

Had to tweek the setting in my things file but this is what I found to work for me.

Things:

Thing network:pingdevice:SiPhone [ hostname="10.0.1.22", uses_ios_wakeup=1, uses_arp_pings=1, retry=30, timeout=15000, refreshInterval=60000 ]

Items:

Group:Switch:AND(OFF,ON) gPresent <present>
Switch Present "Phone is home" <present>
Switch Present_Timer { expire="20m, command=OFF" }
Switch MyDevice <network> (gPresent) { channel="network:pingdevice:SiPhone:online" }

Rule associated with presents detection:

rule "start gPresent on system start"
when
    System started
then
    Present.sendCommand(OFF) // assume no one is home
end

rule "gPresent updated, at least one change of state"
when
    Item gPresent received update
then
    // someone came home
    if(gPresent.state == ON && Present.state != ON) { 
        Present_Timer.postUpdate(OFF) // cancel the timer if necessary
        Present.sendCommand(ON)
    }

    // no one is home and timer is not yet ticking (otherwise endless loop)
    else if(gPresent.state == OFF && Present.state != OFF && Present_Timer.state != ON) {
        Present_Timer.sendCommand(ON) // start the timer
    }
end

rule "Present_Timer expired"
when
	Item Present_Timer received command OFF
then
	Present.sendCommand(OFF)
end

The extra items and rule prevents other things from happening if presents swaps from on to off for a short time e.g. I walk to mail box and loose signal.

I’m trying

binding.network:arpPingToolPath=/bin/ping

and seems to work better

Anyway I prefer Design Pattern: Sensor Aggregation