- Newest
- Most votes
- Most comments
Hi again @flycast,
A couple things I notice:
- Your shadow manager configuration is not in the correct format
{
"reset": [],
"merge": {
"reset": [],
"merge": {
You have merge
inside of another merge
. Please make sure that the configuration is correctly set.
- You are subscribing to the topic named
dsvvefvfq
. Who or what do you expect to be publishing todsvvefvfq
?
Shadow manager publishes to local pubsub topics using the device shadow topics (https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-mqtt.html) as explained here: https://docs.aws.amazon.com/greengrass/v2/developerguide/interact-with-shadows-in-components.html#react-shadow-events.
Therefore, you should be subscribing to $aws/things/<your GG thing name here>/shadow/name/dsvvefvfq/#
You can subscribe to $aws/things/#
which is a wildcard, you will then be able to see all traffic to the topics beginning with $aws/things/
and update your code accordingly.
Cheers,
Michael
Too long for a comment: To answer your question #2 - I expect to publish data in a shadow for the core device to use to publish with.
When I publish an update to a shadow I am seeing the updates get logged in the greengrass.log so I know shadowmanager is getting them.
My current component config looks like:
{
"accessControl": {
"aws.greengrass.ShadowManager": {
"com.xxxxxxxx.productivity.cycle_count:shadow:1": {
"policyDescription": "",
"operations": [
"aws.greengrass#GetThingShadow",
"aws.greengrass#UpdateThingShadow",
"aws.greengrass#DeleteThingShadow",
"aws.greengrass#ListNamedShadowsForThing"
],
"resources": [
"*"
]
}
},
"aws.greengrass.ipc.pubsub": {
"com.xxxxxxxx.productivity.cycle_count:pubsub:1": {
"policyDescription": "",
"operations": [
"aws.greengrass#SubscribeToTopic"
],
"resources": [
"*"
]
}
}
}
}
As I understand this the component configuration will get all shadow traffic from shadowManager and any mqtt packets from pubsub.
When I update the shadow dsvvefvfq
I see the changes logged by shadowManager but nothing happens in my custom component log. I am expecting to see the callback execute. Bare minimum I expect to see the print("Callback was involked")
message in the component log.
def on_stream_event(event: SubscriptionResponseMessage) -> None:
try:
print("Callback was involked")
message = str(event.binary_message.message, 'utf-8')
topic = event.binary_message.context.topic
print('Received new message on topic %s: %s' % (topic, message))
except:
traceback.print_exc()
In your comment below my answer you said that you are subscribing to
*
. This is not correct based on the code you provided. You are subscribing to a single topic in the call tosubscribe_to_topic
. The topic you are subscribing to isdsvvefvfq
.Your component is allowed to subscribe to any topic, but at least in your code, you aren't subscribing to all topics, only a very specific topic. Please use my recommendation of subscribing to
$aws/things/#
instead.
Relevant content
- Accepted Answerasked 2 years ago
- asked 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 9 months ago
Whoa...I see your #1 above. I'll fix that. On #2 I'm confused. I am subscribing to
*
in the component as an allow everything. I will tighten that up when I get things working. The component will be able to see anything that way and that will eliminate misconfiguration as a problem correct?Are you sure the wildcard wouldn't be
$aws/things/*
with an asterisk instead of hash?Yes, I am quite sure that using
*
is not correct. Please see the documentation here: https://docs.aws.amazon.com/greengrass/v2/developerguide/ipc-publish-subscribe.html#ipc-operation-subscribetotopic which includes a note about using+
or#
.I think you're confusing the access control policy and the actual subscription. The access control policy that you set in the component configuration simply means that the component is allowed to perform an action. It does not mean that the component will do that action.