Coder Social home page Coder Social logo

arp-presence-detection-mqtt's Introduction

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
  

arp-presence-detection-mqtt's People

Contributors

nightrang3r avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.