Giter Club home page Giter Club logo

mqrt's Introduction

MQRT

Small MQTT router. Allows creating multiple inputs/outputs and run action when input triggers.

Features

  • multi-(input/output)
  • multiple actions tied to the same trigger
  • JavaScript filtering (run JS to check if message contains what you are interested in)
  • JavaScript payload builder (run JS to build output message based on input message)

Configuration (incomplete):

# Define some input (name - "_" can be anything)
[input._]
type = "mqtt"
host = "127.0.0.1"
port = 1883

# ... with a number of triggers
[input._.trigger.single_click__hall_entrance_switch]
topic = 'zigbee2mqtt/hall_entrance_switch'
filter = { type = "json", field = "action", exact = "single_left" }
# ----- Note, that filter can also pass everything (default)
# filter = { type = 'no_filter' }
# ----- drop everything
# filter = { type = 'drop_all' }
# ----- check with JavaScript
# filter = { type = 'js', code = '''
# return JSON.parse(payload)['temperature'] > 20
# '''}

##############################
##############################

# Define some output (name - "_" can be anything)
[output._]
type = "mqtt"
host = "127.0.0.1"
port = 1883

# ... with a number of actions
[output._.action.toggle_hall_light]
topic = 'zigbee2mqtt/hall_light_main'
payload = { type = 'static', data = '{"action": "toggle"}' }
# ----- Note, that payload can be dropped
# payload = { type = 'drop' }
# ----- passthrough (which is default)
# payload = { type = 'passthrough' }
# ----- of JavaScript code (consider the performance impact in this case)
# payload = { type = 'js', code = '''
#   let x = JSON.parse(payload); x.volume += 1; return JSON.stringify(x);
# ''' }
# ----- or
# payload = { type = 'js', code = 'payload.split(",")[0]' }

##############################
##############################

# Now, specify which action should be executed on trigger
[[handler]]
on = { input = "_", trigger = "single_click__hall_entrance_switch" }
do = { output = "_", action = "toggle_hall_light" }

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.