Coder Social home page Coder Social logo

junavarg / dragonrise Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 2.0 14.15 MB

The dragonrise program allows monitor and publish in a MQTT broker the status of the 14 sensor switches of the “Generic USB joystick” controller card from DragonRise Inc.

Home Page: https://junavarg.github.io/dragonrise/

Go 87.20% Shell 12.80%
home-automation home-assistant go raspberry-pi buttons switches sensors mqtt-client mqtt-publisher mqtt usb joystick linux

dragonrise's Introduction

alt text

Introduction

The dragonrise program allows:
  • Monitor and returns by stdout a JSON structure with the status of the 12 switches (and 2 three position switches) of the popular “Generic USB joystick” controller card from DragonRise Inc.
  • Publish the status of these switches to a server or MQTT broker every time a change occurs in any of them.
  • It is written in Golang so it is a direct executable on the processor (it does not require a runtime) and it can work in the background as a daemon or service. The same process allows multiple controller cards to be monitored which is ideal for applications requiring a high number of switches.

    It allows transporting the MQTT protocol over TCP or over Websockets, including the encrypted version over TLS. In the latter case, the inclusion of the certificates of the MQTT server trust chain is not required.

    Oriented to run on single-board computers (SBC), being written in Golang, it can run on Linux or even, with the necessary modifications, on Windows. Along with the program, a UDEV rules file is included to ensure the order and correct identification of the controller cards according to the USB port where they are plugged in.

    More info: https://junavarg.github.io/dragonrise/

    Instalation

    Install binary in rpi

    Download and execute the install script

    $ wget -O - https://raw.githubusercontent.com/junavarg/dragonrise/master/bin/rpi/install.sh | sudo bash

    This script:

  • Download de executable, copy it in /usr/local/bin, and change permissions to 777
  • Create directory for state files in /var/lib/dragonrise, with owner root and change permissions to 777
  • Download a UDEV rule file with name 31-dragonriseRPi.rules, copy it to /etc/udev/rules.d/ and reload the rules with udevadm command.

    NOTE: If a USB HUB is used, it will be necesary change accordingly the rules.

  • Start de service and configure in systemd for autostart
  • Download uninstall-dragonrise.sh script
  • Install binary in Linux intel x64/amd64

    1) Download the binary-executable

    wget https://raw.githubusercontent.com/junavarg/dragonrise/master/bin/linux-amd64/dragonrise

    2) Copy it in /usr/local/bin, and change permissions to 777

    3) Create directory for state files in /var/lib/dragonrise, with owner root and change permissions to 777

    4) Create a UDEV rule file (for example 31-dragonrise.rules) in /etc/udev/rules.d/ and reload the rules with udevadm command.

    Install from sources

    Install golang compiler

    $ sudo apt-get install golang

    $ wget -O - https://raw.githubusercontent.com/junavarg/dragonrise/master/install-from-sources.sh | sudo bash

    Use

    Use: dragonrise [options] [device_file1] [device_file2]…

    Options:

       -mqpub

       Specify the MQTT broker URL and the root of a topic (basetopic) where to post the status every time an event occurs. The url format is

       protocol://[user[:password]@]host.domain.tld:port/base_topic

       Options for protocol: tcp, ssl, ws, wss

       Examples:

         -mqpub = tcp://host.domain.dom:1883/base_topic

         -mqpub = ssl://[email protected]:8883/base_topic

         -mqpub = ws://host.domain.dom:80/base_topic

         -mqpub = wss://pepe:[email protected]:443/base_topic

       -mqpub2

       -mqpub3

         Two additional brokers to which the program sends events

    The messages are published in 'clean session' with qos 0 and with 'retained flag' so that on each new connection the subscriber receives a message with the current status.

    Examples

    $ dragonrise

    Try to read switch status and events from a USB joystick card in /dev/input/js0 (default). In a Raspberry Pi, /dev/input/js0 normally will correspond to the first USB joystick card conected to any USB port. Program is alwais running until is killed (e.g., with ctrl-c). If device file is not present, program reintent open it every 1 second. Status is printed in stdout in JSON, for example: Info and errors are printed in stderr.

    $ dragonrise /dev/input/js0 /dev/input/js1 2>/dev/null

    Try to read switch status and events from /dev/input/js0 and /dev/input/js1. Program does not show info or errors Without the proper UDEV rule there is no way to warrant which USB card correspond to which device file (/dev/input/js0 or /dev/input/js1).

    $ dragonrise /dev/dragonrise_3

    Try to read switch status and events from a USB joystick card connected to USB number 3 (/dev/dragonrise_3) and no other, thanks to a UDEV rule that makes the correct mapping. In a Raspebrry Pi USB 3 corresponds to external USB port number 2 (USB number 1 correspond to ethernet NIC).

    $ dragonrise -mqpub=tcp://test.mosquitto.org:1883/base_topic /dev/dragonrise_3

    Publish in topic /base_topic/dragon_rise/event of MQTT broquer in url test.mosquito.org using transport tcp in clear with port 1883 (standard)

    $ nohup dragonrise -mqpub=tcp://test.mosquitto.org:1883/base_topic /dev/dragonrise_3 2>/dev/null 1>/dev/null &

    Execution in background (as a daemon). System return PID.

    dragonrise's People

    Contributors

    junavarg avatar

    Stargazers

     avatar  avatar

    Watchers

     avatar

    Forkers

    ai-ros pictux

    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.