So like most I’ve experienced the network binding loosing track of mobile devices on my network; and while arping does resolve a lot of these issues, I originally created my openhab server in a different subnet/VLAN. For those who are not network savy arping does not work well in this scenario as it will resolve to the VLAN gateway IP and never change the mobile device to OFF.
So while the tasker guide I wrote up works well, I occasionally had hiccups (mainly from the wife’s phone); so I decided to let my network equipment tell me if the devices were around.
Network equipment being used (other equipment may work):
Cisco 3750
Cisco 1130s
Ubuntu server with snmpwalk (only used to test OID queries), the cisco OIDs are as follows (I also changed my internal values)
- Switch ARP entries - snmpwalk -c public -v 2c 192.168.1.1 .1.3.6.1.2.1.3.1.1.3
- AP Association – snmpwalk -c public.9.9.273.1.2.1.1.16
Items file:
Group:Switch:OR(ON, OFF) phone1V
Switch phone1 "phone1" (phone1V, gPersist) { snmp="<[192.168.1.1:public:.1.3.6.1.2.1.3.1.1.3.100.1.192.168.0.5:10000:MAP(arp.map)]" }
Switch phone1_ap1_24 "phone1 Association Ap1" (phone1V, gPersist) { snmp="<[192.168.1.2:public:.1.3.6.1.4.1.9.9.273.1.2.1.1.16.random.generated.values:10000:MAP(assoc.map)]"}
Switch phone1_ap1_5 "phone1 Association Ap1" (phone1V, gPersist) { snmp="<[192.168.1.2:public:.1.3.6.1.4.1.9.9.273.1.2.1.1.16.random.generated.values:10000:MAP(assoc.map)]"}
2 MAP transformations are required, as IPs and hex IPs are not switchable on their own:
arp.map
192.168.0.5=ON
Null=OFF
assoc.map
c0\.a8\.00\.05=ON
00\:00\:00\:00=OFF
Null=OFF
Super useful website to convert IP to hex - https://www.browserling.com/tools/ip-to-hex. Also fun discovery openhab by default requires the \ when it comes to special characters, don’t recall exactly which posting had this nugget, just keep that in mind.
After originally getting this to work I did a test run and noticed mobile devices being monitored would show up instantly, however it would take hours before it would change…another great lesson, Cisco by default has a 4 hour timeout for ARP entries. So some light googling and you can change the timeout value with this on the VLAN interface arp timeout 180
. I’m sure there is a reason for a 4 hour timeout, but so far for a home network I have not discovered any issues.
I also worked with a co-worker and did the same SNMP setup with his cisco 3560 switch and 1242 access points. We are still troubleshooting his wife’s phone, but he is also seeing the same reliability as I do.
Hopefully this will help others who want to monitor mobile devices but also want to keep openhab out of the same subnet as all your other devices.