Difference between clientID and assetID in MQTT topic

Hi all,
I was wondering the best practices for MQTT considering multiple sensors that send data to OpenRemote using its MQTT broker.

Every sensor should have a different clientId since it can’t be used more than once. However, every sensor will be a different asset as well.

Does it make sense that a single sensor has the same clientId and assetId? Could it be possible that a clientId (or sensor) has multiple assetId? When or why it should?

Thanks!

We have quite a lot of things to unpack here;
First of all, let’s go through some facts; an asset can be updated by any number of connections (devices), as long as they all use different client IDs, and the security prerequisites are fulfilled. A new connection, or a new clientId, does not necessarily constitute a new Asset.

But, since you asked for the best practices, I think we should focus on that;

In OpenRemote, an asset is the logical representation of an IoT thing. Hence, you should apply that to what you want to do; are those sensors part of the same “thing” for you? You are talking about multiple sensors. Are those sensors part of the same thing? For example, if you are monitoring temperatures of a fridge at 10 different points of it, then indeed, it does not quite make sense to have a different logical representation (thing) for each and every asset, since the sensors are used for monitoring the actual thing, the fridge. But it does completely depend on your setup and what you are planning to achieve using the data from those sensors. You could always use an AttributeLink to send the data from these attributes of these assets to one central asset, but the way you architect your solution depends directly on you.

Hence, you need to think about what you consider an IoT Thing, what your setup is, what data you will be transmitting, and what you want to monitor, to make the correct decisions for yourself.

Best of luck!

Nice reply, thank you.
In my system every sensor is a different IoT thing, concretely power sensors that measure current and voltage. Then, I understand that in this case yes, the clientId (sensor or connection) will be equivalent to the assetId.

Then, following the MQTT API documentation, the publishing topic must be:

{realm}/{clientId}/writeattributevalue/{attributeName}/{assetId}

So, I guess that what I should do is to:

  1. Create an Electricity Consumer asset in the OR Dashboard
  2. Get the ID from the URL of the asset (for example 123ABC)
  3. Configure my sensor to publish the payload {voltage: 230} in topic {realm}/123ABC/writeattributevalue/voltage/123ABC, and same with current.

Is it a proper MQTT setup?
Actually voltage and current are not default attributes of an Electricity consumer asset. Is it a problem?

Thanks!

Just to be clear, the MQTT client ID is nothing that is A) saved, or B) meant for anything more other than just keeping track of the connection. It is just imperative that the client ID is unique for each connection to OpenRemote. The MQTT client ID is something that is defined in the MQTT standard and is required for connecting to the OpenRemote MQTT broker.

About the other thing you mentioned, you will absolutely need to make those attributes. You can make them manually for each asset you create, or create a new Asset Type.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.