I am new to AWS world, am currently developing an Alexa skill that simply publish a mqtt message to AWS IoT Core broker interacting with a previously created 'thing' and topic. Currently I am using boto3 but I am not sure that's the right path. This is the code but it is not working when deploying the Lambda and invoking the intent from Alexa.
import boto3
import json
payload = json.dumps(
{'state':
{
'desired': { 'irrigation': 'on' }
}
})
client = boto3.client('iot-data', region_name='us-west-2')
response = client.publish(
topic='$aws/things/gateway/shadow/update',
qos=1,
payload=payload
)
CloudWatch shows no excceptions, I simply get an error response from Alexa and not receiving any message if subscribing to the same topic where the publish should be triggered.
I am using 'shadow', maybe this is not the right thing to do? Tried normal topic but not working as well. Also, I would love to debug the code before publishing. Is there an easy way to do that without using CloudWatch?
TL;TR Only found a lot of guides online that goes this way: iot core -> aws lambda. But I am actually looking for the opposite: aws lambda -> publish to iot core
publish()
call that logs any exceptions. Also, are you aware there is anupdate_thing_shadow()
function? – Mark B