Giter VIP home page Giter VIP logo

rpi2mqtt's Introduction

rpi2mqtt

mqtt-smarthome NPM version Dependency Status Build Status XO code style License

Connect RaspberryPi GPIOs and 1-Wire temperature sensors to MQTT ๐Ÿฐ๐Ÿ”˜๐Ÿ“ก

Install

Prerequisite: Node.js version 6.0 or above. I suggest to use https://github.com/tj/n to install a recent version of Node.js.

Install rpi2mqtt: $ sudo npm install -g rpi2mqtt

To run rpi2mqtt in background and start on system boot I suggest to use PM2.

Usage

Usage: rpi2mqtt [options]

Options:
  -c, --config         use config file                                                          [default: "~/.pi2mqtt/config.json"]
  -l, --log            log to file                                                              [default: "~/.pi2mqtt/daemon.log"]
  -v, --verbosity      possible values: "error", "info", "debug"                                [default: "error"]
  -a, --alias          alias topics. can be used multiple times. See examples                 
  -i, --in, --input    use gpio as input. can be used multiple times. See examples            
  -o, --out, --output  use gpio as output. can be used multiple times. See examples           
  -p, --payload        type of the mqtt payload. possible values are "plain" and "json"         [default: "plain"]
  -r, --retain         publish with retain flag                                               
  -t, --status-topic   topic prefix for status messages                                         [default: "hostname/status/"]
  -z, --set-topic      topic prefix for set messages                                            [default: "hostname/set/"]
  -x, --testament      topic for connect and last will message                                  [default: "connected"]
  -u, --url            broker url. See https://github.com/mqttjs/MQTT.js#connect-using-a-url    [default: "mqtt://127.0.0.1"]
  -s, --w1-wait        seconds to wait before reading /sys/bus/w1/devices/                      [default: 30]
  -n, --w1-interval    polling interval for 1-wire temperature sensors in seconds               [default: 30]
  -w, --w1-disable     disable 1-wire                                                         
  -h, --help           show help                                                              
  --version            Show version number     
  
  Examples:
    index.js -w -i 17 -i 18 -o 23             Disable 1-Wire, use GPIO17/18 as
                                              inputs and GPIO23 as output
    index.js -t -o 17 -a                      Use 1-wire and GPIO17 as output. Set
    w1/28-0000002981762:Temperature/Garden    mqtt topic aliases and remove topic
    -a gpio/17:Light/Garden                   prefix
                        

MQTT Topics

Default prefix is the hostname. You can disable the topic prefix with empty option --topic

1-Wire Temperature Sensors (DS1820)

<prefix>/status/w1/<1-wire-serial>

By default status topic is <hostname>/status, this can be changed through the command-line option --status-topic.

Example: raspberry/status/w1/28-000005908b0e

GPIO Input

<status-topic>/gpio/<gpio-number>

Example: raspberry/status/gpio/17

GPIO Output

<set-topic>/gpio/<gpio-number>

By default the set topic is <hostname>/set, this can be changed through the command-line option --set-topic.

Example: raspberry/set/gpio/23

The payload can be a plain number (0, 1) or the strings false and true.

Aliases

You can set individual topics with the --alias option.
Example: rpi2mqtt -a w1/28-000005908b0e:Temperature/Garden

If you want to use spaces in the topic use quotes around the whole -a option, like e.g. -a "w1/28-0000012345:Temperature Garden".

Mind that aliases don't affect the configured prefix. So rpi2mqtt -o 17 -a gpio/17:Light/Garden -t Raspberry5 would result in topic Raspberry5/Light/Garden for GPIO 17.

Ideas/Todo

License

MIT Copyright (c) Sebastian Raff

rpi2mqtt's People

Contributors

etobi avatar hobbyquaker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

rpi2mqtt's Issues

Example config file

Hi!
Could you please provide an example config file?
From the code I am not able to get it.

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.