News:

  • September 27, 2026, 06:22:10 PM

Login with username, password and session length

Author Topic: MQTT  (Read 11650 times)

ryanastiefes

  • Sr. Member
  • ****
  • Posts: 72
MQTT
« on: July 19, 2018, 08:15:09 PM »
Just started playing around with MQTT PUB and SUB. I'm using Inductive Automations Ignition with a MQTT Engine to pass the Topics to and from my DoMore using MQTTSUB and MQTTPUB. In order to use this protocol to control the registers in DM I must format the Strings to Floats or Integers or Format the Floats or Integers back to Strings. Unless there is an easier way, I have to use multiple rungs of STRPRINT and STR2REAL to accomplish this task due to the instructions not having a range setting. So my question is, is there an easier way of doing this? Am I going about this the wrong way?

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6176
  • Yes Pinky, Do-more will control the world!
Re: MQTT
« Reply #1 on: July 20, 2018, 12:27:17 AM »
That's probably the best you can do, at least for now. We had initially planned to incorporate conversions directly into the instructions, but since MQTT doesn't specify how payloads were formatted, we chose to just use strings for now. As we get more comfortable with how MQTT is used in practice, we will likely add some of this back.

So this product just uses textual floats and integers for the payload? Any other formats we should consider?
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

ryanastiefes

  • Sr. Member
  • ****
  • Posts: 72
Re: MQTT
« Reply #2 on: July 20, 2018, 11:15:46 AM »
So this product just uses textual floats and integers for the payload? Any other formats we should consider?

As I become more familiar with the protocol I'll let you know. But for now it would be nice to have a STRPRINT Range and STR2REAL Range like MOVER.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3847
    • Host Engineering
Re: MQTT
« Reply #3 on: July 20, 2018, 11:43:03 AM »
As you look at the format of the data, it may be coming back as a JSON array values of reals, or possibly a list of JSON fields?

If that is true, we definitely are addressing this.  JSON is a very common format for web-based queries, including MQTT.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3626
  • Darth Ladder
Re: MQTT
« Reply #4 on: July 20, 2018, 02:10:12 PM »
Just started playing around with MQTT PUB and SUB. I'm using Inductive Automations Ignition with a MQTT Engine to pass the Topics to and from my DoMore using MQTTSUB and MQTTPUB. In order to use this protocol to control the registers in DM I must format the Strings to Floats or Integers or Format the Floats or Integers back to Strings. Unless there is an easier way, I have to use multiple rungs of STRPRINT and STR2REAL to accomplish this task due to the instructions not having a range setting. So my question is, is there an easier way of doing this? Am I going about this the wrong way?

If there are multiple instances of it, you could clean up the individual calls with a subroutine.  Even if it's just one, you might prefer the streamlined display of having all that stuff encapsulated in the CALL.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

ryanastiefes

  • Sr. Member
  • ****
  • Posts: 72
Re: MQTT
« Reply #5 on: August 03, 2018, 09:07:07 PM »
As you look at the format of the data, it may be coming back as a JSON array values of reals, or possibly a list of JSON fields?

Yes it is coming back as a JSON array. So assuming I write up a JSON array using SL's , would I be able to pass registers into that array like R100, and V50?

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6176
  • Yes Pinky, Do-more will control the world!
Re: MQTT
« Reply #6 on: August 04, 2018, 10:42:51 AM »
With the instructions we are currently developing, JSONBUILD allows you to pass in arrays of strings or numerics to create a JSON array, or a table of individual field name/value pairs to create JSON objects. JSONPARSE extracts one field at a time for both objects and arrays, but does allow you to output the value directly to a numeric variable. In the current field-by-field implementation, it is pretty easy to extract the entire array by looping, but your situation makes me want to explore the possibility of extracting an entire array in a single call.

"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

ddubs2248

  • Sr. Member
  • ****
  • Posts: 64
Re: MQTT
« Reply #7 on: April 04, 2019, 03:08:05 PM »
Guys, just thought I would pass this along...its on the Inductive Automation Forum as well.  One is setting up the Do-More and using the JSONBUILD and MQTTPUB.  The other image is setting up the trial version of Inductive Automation.  Please note, this is all done on the same PC.