Skip to content

NightRang3r/Arp-Presence-Detection-MQTT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Arp-Presence-Detection-MQTT

Description

This script is a based on https://github.com/initialstate/pi-sensor-free-presence-detector

Scans MAC Addresses using arp-scan and sends message to mqtt broker to determine occupancy.

Requirements

  • Python 2.7
  • paho-mqtt
  • arp-scan

Get The Script

~# cd /home/pi
~# wget https://raw.githubusercontent.com/NightRang3r/Arp-Presence-Detection-MQTT/master/presence.py

You will need to adjust the script with your own parameters in the settings section:

MQTT_HOST = "127.0.0.1" - Your MQTT Broker IP Address
MQQT_USER = "mosquitto" - MQTT Broker User Name
MQTT_PASS = "12345678" - MQTT Broker Password
MQTT_TOPIC = "presence" - MQTT Broker Topic
T_SLEEP = 30 - Scan Interval
INTERFACE = "eth0" - Network Interface
DEVICES= {"Bob": "00:00:00:00:00:00", "Alice":"01:01:01:01:01:01"} - List of devices, you can add more devices.

Install paho-mqtt

~# sudo pip install paho-mqtt

Install arp-scan

~# sudo apt-get update
~# sudo apt-get install arp-scan

Create service

~# cd /etc/systemd/system/

Create a new file

~# sudo nano presence.service

Paste this into the new file and save:

[Unit]
Description=Presence
Wants=network.target
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/python /home/pi/presence.py
User=root

[Install]
WantedBy=multi-user.target

~# sudo chmod 755 presence.service
~# sudo systemctl daemon-reload
~# sudo systemctl enable presence.service
~# sudo systemctl start presence.service
~# sudo systemctl status presence.service
~# sudo reboot

Home assistant configuration example

device_tracker.yaml:

- platform: mqtt
  devices:
    bob_arp: presence/bob
    alice_arp: presence/alice
    

known_device.yaml (devices will be generated automatically, just change track value to true):

bob_arp:
  hide_if_away: false
  icon:
  mac:
  name: Bob
  picture:
  track: true

alice_arp:
  hide_if_away: false
  icon:
  mac:
  name: Alice
  picture:
  track: true
  

About

Presence Detection using arp-scan for home assistant

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages