Enabling gadget upkeep throughout a number of time zones utilizing AWS IoT Jobs

Spread the love


Introduction

A good thing about Web of issues (IoT) know-how is the flexibility to attach your units to the cloud and simply entry them from all over the world. Whereas this profit has unlocked many alternatives, it has additionally has created a serious problem of preserving units up to date. Managing and sustaining a fleet of IoT units unfold throughout a number of geographies and time zones is logistically tough. To assist resolve this problem, AWS IoT Jobs provides the flexibility to programmatically schedule over-the-air (OTA) updates for a worldwide fleet of units, throughout time zones, and schedule a time-window for these updates.

With the brand new recurring upkeep window schedule configuration function, now you can schedule AWS IoT Jobs to solely run within the actual time zone a tool is deployed in, inside a particular timeframe. For instance, let’s say you will have units in factories internationally that must obtain a weekly OTA replace, however solely when the factories are closed on Saturdays, from 9PM to 6AM. Utilizing a mix of AWS IoT Jobs, dynamic factor teams, and AWS IoT Machine Shadow, you’ll be able to group units collectively by the point zone they report they’re in and implement a weekly OTA replace to solely be utilized between 9PM and 6AM gadget native time on Saturdays.

On this weblog put up, we’ll element what steps to take to completely create and allow an OTA replace scheduling answer utilizing AWS IoT Jobs, dynamic factor teams, and Machine Shadows.

Conditions

To observe via this weblog put up, you will have:

  1. An AWS account
  2. Entry to an AWS IoT Core supported area
  3. Entry to an AWS IoT Machine Administration supported area
  4. Entry to AWS CloudShell

Walkthrough

For the demonstration on this put up, you’ll schedule a weekly OTA replace that may solely run between 9PM and 6AM gadget native time. To do that, you’ll create two AWS IoT dynamic factor teams, one for Central Commonplace Time (CST) and one for Pacific Commonplace Time (PST), that may every be robotically populated with units in response to their time zone. A tool’s time zone might be reported by their corresponding AWS IoT Machine Shadow. You’ll then create and configure two AWS IoT Jobs, one for every dynamic factor group. Every job may have a schedule configuration with the upkeep window set to reoccur weekly from 9PM to 6AM. The illustration under particulars what this answer will appear to be as soon as absolutely carried out.

A diagram that shows two devices being added to two separate AWS IoT dynamic thing groups, with two separate AWS IoT Jobs running on each device according to the timezone they're in.

Step 1: Create AWS IoT dynamic factor teams

To create your AWS IoT dynamic factor teams (AWS CloudShell, AWS CLI):

  1. Allow AWS IoT Machine Administration fleet indexing by issuing the update-indexing-configuration command
  2. Create the AWS IoT dynamic factor group for units within the PST time zone by issuing the create-dynamic-thing-group command
    aws iot create-dynamic-thing-group --thing-group-name "pstdevices" --query-string "shadow.reported.timezone:PST"
  3. Create the AWS IoT dynamic factor group for units within the CST time zone by issuing the create-dynamic-thing-group command
    aws iot create-dynamic-thing-group --thing-group-name "cstdevices" --query-string "shadow.reported.timezone:CST"

Step 2: Configure gadget time zones

To configure your gadget’s time zones (AWS CloudShell, AWS CLI):

  1. Create an AWS IoT factor for the gadget deployed within the PST time zone by issuing the create-thing command
    aws iot create-thing --thing-name "vibrationdevicepsttimezone"
  2. Create an AWS IoT factor for the gadget deployed within the CST time zone by issuing the create-thing command
    aws iot create-thing --thing-name "vibrationdevicecsttimezone"
  3. Create an AWS IoT Machine Shadow for the gadget deployed within the PST time zone by issuing the update-thing-shadow command
    aws iot-data update-thing-shadow --cli-binary-format raw-in-base64-out --thing-name vibrationdevicepsttimezone --payload '{"state":{"reported":{"timezone":"PST"}}}' "vibrationdevicepsttimezone.txt"
  4. Create an AWS IoT Machine Shadow for the gadget deployed within the CST time zone by issuing the update-thing-shadow command
    aws iot-data update-thing-shadow --cli-binary-format raw-in-base64-out --thing-name vibrationdevicecsttimezone --payload '{"state":{"reported":{"timezone":"CST"}}}' "vibrationdevicecsttimezone.txt"
  5. Confirm that the AWS IoT factor for the gadget deployed within the PST time zone was added to the pstdevices AWS IoT dynamic group by issuing the list-thing-groups-for-thing command
    aws iot list-thing-groups-for-thing --thing-name vibrationdevicepsttimezone

    The output from the command ought to look just like the next:

    {
        "thingGroups": [
            {
                "groupName": "pstdevices",
                "groupArn": "arn:aws:iot:us-east-1:<AWSACCOUNTID>:thinggroup/pstdevices"
            }
        ]
    }
  6. Confirm that the AWS IoT factor for the gadget deployed within the CST time zone was added to the cstdevices AWS IoT dynamic group by issuing the list-thing-groups-for-thing command
    aws iot list-thing-groups-for-thing --thing-name vibrationdevicecsttimezone

    The output from the command ought to look just like the next:

    {
        "thingGroups": [
            {
                "groupName": "cstdevices",
                "groupArn": "arn:aws:iot:us-east-1:<AWSACCOUNTID>:thinggroup/cstdevices"
            }
        ]
    }

