2
votes

I am working on simple publish/ subscribe example using node.js SDK, in which I have subscribed to topic 'sensor/alert' and same time periodically publishing topic 'sensor/temp' with payload

{"temp":[no between 0-20]} (ex. {"temp" : 20})

I have configured rule engine with following rule

"SELECT * FROM 'sensor/temp' WHERE temp > 10"

which trigger

"AWS IOT republish action".

I have set proper role for this rule from AWS-IOT console. But when client code publish topic with payload {"temp" : 12} or any number greater than 10 in payload, rule engine should come in action and republish to topic 'sensor/alert' but unfortunately it not. I have checked publish and subscribe logic with AWS MQTT client. In Client code publish and subscribe logic is working properly, but rule engine is not working. I am using AWS free account. I am not able to troubleshoot the issue. Any help is appreciated.

Thanks in advance.

2

2 Answers

0
votes

I think it is "SELECT * FROM 'sensor' WHERE temp > 10" instead of sensor/temp

You should try to publish this message

{"temp" : "12"}

Now you should subscribe to the topic sensorrepublished for example and you should be able to seed the message

0
votes

where is the target you want to trigger? if Lambda, you need to add permission in Lambda like this

response = client.add_permission(
FunctionName='Lambda_Name',
StatementId='FunctionPermission',
Action='lambda:InvokeFunction',
Principal="iot.amazonaws.com",
SourceAccount = "yourAccount"
)

Thanks