Updating and subscribing to shadows

0

I am trying to set data values in a shadow and have my custom component pick up that value on the core device. I am having an issue with the component not picking the value up. As I troubleshoot this I think the new shadow value is not making it to the component at all. I backed up and am looking at how shadowmanager and the cloud sync to troubleshoot each step.

I have ShadowManager configured like this:

{
	"strategy": {
		"type": "realTime"
	},
	"synchronize": {
		"coreThing": {
			"classic": true
		},
		"namedShadows": [
			"test",
			"dsvvefvfq"
		],
		"direction": "betweenDeviceAndCloud"
	}
}

My understanding of this configuration is if the classic shadow or the two named shadows (test and dsvvefvfq) change on either the core device or cloud (cloud->core) or (core->cloud) then synchronize them immediately.

I then go to my thing definition and edit the shadow named "dsvvefvfq". When I watch the log files I immediately see:

2022-09-27T16:56:55.626Z [INFO] (pool-2-thread-145) com.aws.greengrass.shadowmanager.ShadowManagerDAOImpl: Updating sync info. {thing name=SliceOfPi, shadow name=dsvvefvfq, cloud-version=14, local-version=9}
2022-09-27T16:56:55.630Z [INFO] (pool-2-thread-145) com.aws.greengrass.shadowmanager.sync.strategy.BaseSyncStrategy: sync. Executing sync request. {Type=CloudUpdateSyncRequest, thing name=SliceOfPi, shadow name=dsvvefvfq}

Weirdly, I never get the Successfully updated shadow message until I edit the shadow again. I am expecting to see a series of log entries that follows this pattern:

Updating sync info. {thing name=SliceOfPi, shadow name=dsvvefvfq
Executing sync request. {Type=CloudUpdateSyncRequest, thing name=SliceOfPi, shadow name=dsvvefvfq
Successfully updated shadow. {service-name=aws.greengrass.ShadowManager, thing name=SliceOfPi, shadow name=dsvvefvfq

I also notice the versions don't match between cloud-version and local-version. They seem to both increment every time I update the shadow. Shouldn't the local and cloud version number match once synchronizing is finished?

Also, one other question that might be relevant. In the shadow manager there are two sections that look very similar - coreThing and shadowDocuments. It is not at all clear from the docs how they interact. How do they interact?

  • Looking deeper I may be misunderstanding the difference between desired and reported states. I was thinking that the last value for desired would be the current value for reported. I now see that I can change my field value for either desired or reported. Is this understanding correct?

flycast
asked 2 months ago27 views
1 Answer
1
Accepted Answer

Hi flycast. generally, speaking, the cloud would modify the shadow using the desired property. The device would see the desired property, apply it on the device, then update the reported property. If the device changed state by itself, it would just change the `reported' property.

https://docs.aws.amazon.com/iot/latest/developerguide/iot-device-shadows.html

Enter image description here

profile picture
EXPERT
Greg_B
answered 2 months ago
  • Amazing how a paradigm shift can open your world! Thanks for that @Greg_B!

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions