Greengrass MQTT Bridge component to listen only topics specific for the thing

0

Hi, It seems currently we are only allowed to use wildcard (+), or hard coded thing names in MQTT Bridge mqttTopicMapping.

For example I can do as follows and it works;

mqttTopicMapping: {
              HelloWorldIotCore: {
                topic: 'clients/+/hello/world',
                source: 'LocalMqtt',
                target: 'IotCore',
              },
              IotCoreToDevice: {
                topic: 'clients/+/iotcore/to/device',
                source: 'IotCore',
                target: 'LocalMqtt',
              }
}

This one works too;

mqttTopicMapping: {
              HelloWorldIotCore: {
                topic: 'clients/hardcoded_thing_name/hello/world',
                source: 'LocalMqtt',
                target: 'IotCore',
              },
              IotCoreToDevice: {
                topic: 'clients/hardcoded_thing_name/iotcore/to/device',
                source: 'IotCore',
                target: 'LocalMqtt',
              }
}

But this one does not work. I want this to work because I want to apply the same deployment to multiple devices (or thing group) and I want each device to receive topic messages specific for itself.

mqttTopicMapping: {
              HelloWorldIotCore: {
                topic: 'clients/{iot:thingName}/hello/world',
                source: 'LocalMqtt',
                target: 'IotCore',
              },
              IotCoreToDevice: {
                topic: 'clients/{iot:thingName}/iotcore/to/device',
                source: 'IotCore',
                target: 'LocalMqtt',
              }
}

Any solution for this problem?

Thanks

asked a year ago299 views
1 Answer
0
Accepted Answer

Hi,

I found the problem and posting here in case anybody suffers from the same problem.

In order to be able to {iot:thingName} in component configurations I had to enable interpolateComponentConfiguration on Nucleus configuration like below:

configurationUpdate: {
          merge: JSON.stringify({
            interpolateComponentConfiguration: true,
          }),
        },

More details here -> https://docs.aws.amazon.com/greengrass/v2/developerguide/greengrass-nucleus-component.html#greengrass-nucleus-component-configuration-interpolate-component-configuration

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions