GreengrassV2-Core's IoT-Thing-shadow never beeing synchronized with remote

0

Hi,

I successfully deployed a custom python component on a greengrassv2-core-device. When updating the local device shadow successfully (as the log says) using aws-iot-device-sdk-python-v2, it basically never shows up in the AWS console.

Setup

  • The core device is online.

  • This is the component-code I'm updating the local shadow with:

THING_NAME = "thingname"
SHADOW_NAME = "shadowname"
last_heartbeat = ...

shadow = {
    "state": {
            "reported": {
                "last_heartbeat": last_heartbeat,
            ...
        }
    }
}

try:
    # create the UpdateThingShadow request
    update_thing_shadow_request = UpdateThingShadowRequest()
    update_thing_shadow_request.thing_name = THING_NAME
    update_thing_shadow_request.shadow_name = SHADOW_NAME
    update_thing_shadow_request.payload = json.dumps(shadow).encode('utf-8')

    # retrieve the UpdateThingShadow response
    op = ipc_client.new_update_thing_shadow()
    op.activate(update_thing_shadow_request)
    fut = op.get_response()

    result = fut.result(5)
    return result.payload

except InvalidArgumentsError as e:
    print("InvalidArgumentsError: %s", e.message)
except ConflictError as e:
    print("ConflictError: %s", e.message)
except UnauthorizedError as e:
    print("UnauthorizedError: %s", e.message)
except ServiceError as e:
    print("ServiceError: %s", e.message)
  • My ShadowManager configuration:
{
   "reset":[
      
   ],
   "merge":{
      "reset":[
         
      ],
      "merge":{
         "strategy":{
            "type":"periodic",
            "delay":300
         },
         "synchronize":{
            "coreThing":{
               "classic":false,
               "namedShadows":[
                  "shadowname"
               ]
            },
            "direction":"betweenDeviceAndCloud"
         },
         "rateLimits":{
            "maxOutboundSyncUpdatesPerSecond":100,
            "maxTotalLocalRequestsRate":200,
            "maxLocalRequestsPerSecondPerThing":20
         },
         "shadowDocumentSizeLimitBytes":8192
      }
   }
}

Observations

Based on the positive greengrass-core log underneath, I ommit the component-recipe and iot-thing-policy, but these are configured with with permissions to update a shadow.

When executing the codesnippet I get these entries in <GREENGRASSV2_DIR>/log/greengrass.log (there are multiple success-entries, this is just one):

2022-08-03T21:19:26.177Z [INFO] (Thread-27) com.aws.greengrass.shadowmanager.ipc.UpdateThingShadowRequestHandler: Successfully updated shadow. {service-name=componentname, thing name=thingname, shadow name=shadowname, local-version=9}

So everything seems to be fine so far, my component keeps happily updating its local shadow. For some reason the local shadow is never beeing synchronized with remote (when having a look in console there are no shadows for the IoT-Thing) although the ShadowManager is configured properly.

Questions

  • Why isn't the shadow beeing synchronized?
  • Do I have to create the Thing-shadow manually before its starting to synchronize (even though it need to be timed properly when using cloud provisioning with a IoT-Thing-group)?
  • Did I miss something which prevents the shadow from beeing synchronized?

Relevant doc-links

gefragt vor 2 Jahren380 Aufrufe
1 Antwort
0

Your shadow manager configuration seems wrong. Can you try making a new deployment via the console with Reset Paths set to [ "" ] and the following Configuration To Merge for the ShadowManager component:

{
    "strategy": {
        "type": "periodic",
        "delay": 300
    },
    "synchronize": {
        "coreThing": {
            "classic": false,
            "namedShadows": [
                "shadowname"
            ]
        },
        "direction": "betweenDeviceAndCloud"
    },
    "rateLimits": {
        "maxOutboundSyncUpdatesPerSecond": 100,
        "maxTotalLocalRequestsRate": 200,
        "maxLocalRequestsPerSecondPerThing": 20
    },
    "shadowDocumentSizeLimitBytes": 8192
}

You should then be able to see the named shadow in the console for the thing corresponding to your core device.

AWS
EXPERTE
beantwortet vor 2 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen