MQTT Thing String channel with commands

I’m trying to operated on my vms with an mqtt service I’ve adapted for used.
I’m trying to get a string channel to accept and use multiple values.
The run time values are Off, Paused, Running.
The commands however are:
to Pause
pause,mymachine

To Run
resume,mymachine

So I’ve got this:

Type string 	: state		"Machinestate"		[            
      stateTopic="iotlink/workgroup/host/hyper-v/state/mymachine",
      allowedStates="Off,Paused,Running",
      commandTopic="iotlink/workgroup/host/hyper-v/operate",
      Off="stop,mymachine",
      Paused="pause,mymachine",
      Running="resume,mymachine"  ]

ANd on screen it looks ok with a nice selection drop down with the allowed states. But no matter what I set the desired state to the mqtt command is just the Allowed state value:

iotlink/workgroup/host/hyper-v/operate Running
iotlink/workgroup/host/hyper-v/operate Paused

Can I do what I want, or should i alter the message structure?

ideally I’d change the message structure to

iotlink/workgroup/host/hyper-v/operate/machine

But the mqtt thing I’m using doesn’t seem to allow me to subscribe to
iotlink/workgroup/host/hyper-v/operate/+ else I wouldn’t be having to do it this way.

This is just made-up syntax and will be ignored.

It looks like you want to transform an openHAB command string to a different MQTT payload string?
Use transformationPatternOut for that.
A MAP transform should do the job here.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.