0

In the tutorial of rules engine, they say it is possible to say that every time we receive a message that indicates "blue" as the desired color of the light bulb the rules engine transforms it to "green"

To do this, I thought about creating a rule that republishes the message to the topic shadow/update but I could not find a way to modify the message before republishing.

It there a way to do it in the aws console ?

Karim KARAA
  • 101
  • 3

1 Answers1

2

You'll need to create an IoT rule to repbuish the message as you state, the SQL-like syntax allows for basic string manipulation, so you could try:

{
    "sql": "SELECT replace(color, 'blue', 'green') as color FROM '$aws/things/mything/shadow/update' WHERE color = 'blue'",
    "ruleDisabled": false,
    "actions": [{
        "republish": {
            "topic": "$aws/things/mything/shadow/update",
            "roleArn": "arn:aws:iam::123456789012:role/my-iot-role"
        }
    }]
}

You may have to adjust the variables, if the color is a property of the reported state, you can change all instances of 'color' to 'reported.color'.

The AWS IoT SQL reference has further examples.

Michael Barnwell
  • 724
  • 1
  • 10
  • 16