Giter VIP home page Giter VIP logo

owrtwifi2mqtt's Introduction

A simple shell script to detect presence of Wifi devices (smartphones, tablets, Amazon Dash Buttons, ..) and post the results via MQTT. This information can be processed in Homeautomation Systems like OpenHAB to turn down the heating when everyone left the appartment.

Installation

Install the MQTT client

Install the packages

  • mosquitto-client
  • coreutils-nohup

with either luci or opkg.

Copy over the script

Use SCP to copy the presence_report script to /usr/bin/presence_report on the target device. Call chmod u+x /usr/bin/presence_report to allow script execution.

Add the script to rc.local

Place the following lines

  • nohup /usr/bin/presence_report event 192.168.1.2 >/dev/null 2>&1 &
  • nohup /usr/bin/presence_report lastseen 192.168.1.2 >/dev/null 2>&1 &

inside the /etc/rc.local file before the exit 0. You can to this via command-line or via LuCI in System -> Startup -> Local Startup. The script will be executed after reboot.

Usage

After installation the following topics will be published for each WiFi device, using the lowercase MAC address:

owrtwifi/status/mac-00-00-00-00-00-00/lastseen/iso8601

Payload contains the timestamp when the device was seen in an ISO 8601 (and OpenHAB) compatible format, like this: 2017-08-25T19:29:57+0200

owrtwifi/status/mac-00-00-00-00-00-00/lastseen/epoch

Unix epoch in seconds

owrtwifi/status/mac-00-00-00-00-00-00/event

Message will be new or del and is sent right after the device connected/disconnected to/from WiFi.

Credits

Original idea and script from Jupiter "belikh" Belic. Suggestion to use iw event from Tom "tomdee" Denham, merging these two scripts into one for easier installation by afreof.
This script follows Oliver "owagner" Wagner's architectural proposal for an mqtt-smarthome.

owrtwifi2mqtt's People

Contributors

dersimn avatar zanattabruno avatar afreof avatar zuernc 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.