2.7.17 • Published 5 years ago

mqtt-exec2 v2.7.17

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
5 years ago

mqtt-exec2

npm.io npm.io

A MQTT agent that subscribes to a list of MQTT topics and executes a script/command each time a message arrives.

Setup

npm install -g mqtt-exec2

On linux you will need to install node with a version manager to install mqtt-exe with a non-root user.

Usage

exec-mqtt --help

Usage: mqtt-exec [-i] [-u] [-b <broker url>] [-c <config path>] [-l <log path>]

Options:
  --version        Show version number                                 [boolean]
  --install, -i    Install in System Startup
  --uninstall, -u  Uninstall of System Startup
  --broker, -b     MQTT broker url                      [default: "mqtt://mqtt"]
  --config, -c     Path to json config file
  --log, -l        Log to file, let empty to use User config dir
                   (eg: C:\Users\mtbox\.mqtt-exec)
  --help           Show help                                           [boolean]

	Examples:
	  mqtt-exec                                 Use default mqtt broker
	                                            (mqtt://mqtt:1883) and config.json
	                                            file present in user config
	                                            directory, eg:
	                                            C:\Users\mtbox\.mqtt-exec
	                                            No logs to file

	  mqtt-exec -i                              Install at startup, with default
	                                            mqtt broker (mqtt://mqtt:1883) and
	                                            config.json file present in user
	                                            config directory, eg:
	                                            C:\Users\mtbox\.mqtt-exec
	                                            No logs to file

	  mqtt-exec -i -l                           Install at startup, with default
	                                            mqtt broker (mqtt://mqtt:1883) and
	                                            config.json file present in user
	                                            config directory, eg:
	                                            C:\Users\mtbox\.mqtt-exec
	                                            Logs are send to a file in user
	                                            config directory.

	  mqtt-exec -b                              Connect to broker 'mqtt', on port
		mqtt://myname:secretpasswd@mqtt:8883 -c   8883 with config.json parameter      
	  config.json                               file.

	  mqtt-exec -i -c /home/pi/config.json -l   Install at startup, using
	                                            /home/pi/config.json file, log to
	                                            file in user config directory,
	                                            eg: C:\Users\mtbox\.mqtt-exec

	  mqtt-exec -i -c Z:\config.json            Install at startup, using
	                                            Z:\config.json file, no log recorded

	  mqtt-exec -u                              Uninstall from system startup

Configuration

Create a configuration file "config.json" and put it in your user folder (~/.mqtt-exec for linux or %userprofile%\.mqtt-exec for windows).

Windows example

{
  "exec/mypc":	{
    "foobar2000" : "\"K:/Program Files/foobar2000/foobar2000.exe\"",
    "shutdown" : "\"C:/Windows/System32/shutdown.exe\" /s",
    "calc" : "calc"
  }
}

Linux example

{
  "/home/devices/livingroom/light1/value/set":  {
    "true"  : "sudo /home/pi/rcswitch-pi/sendRev B 1 1",
    "false" : "sudo /home/pi/rcswitch-pi/sendRev B 1 0"
  },
  "/home/devices/livingroom/light2/value/set":  {
    "true"  : "sudo /home/pi/rcswitch-pi/sendRev B 2 1",
    "false" : "sudo /home/pi/rcswitch-pi/sendRev B 2 0"
  }
}

Credit

Thank to Dennis Schulte creator of mqtt-exec. It's config.json concept is re-used here.

Licence

Copyright © 2018-present, macro-toolbox.com. Released under the MIT License.

2.7.17

5 years ago

2.7.16

5 years ago

2.7.15

5 years ago

2.7.14

5 years ago

2.7.13

5 years ago

2.7.12

5 years ago

2.7.11

5 years ago

2.7.10

5 years ago

2.7.9

5 years ago

2.7.8

5 years ago

2.7.7

5 years ago

2.7.6

5 years ago

2.7.5

5 years ago

2.7.4

5 years ago

2.7.3

5 years ago

2.7.2

5 years ago

2.7.1

5 years ago

2.7.0

5 years ago

2.6.6

5 years ago

2.6.5

5 years ago

2.6.4

5 years ago

2.6.3

5 years ago

2.6.2

5 years ago

2.6.1

5 years ago

2.6.0

5 years ago

2.5.6

5 years ago

2.5.5

5 years ago

2.5.4

5 years ago

2.5.3

5 years ago

2.5.2

5 years ago

2.5.1

5 years ago

2.5.0

5 years ago

2.4.1

5 years ago

2.4.0

5 years ago

2.3.2

5 years ago

2.3.1

5 years ago

2.3.0

5 years ago

2.2.1

5 years ago

2.2.0

5 years ago

2.1.0

5 years ago

2.0.0

5 years ago