[MQTT] To update several attributes with a single message

Hello,

To save power, using MQTT, we would like to update several attribute with a single message. Unfortunately, the MQTT API allows only one attribute per mesage.

To workaround this limitations, we are publishing a JSON payload to an “inbound” attribute and using AttributeLinks to update individual attributes. This, however, seems a bit awkward, especially the setup.

Do you plan to support this (i.e., to update several attributes with a single message) in the near future?

We though of adding support for this with a special attribute name (in {realm}/{clientId}/writeattributevalue/{attributeName}/{assetId}). However, there seems to be an issue with this.

Because access control seems to be performed in DefaultMQTTHandler::canPublish, if we authorize such a publication, such a JSON payload may be used to update an attribute whose access is not authorized.

To workaround this, we thought of:

  1. Accepting all such publications (with the special attribute name).
  2. But, whenever there’s a publication, of using canPublish for each individual attribute and only updating the attribute if access is authorized.

Any thoughts?

Thank you.

Best regards,
Adriano Carvalho

1 Like

Hi,

Good thinking but as you say AttributeLink is processed as an internal request (i.e. if you authorise the creation of the AttributeLink then that implies who/whatever updates the attribute is OK to update the linked attribute(s) also.

I think we’ve discussed before about using a custom MQTTHandler; this mechanism would give you complete control over what data is in the payload and how you process it.

MQTT is by design quite limited; we cannot support multiple attributes in one payload as the topic is all we can use to authorise the publish and therefore we couldn’t authorise the payload itself (although the system could still disallow un-authorised attribute publishes further down the processing pipeline).