Device Tracker with PFSENSE router

Working well for me, appreciate this.

I was in the middle of adapting my system to use this pfSense/cron job when I scrolled down and saw the SNMP component. It configured right up and is working great! Thank you!

I find that I canā€™t see wifi_5G iphone

Hello,

How long it takes to detect home stat?
Best regards

Iā€™m so sorry, Iā€™ve been gone from the forums for a while. To answer your question, the detection is based upon your interval_seconds line. It also depends on which devices your using to detect presence. I use our phones. If we happen to turn off wifi on the phone while gone then it doesnā€™t detect us at all! However, if our wifi is on it is pretty quick. I also use it to know which computers are on throughout the house, which is also handy.

mine was working after i update the unifi controler, but the when we arrived was ok about one minute or so , when we were away tokked much more about 9 to10 min.

iā€™m using the mac adress to detect.

but now it donā€™t detect:(

sorry it was other suject that i was refering.

Does this integration work under 0.105?
Iā€™m struggling with: ā€œConfiguration invalidā€ ā€œPlatform error device_tracker.pfsense - Integration ā€˜pfsenseā€™ not found.ā€

I created the pfsense.py file in the device_tracker folder under custom_components. Do i need a manifest.json file or __init__.py or something else?

Sorry Iā€™m not sure, I havenā€™t used pfsense for a few years now and HA has changed a ton.

Okay, i knew it was a long shot. Thank you for your quick reply though :slight_smile:

Iā€™m using pfsense with SNMP and it works fine. I use this configuration:

device_tracker:
  - platform: snmp
    host: 10.0.0.254
    community: !secret community
    baseoid: 1.3.6.1.2.1.4.22.1.2
1 Like

Nice! I will look into that solution :+1:

Got it working already :nerd_face:

Two questions:

  1. How fast does the device update. Is it based upon the DHCP leases? It seems that the online to offline state is quit slow but the offline to online state is fast.
  2. Is it possible to import hostname of af new device?

Itā€™s not from DHCP, it is the table of all devices in the network. Youā€™ll find a description here:

As for speed it works fast enough for my use - and as far as I can tell the limiting factor is my phone taking some time before it actually finds and connects to my wifi.

The MAC addresses from are updated by the pfSense ARP (Address Resolution Protocol) table. Default is 20 minutes from last time the ARP cache saw the device in question.

You can monitor the ā€œexpirationā€ by logging into pfSense and go to Diagnostics > ARP Table, you will see all the devices and a second-value counting down. It is updated either when there is traffic from the device thru the router, or when a device replies to an ARP request packet on the network and the router hears it. Some things play better than others (our LG Android phones seem to not update the table as often as computers and tablets).

The expiration is set by a kernel variable which you can add a custom value to adjust if you want a shorter time. The risk if itā€™s too short is there will be more ARP resolution traffic on your network and things may show as ā€œnot onlineā€ when they really are. Probably not a big deal on a small home network to go as low as 5 minutes, but I found I had to go up to 6 minutes with a ā€œconsider homeā€ of 6 minutes to avoid some phones dropping out when they are really still home.

The default value is 20 minutes for ARP purging. You can go to System > Advanced > Tunables, and modify (create) ā€œnet.link.ether.inet.max_ageā€ value in seconds. For 6 minutes, I set it to 360.

For the Hassio tracker, I found this worked most reliably (avoiding false-negatives - I really donā€™t want lights and radios going on-off scaring us when we are home but phones are idle)

# pfSense device tracker
# Useful command to browse SNMP output: "snmpwalk -Os -c public -v 2c 192.168.1.1"
device_tracker:
  - platform: snmp
    host: 192.168.1.1
    community: public
    baseoid: .1.3.6.1.2.1.4.22.1.2
    interval_seconds: 20
    consider_home: 360

I also strongly recommend you only turn on the SNMP features you use, just to cut down on what might be exposed and what resources might be used.

Under Services > SNMP I found the only thing I needed to leave enabled was ā€œSNMP modules: MibIIā€ and I also restricted it only to the VLAN/Interface that my trusted network devices are sitting on.
image

One other note, I also found I could fiddle with the SNMP string to get Hassio to see all VLANs all devices, or only one VLAN of devices (using SNMPwalk command, looking at output) but I donā€™t know if itā€™s a predictable pattern (e.g. VLAN-ID, or ???). This could be useful if you REALLY only care about tracking devices on a specific VLAN vs tracking all VLANs.

As for hostnameā€¦I havenā€™t looked into that, I have duplicate hostnames because some people have the same model of phone and they all show as ā€œBRAND-MODELā€ which is useless if I canā€™t tell which is what. I make a ā€œpersonā€ for each ā€œthingā€ I want to track, and add the relevant MAC addresses to it. For example, my TV is ā€œa personā€ so I can track if itā€™s on or off, as is my HTPC (with both network MAC addresses added to the ā€œpersonā€). The hostname thing also gets funky with stuff that doesnā€™t properly report a hostname (e.g. static IP devices) but the MAC addresses work on everything, nomater what.

If you really want to investigate what else you can pull, look at the snmpwalk command and you can manually browse thru everything that pfSense is reporting looking for fields of interest.

8 Likes

The is excellent explanation. Answered so many questions i did not yet ask. Thank you for your thorough walk through the configurations and nubs to tweak.
I will disable the SNMP modules that are not in use and good point about the hostname.

1 Like

Thanks for that detailed info. One thing that can help make the states a lot more reliable is to combine this with something like owntracks (or any other sensor) in a bayesian sensor configuration.

1 Like

Hey mmiller7, Thank you for this great explanation!

Just wondering.
As mentioned some devices like iPhone likes to go sleep and can then appair away.
Can this be overridden by setting a shorter maximum lease time?
Then the device might be forces to wake up to re-lease the address? Anyone know?

Hey everyone! Iā€™ve put together a new integration for pfSense which device_tracker support among other things. No need for fauxapi.

2 Likes