MQTT & Exec Binding: Round Robin input --> output

Disclaimer: I’m using PaperUI and not going to be using scripting or files. Because, reasons.

I have a small command line program on an OpenHabian PI which does great things. Let’s call it some-cli.

I can run /home/openhabian/some-cli --foo=bar no problem at all, as it requires no privileges and works fine in the simplest way. There are no problems with the CLI program itself. It prints out some JSON once it has done some work.

In /etc/openhab2/misc/exec.whitelist, it has the following entries:

/home/openhabian/some-cli cmd1 --option=false %2$s
/home/openhabian/some-cli cmd2 --option=false %2$s
/home/openhabian/some-cli cmd3 --option=false %2$s

I have 3 Things created:

  • CMD1 Thing (/home/openhabian/some-cli cmd1 --option=false %2$s, autorun = on)
  • CMD2 Thing (/home/openhabian/some-cli cmd2 --option=false %2$s, autorun = on)
  • CMD3 Thing (/home/openhabian/some-cli cmd3 --option=false %2$s, autorun = on)

Each of those is linked to 2 items - input and outputs, via exec() channels.

  • CMD1 Item Input (String)
  • CMD1 Item Output (String)
  • CMD2 Item Input (String)
  • CMD2 Item Output (String)
  • CMD3 Item Input (String)
  • CMD3 Item Output (String)

The expectation here is when CMD1 Item Input receives new arguments, it will autorun the command, like /home/openhabian/some-cli cmd1 --option=false arg1 arg2 arg3.

The command needs to get its arguments from an incoming MQTT message (from a State Topic it subscribes to). And then it needs to send the output on another MQTT topic, in round-robin style: args to the Pi, send back the output as a response.

So i have a new Generic MQTT Thing, which has 6 channels (3 x input/output for each command variation, which is insane), set to the follow the input/output Items.

  • CMD1 Input - State Topic /object/cmd1/state, Command Topic: [blank], isCommand=true
  • CMD1 Output - State Topic [blank], Command Topic: /object/cmd1/command
  • CMD2 Input - State Topic /object/cmd2/state, Command Topic: [blank], isCommand=true
  • CMD2 Output - State Topic [blank], Command Topic: /object/cmd2/command
  • CMD3 Input - State Topic /object/cmd2/state, Command Topic: [blank], isCommand=true
  • CMD3 Output - State Topic [blank], Command Topic: /object/cmd3/command

All seems well. When i publish a trigger of new arguments to the MQTT topic (e.g. publish “arg1 arg2 arg3” to /object/cmd1/state , the log shows:

2020-12-12 22:26:20.529 [ome.event.ItemCommandEvent] - Item 'some_cli_cmd1_input' received command arg1 arg2 arg3

2020-12-12 22:26:20.532 [nt.ItemStatePredictedEvent] - some_cli_cmd1_input predicted to become arg1 arg2 arg3

It should auto-run, according to the docs. I don’t want to have yet another set of stuff like switches, which i am trying to avoid. Every time it receives new input it should run (on-demand).

But that’s it. Nothing. Zero. Nada. No output, no execution, no error, no message.

What i need to do, conceptually is:

  1. Send args in MQTT message to topic;
  2. Have OpenHAB send the args to a command line program on the Pi (pipe, or passthru).
  3. Return the output to another MQTT topic.

Ignore me. This actually working. OH had stopping running the executable and encountered the “no suitable algorithm problem for the MQTT binding”.