Git Product home page Git Product logo

mqtt-homie's Introduction

Build Status

MQTT::Homie

A ruby interface for creating a device conforming to the MQTT Homie convention. This gem builds upon the ruby-mqtt ruby gem.

The Homie convention defines a standardized way of how IoT devices and services announce themselves and their data to a MQTT broker.

Installation

Add this line to your application's Gemfile:

gem 'mqtt-homie'

And then execute:

$ bundle

Or install it yourself as:

$ gem install mqtt-homie

Quick Start

require 'rubygems'
require 'mqtt/homie'

# Set up a device, with a node and properties
device = MQTT::Homie.device_builder(id: 'device', name: 'Device')
  .node(id: "gate", name: "Front gate", type: "Gate")
  .property(id: "state", name: "Gate state", enum: [:open, :closed, :opening, :closing], value: :closed)
  .property(id: "position", name: "Gate position", datatype: :integer, unit: "%", value: 0)
  .property(id: "command", name: "Send gate command", settable: true, enum: [:open, :close]).build

# Create a client and connect to a MQTT broker
client = MQTT::Homie::Client.new(device: device, host: 'localhost')
client.connect

# access nodes and properties of the device
node = device.node('gate')
state = node.property('state')
state.value = :open  # publishes new state to MQTT

# listen for changes to properties via the Observer interface
node.property('command').add_observer(self)

Overview

TODO

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Mqtt::Homie project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

mqtt-homie's People

Contributors

sobakasu 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.