Step 3: Create AWS IoT Jobs

To create your AWS IoT Jobs (console):

    1. Open the AWS IoT console
    2. On the left-hand navigation bar, underneath Handle, Distant Actions, select Jobs
    3. Select Create Job
    4. Choose Create customized job
    5. Enter a job title of pstdevicesiotjob
    6. For Factor teams to run this job, select pstdevices
    7. Select the Job template you want to use for this demonstration
    8. Select Subsequent
    9. For Job run Sort, choose Steady
    10. Below Further configurations, select Scheduling configuration
    11. For Job begin, enter immediately’s date and a time one hour forward of your present time
    12. For Recurring upkeep window, choose Weekly
    13. For On these weekdays, choose Saturday
    14. For Upkeep window begins from, enter a time of 21:00 (9:00PM in 24-hour format)
    15. For Upkeep window period, enter 9 hours and 0 minutes (ending job executions at 6:00AM)
      Your console needs to be just like the next screenshot:A screenshot of the AWS IoT Console where Scheduling configuration parameter Job start is set to today's date, one hour ahead, Recurring maintenance window is set to Weekly, On these weekdays is set to Saturday, Maintenance window starts from is set to 21:00, and Maintenance window duration is set to 9 hours and 0 minutes.
    16. Select Submit
    17. Repeat steps 2 via 15 utilizing the next:
      • Set job title to cstdevicesiotjob
      • Set Factor teams to run this job to cstdevices
      • Select the identical Job template you utilized in step 7
      • Select Submit
    18. Below Standing, guarantee each jobs are displaying as Scheduled
      Your console needs to be just like the next screenshot:

A screenshot of the AWS IoT Console where the AWS IoT Job is showing a status of Scheduled.

The standing of every job will change to In progress after your configured Upkeep window begins from date and time passes. Every job will then begin a job execution on each gadget inside the focused AWS IoT dynamic factor group at 9PM gadget native time on Saturday and finish job executions at 6AM on Sunday. These job executions will happen on each present and newly added gadget till the Upkeep window period time has handed. As soon as the Upkeep window period time has handed, the standing of every job will change again to Scheduled. This course of will happen weekly till you cancel every job.

Cleansing Up

You should definitely take away the sources created on this weblog to keep away from costs.
Out of your AWS CloudShell setting situation the next instructions:

  1. aws iot delete-thing —thing-name "vibrationdevicepsttimezone"
  2. aws iot delete-thing —thing-name "vibrationdevicecsttimezone"
  3. aws iot delete-job --job-id "pstdevicesiotjob"
  4. aws iot delete-job --job-id "cstdevicesiotjob"
  5. aws iot delete-dynamic-thing-group --thing-group-name "pstdevices"
  6. aws iot delete-dynamic-thing-group --thing-group-name "cstdevices"
  7. aws iot update-indexing-configuration --thing-indexing-configuration thingIndexingMode=OFF

Conclusion

On this put up you realized find out how to deploy an OTA replace inside an authorised timeframe to a fleet of units which are deployed throughout a number of time zones utilizing AWS IoT Jobs, dynamic factor teams, and Machine Shadows. Utilizing this method, you’ll be able to remotely deploy updates to your fleet of units, and get the peace of thoughts that every gadget will begin the replace on the appropriate time and apply it solely throughout your sanctioned time window. For a extra in depth take a look at AWS IoT Jobs, try our Get Began with AWS IoT workshop and this weblog put up on find out how to Schedule distant operations utilizing AWS IoT Machine Administration Jobs.

Creator bio

Nicholas Switzer is an IoT Specialist Options Architect at Amazon Net Providers. He joined AWS in 2022 and makes a speciality of IoT and Edge Computing and the related product area. He’s based mostly within the US and enjoys constructing good merchandise that enhance on a regular basis life.

Leave a Reply

Your email address will not be published. Required fields are marked *