Git Product home page Git Product logo

vera-mqtt's Introduction

MQTT Client Plugin

This plugin provides the ability to publish out any user defined variable to an MQTT Broker. It is based on the code found here This is my first plugin so odds are there will be some bugs although so far seems to be working fine.

This plugin is designed for use on systems running UI7.

Features

User defined Variables to watch
User defined Device Alias which makes Logic much more intuitive and makes it easier when replacing devices

MQTT Message Example

Code:

{"Payload":{"DeviceId":45,"OldOnOff":"1","OnOff":"0","Time":1453209965},"Topic":"Vera/Events/TestSocket"}

Installation and Configuration

Upload the attached files
Create a new device with device_file set to D_SensorMqtt1.xml
Set desired variable watches on the Watchdog tab
(optional) Set desired Alias on the Alias tab
Have fun

Dependencies

There are a few dependencies that should be copied to /usr/lib/lua folder

Modifications for subscription

You can subscribe to a topic by creating a child device :

  1. Add a new device and choose a type (e.g. "D_BinaryLight1.xml" or "D_TemperatureSensor1.xml").
  2. Reload LUUP engine.
  3. Change the attribut "id_parent" with the id of the MQTT plugin device.
  4. Reload LUUP engine and refresh your browser.
  5. You should see variables "mqttTarget" and "mqttTopic" in your newly created device.
  6. Set the topic you want to subcribe to and the target (format: service,variable=(formula in LUA)).
  7. Reload LUUP engine.

If the payload of the received message is in JSON, the plugin will try to decode it and put it in the variable "payload" in the context of the LUA formula.

Examples :

Topic  : Test/#
Target: urn:upnp-org:serviceId:SwitchPower1,Status=payload.value and ((payload.value=="alarm") and "1" or "0")

On a message from topic 'Test/Something' with payload '{"value":"alarm"}', the switch will be powered on.

Topic  : Test/+/Sensor
Target: urn:upnp-org:serviceId:TemperatureSensor1,CurrentTemperature=payload.temperature and (tonumber(payload.temperature) or "0")

On a message from topic 'Test/Something/Sensor' with payload "{"temperature ":"15.2", "hygrometry":"80"}", the temperature will be set to 15,2.

vera-mqtt's People

Contributors

bblacey avatar dklinkman avatar jonferreira avatar vosmont avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

madwoodworker

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.