Publishing MQTT to external broker

Hi, I’m new here and I’m discovering usability of using OpenRemote for use case.

For the demo purpose I need to connect to public MQTT broker (I took broker.hivemq.com as a example).

My Asset configuration:

I managed the proper connection. But if I want to publish some data some under topic for example as I am using mosquitto_pub in CLI:

mosquitto_pub -h broker.hivemw.com -t example/test -m some_message

What do I need to do and what do I need to configure? I didn’t find information how to publish data under particular topic: example/test

Thank you in advance!
Maciej

1 Like

Hi,

Glad you’ve managed to setup the MQTT Agent, to publish/subscribe you need to:

  1. Create another asset (e.g. a Thing Asset)
  2. Create attributes to store the data you want to extract
  3. Add an AgentLink configuration to each of these attributes and select your MQTT Agent, you will then have options for publish/subscribe topics
  4. You can use the standard AgentLink options for processing the raw data (JSON Path, substring, regex)

Hi Rich, I think I managed this as you said :slight_smile: The missing information for me was I need separate ThingAsset and configure AgentLink. Now it’s a lot more clear, thank you!

Maciej

I’m also able to connect to external broker I’m getting confused in pub sub topic .In which manner we have to write it
like this {realm}/{clientId}/attribute/{attributeName}/{assetId}
or some thing different
thank you

Hi Kalash,

Not an expert on this topic, so hopefully I don’t give false information… Otherwise I will be corrected :slight_smile:

In the AgentLink configuration of the attribute of the asset you have created (in addition to the MQTTAgent that you need for the connection) you can add the Publish Topic or Subscription Topic parameters. If you are publishing you can define the topic (e.g. temperature), otherwise if you are subscribing you have to follow the topic name you have set somewhere else.

If this does not work, please explain a bit more about your set up.

Hi Rich,
I have the same problem as OP.
I created an ElectricityConsumerAsset whose parent is my MQTT Agent, connected to an external broker.
If I expand one of the existent attributes, i. e. “power” and add Agent Link, then when I select my MQTT Agent there are no options for publish/subscribe topics:

How can I select or even write the correct subscription topic?

Is the Demone MQTT Agent of the type ‘MQTTAgent’? The Agent link doesn’t seem to recognize the type (that is why it’s saying ‘no schema match found’ and only gives the JSON option).

If the agent that is selected is the standard MQTT Agent, it will know which form options to show, and you can add the parameters for publish and subscribe topics.

yes, of course it is a MQTT Agent, and its status is even Connected:

This is exactly what I expect to achieve. But the parameters’ fields to add topics are not appearing.

It’s hard to say what’s going wrong without seeing your set up. If I understand correctly you were able to select the MQTTAgent from the Agent Link dropdown, but then it gives you the ‘No schema match found’?

If that is the case I need to call in a developer to come up with a reason why this might happen :grimacing:

Exactly. At the moment, I’m pulling latest manager’s and proxy containers and I’ll retry to rebuild the MQTT Agent. I’ll keep you informed.

Edit: Pulling new manager container pushed to another problem: Unable to update to latest manager container

Hi @Don, the bug is solved in the latest manager container.

1 Like