Reading from an external MQTT broker

Hi, I have an mqtt broker to where my devices are sending messages.
I want to “import” them into open remote.

I have created an MQTT Agent, and since my mqtt-broker uses mqtts:// i also added the required certificates (.pem files from /etc/ssl/certs) to my OR_SSL_CLIENT_TRUSTSTORE_FILE=/storage/keystores/client_truststore.p12 with the keytool command.

So now i can see in the logs that OpenRemote connects to my mqtt-broker.

However, I dont know how to proceed to get the data ingested into OpenRemote as asset attributes.

Please note that I’m new to OpenRemote so it maybe is obvious, but to be clear I want to subscribe to some mqtt topcis and convert them into openremote attributes.

Can anyone help me and explain what the next step is?

I have looked for documentation but only found communication in the other direction (FROM OR to mqtt broker), and a few questions in the forum [1], [2], about the same thing I’m asking about. However, they didnt have any answers.

I’d be very grateful for any help!

Cheers!
/Lars (from Sweden)

[1] Subscribe to locally hosted Mosquitto MQTT Broker
[2] MQTT integration (Mosquitto) - no subscribe message

Hey Lars,

Happy to hear you were able to connect your agent to the external MQTT broker!

I recommend reading through the agent overview, to understand more about how agents work. Principally, you’d start with creating an Agent link configuration item on the attribute you’d like, and then configuring the subscription/publish topic for that specific attribute’s agent link. Depending on the format of your message, you’d possibly have to use some value filters. The agent link would then use the linked agent to perform the work required.

Best of luck!

Panos

Ok, thanks.

I managed to create an Attribute that gets its value from the MQTT Agent.

But when i try to add one more attribute from the same MQTT Agent I’m unable
to add it. My broker publishes several topics (power, current, voltage, etc) and I want to ingest them,
but after I’ve added the first attribute it is no longer possible to select any agent in the pull down box
that lists the agents. If i try to enter the id and MQTTAgentLink type etc in the json box, it just reverts back to DefaultAgentLink.

Is that a bug?

Thanks for any explanation of what is happening!
/Lars

Good afternoon @larsr ,

I’m understanding that you’re trying to add another Agent link configuration item to a different attribute of an asset. I’m not exactly sure what could be the issue, are there any logs that describe the issue a bit more in-depth? I wasn’t able to reproduce this locally.

Hi, I think it is some kind of problem with the web interface.
The problem is that I can’t create more than one asset with an AgentLink to my MQTTAgent.

I have created a ThingAsset and an MQTTAgent. First I create a new attribute on the ThingAsset
with an AgentLink to the MQTTAgent.

The problem comes now.

After having created and saved the first attribute, it becomes impossible to choose
the MQTTAgent again when I try to create an AgentLink for another attribute.
The web interface just reverts the settings back to some DefaultAgent.

I noticed today that I can create more that one AgentLink attribute AS LONG AS I DONT SAVE the asset. But I would really like to be able to add them one at a time.

Hi, I tried recreating this issue but I cannot.

If you can please provide exact steps to reproduce the issue and let us know which browser you are using then we can investigate further.

Here is the workaround

Here I have

  • created a new Thing Asset called “Silly”
  • added a Number attribute called L1
  • created an AgentLink to my MQTTAgent
  • added a Subscription Topic to my power meter

The thing that doesnt work is when I try to add a second MQTTAgent attribut to Silly.

  • I add a number attribute called L2
  • I create an AgentLink. However, this time I can’t choose my MQTTAgent. It defaults to a DefaultAgent. Here I would like to still be able to choose my MQTTAgent from the AgentLink property box.

[ I was not allowed to put a screen shot of this into the forum (just one image per post for newbies) so I paste it in the next message. ]

However, I found a work-around for now. If i click on the JSON box next to my working L1 attribute AgentLink, I can copy the AgentLink values from it, and paste it into the AgentLink JSON of L2, to convert the DefaultAgentLink into an MQTTAgentLink.

Just to confirm on your second attribute is the Agent ID drop down empty? (i.e. you cannot select the MQTT agent).

The Agent Link type will update once you select an agent from the Agent ID dropdown.

Yes, the AgentID drop down is empty, and one cannot select the MQTTAgent again. Nothing happens when I click in it. I’ve tried with chrome and safari.

So you are not able to recreate this problem?

Hi Lars,

I followed your steps, but for me the agent was always available in the dropdown.
Not sure what is happening here.

Don

While exploring this issue I did find a bug that is fixed now. I’m assuming there is no direct relation, but you never know :stuck_out_tongue: