I'm encountering an issue with an AWS IoT SQL query that triggers a Lambda function, but the "state" remains empty in the Lambda event.
Below is a snippet of my Lambda function code:
python
def lambda_handler(event, context):
state = event.get("state")
The data I'm sending to the topic $aws/things/<THING_NAME>/shadow/name/<SHADOW_NAME>/update/accepted has the following format:
{
"state": {
"reported": {
"access_points": [
{
"SSID": "SSID",
"Strength": 100,
"WPAFlags": 0
}
]
}
}
}
Strangely, if I remove the list [] type from the access_points and publish the data, it triggers the Lambda function successfully. However, when the access_points list is included, the Lambda function is not triggered.
Below payload works fine. However I need to send a list.
{
"state": {
"reported": {
"access_points":
{
"SSID": "SSID",
"Strength": 100,
"WPAFlags": 0
}
}
}
}
I'm using the following SQL query in AWS IoT Core:
SELECT state.reported as state, topic() as topic FROM '$aws/things/+/shadow/name/+/update/accepted'
Could there be an issue with the query? Is it not supported to use a JSON array type (access_points) in the reported state? Any guidance or pointers would be greatly appreciated.