Using that I never see one of my devices go home/not_home when they shouldn’t in the log book. That, combined with the multiple triggers and conditions I described above has resulted in pretty reliable automations based on home/away status.
It works reliably for me. I have my HA devices locked down to those reserved IPs so I can have nmap survey a narrow range of IPs.
Also helps in locking down what is discovered in HA and eliminates a bunch of noise in the device_trackers as guests connect or I bring home a work computer ect. Track what you want to track, ignore the rest.
I guess the problem is more with false negatives (away from home when someone is home), than with false positives (thinking someone is home when they aren’t). So do you just compare the responses from each of these and if one of them says you are home, then you’re home??
Wait 5 minutes before setting the state away, set hoe as soon as any tracker is detected.
I found the ble tracker using PI3 and the gpsloger are the most reliable
- alias: 'Set Anil Away'
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.anilhome
state: 'on'
- condition: state
entity_id: device_tracker.pixel_bt #bluetooth
state: 'not_home'
- condition: state
entity_id: device_tracker.ac37434ce86a #nmap
state: 'not_home'
- condition: or
conditions:
- condition: state
entity_id: device_tracker.anils6_pixel #owntracks
state: 'not_home'
- condition: state
entity_id: device_tracker.anils6_pixel
state: 'away'
- condition: state
entity_id: device_tracker.anils6_pixel
state: 'Work'
trigger:
- platform: state
entity_id: device_tracker.pixel_bt
state: 'not_home'
for:
minutes: 5
- platform: state
entity_id: device_tracker.anils6_pixel
state: 'not_home'
for:
minutes: 5
- platform: state
entity_id: device_tracker.anils6_pixel
state: 'Work'
for:
minutes: 5
- platform: state
entity_id: device_tracker.ac37434ce86a
state: 'not_home'
for:
minutes: 5
action:
- service: homeassistant.turn_off
entity_id: input_boolean.anilhome
- alias: 'Set Anil Home'
condition:
condition: state
entity_id: input_boolean.anilhome
state: 'off'
trigger:
- platform: state
entity_id: device_tracker.pixel_bt
state: 'home'
- platform: state
entity_id: device_tracker.anils6_pixel
state: 'home'
- platform: state
entity_id: device_tracker.ac37434ce86a
state: 'home'
- platform: state
entity_id: device_tracker.4cd5eae084d35a83
state: 'home'
for:
seconds: 30
action:
service: homeassistant.turn_on
entity_id: input_boolean.anilhome
@anilet Slightly OT, but just to address this question - if you use three back ticks ( ` ) on a line by themselves at the top and bottom of your code when you paste it in, it will maintain your formatting, and show up in a code box.
Like This
I am sure this used to be in a help dialog somewhere, but when I went looking for it to point you in the right direction, I didn’t see it anywhere.
I use iBeacons for home presence detection and it has been very reliable. I have 4 beacons around the house and use OwnTracks to monitor them with iPhones. I can reliably determine when any combination of my wife and I are home or not home. I also have an iBeacon in my car and use that with GPS to detect when I’m in the car (or garage) or detect presence at work or the gym. The problem with GPS/Owntracks alone was that it sometimes took a while to update and GPS may not work well when you’re in a building. Network-based tracking (nmap, routers, pings, ARP scanning, etc.) didn’t work well because of the iPhone’s quirky behavior related to sleeping and network access.
Anyone ever use 2 nmaps, or 2 subnets? I recent added on to split all the cameras & HA stuff off the main lan (was getting bogged down) and now my nmap is unreliable. I think it is scanning 1 (where the cellphones are) and the the other (where most the devices are) and updating that the phones are away.
I want to track the phones and the devices as both are used in automations.
I’m thinking not. I removed the x.x.2.x and am not seeing anything on x.x.1.x. Previously I had HA on the .1.x subnet and today moved it to the .2.x. I was not seeing any errors so I thought it was connecting to the .1.x router but perhaps not.
So I ran nmap -F 192.168.1-2.1-254 from the command line of my HASS Pi on the .2.x subnet and got:
Starting Nmap 6.47 ( http://nmap.org ) at 2017-01-02 12:33 CST
Nmap scan report for 192.168.1.64
Host is up (0.024s latency).
Not shown: 99 closed ports
PORT STATE SERVICE
8080/tcp open http-proxy
Nmap scan report for 192.168.1.65
Host is up (0.0029s latency).
All 100 scanned ports on 192.168.1.65 are closed
Nmap scan report for 192.168.1.69
Host is up (0.022s latency).
Not shown: 99 closed ports
PORT STATE SERVICE
8080/tcp open http-proxy
Nmap scan report for 192.168.1.76
Host is up (0.0054s latency).
Not shown: 98 closed ports
PORT STATE SERVICE
23/tcp open telnet
80/tcp open http
Nmap scan report for 192.168.1.77
Host is up (0.13s latency).
Not shown: 98 closed ports
PORT STATE SERVICE
80/tcp open http
8888/tcp open sun-answerbook
Nmap scan report for 192.168.1.82
Host is up (0.11s latency).
Not shown: 99 closed ports
PORT STATE SERVICE
5060/tcp open sip
Nmap scan report for 192.168.1.83
Host is up (0.0093s latency).
All 100 scanned ports on 192.168.1.83 are closed
Nmap scan report for 192.168.1.84
Host is up (0.053s latency).
Not shown: 93 closed ports
PORT STATE SERVICE
80/tcp open http
139/tcp open netbios-ssn
443/tcp open https
445/tcp open microsoft-ds
631/tcp open ipp
8080/tcp open http-proxy
9100/tcp open jetdirect
Nmap scan report for 192.168.1.95
Host is up (0.00097s latency).
Not shown: 95 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
548/tcp open afp
631/tcp open ipp
8443/tcp open https-alt
Nmap scan report for 192.168.1.189
Host is up (0.0037s latency).
Not shown: 98 closed ports
PORT STATE SERVICE
8008/tcp open http
8081/tcp open blackice-icecap
Nmap scan report for 192.168.1.254
Host is up (0.0018s latency).
Not shown: 97 closed ports
PORT STATE SERVICE
80/tcp open http
443/tcp open https
49152/tcp open unknown
Nmap scan report for 192.168.2.1
Host is up (0.00076s latency).
Not shown: 95 closed ports
PORT STATE SERVICE
53/tcp open domain
80/tcp open http
548/tcp open afp
631/tcp open ipp
5000/tcp open upnp
Nmap scan report for 192.168.2.3
Host is up (0.0024s latency).
All 100 scanned ports on 192.168.2.3 are closed
Nmap scan report for 192.168.2.4
Host is up (0.016s latency).
Not shown: 99 closed ports
PORT STATE SERVICE
443/tcp open https
Nmap scan report for 192.168.2.5
Host is up (0.031s latency).
Not shown: 99 closed ports
PORT STATE SERVICE
443/tcp open https
Nmap scan report for 192.168.2.6
Host is up (0.052s latency).
All 100 scanned ports on 192.168.2.6 are closed
Nmap scan report for 192.168.2.7
Host is up (0.0095s latency).
Not shown: 92 closed ports
PORT STATE SERVICE
135/tcp open msrpc
139/tcp open netbios-ssn
445/tcp open microsoft-ds
554/tcp open rtsp
5357/tcp open wsdapi
49152/tcp open unknown
49153/tcp open unknown
49154/tcp open unknown
Nmap scan report for 192.168.2.8
Host is up (0.00013s latency).
All 100 scanned ports on 192.168.2.8 are closed
Nmap scan report for 192.168.2.9
Host is up (0.0086s latency).
All 100 scanned ports on 192.168.2.9 are closed
Nmap scan report for 192.168.2.100
Host is up (0.00026s latency).
Not shown: 97 closed ports
PORT STATE SERVICE
22/tcp open ssh
139/tcp open netbios-ssn
445/tcp open microsoft-ds
Nmap scan report for 192.168.2.105
Host is up (0.0066s latency).
Not shown: 96 closed ports
PORT STATE SERVICE
23/tcp open telnet
554/tcp open rtsp
5000/tcp open upnp
49152/tcp open unknown
Nmap scan report for 192.168.2.106
Host is up (0.00071s latency).
All 100 scanned ports on 192.168.2.106 are closed
Nmap scan report for 192.168.2.107
Host is up (0.00069s latency).
All 100 scanned ports on 192.168.2.107 are closed
Nmap done: 508 IP addresses (23 hosts up) scanned in 16.03 seconds
Appears all is well (I am not an expert) but when I used it in device_tracker it still did not work to update the statuses
So reading up on nmap, it is/can screen across multiple subnets but it will not receive the MAC address on subnets other than the computer it is running on.
So I need a workaround. Anyone know how to get HASS to connect to an ARRIS/PACE 5268AC to get the information direct?
OR perhaps run a Master/Slave HASS across the different subnets? hmmm, I wonder if they could then share the information.
I may end up doing this as I have a spare Pi but I have come across something else - but will probably need a networking guru to help me figure it out.
I have a server (running Ubuntu Server & Zoneminder only atm) that I could add HA to. This server has 4 NIC ports(?). In theory I could attach both subnets, run HA and it see both subnets… I think.
Not a very green solution but the server has mucho idle time and has a UPS on it so…