Paper-UI Channel Command Topic Transform

Hi,
Does anyone know if Paper UI will accept a transformation for the command topic for a channel?

I am trying to send an MQTT Json payload to set a timer on a device. This would look like:

"cmnd/wemo-1/timer1" -m '{"Time":"18:05"}'

The item is as follows:
String Timer1 {channel=“mqtt:topic:0b01722e:T1”}

the sitemap is
Setpoint item=Timer1 label=“Timer1 [JS(numberToClock.js):%s]” minValue=0 maxValue=1440 step=15

This use the transform to convert the Timer1 value to display correctly on the UI

numbertoclock.js
(function(i) {
var hours = Math.floor(i / 60);
var minutes = i % 60;

hours = (hours < 10) ? "0" + hours : hours;
minutes = (minutes < 10) ? "0" + minutes : minutes;
return hours + ":" + minutes;

})(input)

In paper-ui the channel is configured as follows:


Ideally I would use the same transform for the command topic.

I want the convenience of setting the timer values in the UI and would like to avoid a rule that updates an different item. (would be something like this)
val String VarTimer1AsTime = transform(“JS”, “numberToClock.js”, Timer1.state.toString )
Timer1AsTime.postUpdate(VarTimer1AsTime)

I will need multiple timers running to don’t want to replicate a rule and additional item for each timet

Version information needed here

One thing I do notice is that there is a typo in your outgoing value format. You have a single quote before Time and double quotes everywhere else. That will result in an invalid JSON string which your destination will not be able to parse.

Furthermore, your JS transform is only applying to the way that Item appears on your sitemap. It doesn’t change a thing about how the value is stored in the Item itself and therefore has no impact the value published. In otherwords, assuming this Item represents seconds, if you set it to 300 the published message as you currently have it configured would be:

{'Time":"300"}

You need to install a more recent MQTT binding like rossko57 suggests, and then apply your JS transformation on the outgoing message. You will need to change your JS transform to return your full JSON string, not just the MM:SS.

If possible, it would probably be the most ideal to change the end point so it can accept the number of seconds in the first place. Why force OH to go through the effort to convert seconds to MM:SS only to have your Wemo almost certainly need to convert it back to seconds once it receives the message?

On 2.4. Will 2.5 have this?

Thanks,
Can you help with the change to the transform to return the full string. Can’t figure out the quoting.

The device (running tasmota) currently accepts time as hh:mm so this seemed to be the simplest way.

Regards

Just change your return statement to return the full JSON string.