Git Product home page Git Product logo

puckjs2mqtt's Introduction

puckjs2mqtt

A RuuviTag -> MQTT bridge supporting Home Assistant MQTT discovery.

Based on the excellent EspruinoHub and very much a work in progress.

Setting up

Ideally use a Raspberry Pi 3 or Zero W, as these have Bluetooth LE on them already. However the BLE USB dongles mentioned in the Puck.js Quick Start guide should work.

Get Raspbian running on your Raspberry Pi

  • Download Raspbian Lite from https://www.raspberrypi.org/downloads/raspbian/
  • Copy it to an SD card with sudo dd if=2017-11-29-raspbian-stretch-lite.img of=/dev/sdc status=progress bs=1M on Linux (or see the instructions on the Raspbian download page above for your platform)
  • Unplug and re-plug the SD card and add a file called ssh to the boot drive - this will enable SSH access to the Pi
  • If you're using WiFi rather than Ethernet, see this post on setting up WiFi via the SD card
  • Now put the SD card in the Pi, apply power, and wait a minute
  • ssh [email protected] (or use PuTTY on Windows) and use the password raspberry
  • Run sudo raspi-config and set the Pi up as you want (eg. hostname, password)

Installation

# Install Node, Bluetooth, etc
sudo apt-get update
sudo apt-get install git-core nodejs nodejs-legacy npm build-essential mosquitto mosquitto-clients bluetooth bluez libbluetooth-dev libudev-dev
# Now get puckjs2mqtt
git clone https://github.com/ppetru/puckjs2mqtt
# Install puckjs2mqtt's required Node libraries
cd puckjs2mqtt
npm install
# Optional - enable gathering of historical data by creating a 'log' directory
mkdir log
# Give Node.js access to Bluetooth
sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)

You can now type ./start.sh to run puckjs2mqtt, but it's worth checking out the Auto Start section to see how to get it to run at boot.

Auto Start

There are a 2 main ways to run puckjs2mqtt on the Raspberry Pi.

Headless Startup

This is the normal way of running services - to configure them as a system start-up job using systemd:**

    sudo cp systemd-puckjs2mqtt.service /etc/systemd/system/puckjs2mqtt.service

and edit it as necessary to match your installation directory and user configuration. Then, to start it for testing:

    sudo systemctl start puckjs2mqtt.service && sudo journalctl -f -u puckjs2mqtt

If it works, Ctrl-C to break out and enable it to start on login:

    sudo systemctl enable puckjs2mqtt.service

Console Startup

If you have a video output on your Pi then you can run puckjs2mqtt at boot - on the main display - so that you can see what it's reporting.

  • Edit .bashrc and add the following right at the bottom:
if [ $(tty) == /dev/tty1 ]; then
  while true; do
    puckjs2mqtt/start.sh
    sleep 1s
  done
fi
  • Now run sudo raspi-config, choose Boot Options, Desktop / CLI, and Console Autologin

  • Next time you reboot, the console will automatically run puckjs2mqtt

Usage

TBD

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.