Provisioning Devices

Are the steps below feasible to automatically spin up attributes based on a payload with multiple measurements? I have tried to get it to work but there seems to be an issue if the attribute does not exist:

  • Manually add or clone new asset
  • Create json object ‘payload’ attribute to receive payload data
  • Consume uplink payload via MQTT agent link etc
  • Create boolean attribute called ‘provisionDevice’
  • Manually check ‘provisionDevice’ attribute
  • Groovy rule triggers and decodes payload into individual names, values and types
  • Groovy rule adds new attributes to the asset
  • Groovy rule create Attribute Links etc
  • Turns ‘provisionDevice’ to false

Hi Clint,

Sorry for the delayed response; I haven’t been on the forum for a while :slightly_smiling_face:

That is an interesting approach to your provisioning challenge but asset modification isn’t possible from within a rule.

For this scenario we would typically suggest a custom MQTTHandler that consumes your MQTT payload and does the provisioning.

ATB,

Rich

Thanks Rich

I can create a custom MQTTHandler that consumes the payload as suggested. How would it then do the provisioning within OR e.g. create assets, attributes etc?

Rgds
Clint

MQTTHandlers have full access to the system so you can grab the AssetStorageService in the init method and use that for asset CRUD operations. See the UserAssetProvisioningMQTTHandler for some inspiration.

KR,

Rich