0
Waiting for user's reply

MQTT: Convert data before sent/receive

Tanapol E. 7 jaar geleden in Server Solutions / UMC Server bijgewerkt door Ilya Markov (expert) 7 jaar geleden 1

Hi,

My MQTT sent/receive command by string "ON" and "OFF" not 0 1


Is it possible to convert them?

for example

when receive string "ON" from Feedback

just convert to 1

and when send 1 to MQTT Tag just convert and send out "ON" string

Waiting for user's reply

Hello,

you can use js script for this task. You can subscript to this tag via global listener or event tag change and then convert it.


var device = IR.GetDevice("MQTT")

IR.AddListener(IR.EVENT_TAG_CHANGE, device, function(name, value)
{
   if (name == "MQTT Feedback")
   {
     if (value == "ON")
     {
       //Here you should set 1 to your varibale
     }
     else
     {
      //Here you should set 0 to your varibale
     }
   }
})