An efficient Schedule and Notification system for IOT devices

Schedule and Notification System

Internet of Things (IOT) is one of the greatest innovations in Technology . Some of its applications are Home Automation, Surveillance, wearable devices, smart cars, etc. Schedule systems for these IOT devices have become so beneficial. We designed Schedule system for arranging, controlling and optimizing work and workloads like automating the turning of bulbs on/off, periodic watering of plants using smart devices, etc. Notification systems enhance the delivering of notifications as per event to the appropriate entity. Notifications are a way to notify you as a form of popup or message in email & sms about any events like friendly reminders, device failures, schedules success ,etc.

Lets see a use case of a schedule system

Suppose I have an AC at home and I want to turn it OFF at 1 am and make my fan ON at the same time everyday. So the schedule system will schedule the AC to be OFF and fan ON at 1 am. everyday. And the notification system will notify about the event status. This is a simple use case for schedule and notification system. 

We can also schedule watering devices at nursery to water plants everyday at 7 in the morning and this makes our job easy.

Let’s take a problem statement

Here we have a bunch of devices like AC, bulbs, fans and heater. We want to design a schedule system for these devices and get notifications for every scheduled event .

How can we interact with the devices

Here, we have devices like AC, bulbs, fans and heater which are all connected to a single Atom8 device, which controls the other connected devices asynchronously. You can check the Atom8 devices here.

MQTT Protocol

MQTT stands for MQ Telemetry Transport. It is a machine to machine / ‘Internet of Things’ connectivity protocol. It is a lightweight, publish-subscribe message transport network protocol that transports messages between devices.

MQTT Broker

It is a server through which all the messages are passed hence, it acts like a middle man which supports pub-sub messaging pattern and all the devices are connected to it. It uses the topic of message and decides which client and device are getting messages.

MQTT Topics

Topics refers to strings that brokers use to filter messages for each connected client and device.

MQTT Broker and Topics

The above diagram is an example of how devices interact. Broker contains two MQTT topics Topic 1 & Topic 2. Here it uses a pub-sub model. Device A subscribes to Topic 1 and Device B subscribes to Topic 2. 

Now when the client publishes a message ‘ON’ to Topic 1, the broker will send this message to all devices and clients that have subscribed to Topic 1. In current case the Device A will recieve message to and will turn itself On.

For more details, refer :


AWS IOT is a platform by Amazon Web services to manage ‘Internet Of Things’ devices. These devices are also termed as ‘Things’. Like other services AWS IOT can connect to other AWS cloud services making its application much wider. 

Things transmit messages through device gateway, where they update the ‘Device Shadow’. A device shadow (or a thing shadow) is an object/document holding information of device in AWS IOT Device Shadow Service and updates to change the state of the device. The thing shadow eliminates the need to request information from the device to retrieve its state and reduces network traffic. In our case the Atom8 device is a thing. We have to set up the thing on AWS IOT first. 

For use case, refer :

Sending Message to a device

AWS IOT uses MQTT broker to transmit messages between Cloud and Devices. Suppose we want to make our AC ‘On’. Atom8 device handles AC. So now we have to update device shadow (state of the device) using Rest calls. A message publishes to the current Atom8 thing topic of AWS IOT MQTT broker when there is an update in device shadow. Now our Atom8 device have already subscribed to that topic so the broker publishes that message to this Atom8 device and as per the message it makes our AC ‘On’.

A sample flow chart to change the state of device :

Process to change the device state

Structure of Device Shadow

Device Shadows can make a device’s state available to apps and other services. Every shadow has a reserved MQTT topic and HTTP URL that supports the get, update, and delete actions on the shadow.Shadows use JSON shadow documents to store and retrieve data. A shadow’s document contains a state property that describes these aspects of the device’s state:

  1. desired
    – This  specifies the desired states of device properties by updating the desired object.
  2. reported
    – Devices report their current state in the reported object.
  3. delta
    – AWS IoT reports differences between the desired and the reported state in the delta object.

Structure of Device Shadow

					console.log( 'Code is Poetry' );{
    "state": {
        "desired": {
            "field1": integer2,
            "field2": "string2"
        "reported": {
            "field1": integer1,
            "field2": "string1"
    "version": version

For more details about device shadow you can refer this :

So now we are familiar with the process of changing the state of a device. Let’s start with a simple approach to Schedule and Notification system i.e. Version 1.

Schedule and Notification System V1

In this simple approach, we will design an end to end system to run schedules and send notifications to appropriate entities.

Here we use AWS cloudwatch, Lambda, IOT and Send Notification services.We write API codes are in AWS Lambda.

As we have already discussed in detail about how we can change the device state using device shadow, Mqtt and Atom8 devices. In this design we will focus on changing the device shadow state in AWS IOT for schedules.

Schedule and Notification System Version1


  • To run the schedules we want to call ExecuteScheulde API  at appropriate time everyday. So for that we will use Events rule in AWS Cloud Watch. Here we will define a rule to trigger a event at scheduled time and call ExecuteSchedule with appropriate data about the update to device details and required state changes.
  • Every Atom8 device can handle multiple devices like fan & AC and a home can have multiple Atom8 devices.
  • So every schedule can have multiple events of the same Atom8 devices or combination of multiple Atom8 devices.
  • For ‘n’ events ExecuteSchedule API will make ‘n’ asynchronous calls to UpdateThingShadow API. So AWS will create ‘n’ instances of UpdateThingShadow and these instances will update the desired state of the respective thing’s device shadow in AWS IOT.
  • This updates in device shadow will publish messages to respective MQTT topics and topics will publish messages to subscribed devices.
  • Hence in this way we can run multiple events in a single schedule.
  • After that the ExecuteSchedule API will call SendNotification API which will create a notification body and also will list endpoints of device’s owners.
  • After the completion of the above work, SendNotification API will push Notification messages to the concerned SNS endpoints which will push notifications to concerned phones.

In this way we can automate a schedule and send notification. Here we can also set events in cloudwatch using code made with aws-sdk.

Disadvantages of above system

  • When a device changes its state as per desired state it reports back with a reported state to AWS IOT results in updating reported state of device shadow of particular thing. In the above system we are not considering the reported state. So if a device fails to report back due to any issue, still the schedule will be considered successful.
  • All MQTT calls are asynchronous and the messages sometimes are not in order, so handling and checking the reported state is difficult.
  • Here we don’t consider any type of failure in the schedule event. The reason we can update the desired state is whether the device is online or offline, but the device only reports back when it’s online. So not considering the reported state can neglect failures of events.
  • Further we cannot notify users about successful, partial or failed execution of schedule.

To overcome these disadvantages we can design an improved Schedule and Notification system.

Schedule and Notification System V2

Here the main point of concern was to consider the reported state of the device also. To do that our system must have to wait for the device to report back so that we can analyze the reported state and see whether the scheduled event was successful.

So here AWS StepFunctions becomes very useful. StepFunctions consists of workflow of states. Our system can be divided into different states and we can define a workflow to run those states in a required manner. In StepFunctions we will work on two most important features which are Dynamic Parallelism and waitForTaskToken.

Dynamic Parallelism in step functions

In Dynamic Parallelism in step functions, we can run identical parallel tasks as per input to the state. Here the number of parallel tasks is decided as per the length of the input array. It runs on scatter and gather model. The ‘Map’ state can be used in step functions to run the same steps for multiple entries of the input array in parallel.

For examples, refer :

‘waitForTaskToken’ task in step functions

These types of tasks can be used when we need a callback from an external service. So here we can call an external service with a taskToken included in the input. Here the workflow will stop and wait for taskToken to be returned with ‘sendTaskSuccess’ after which the task will be considered finished and the workflow will resume. ’sendTaskSuccess’ along with taskToken can be sent using aws-sdk in any programming language.

Example of waitForTaskToken task :

					"sample wait state": {
  "Type": "Task",
  "Resource": "arn:aws:states:::lambda::invoke.waitForTaskToken",
  "Parameters": {
    "Function": "lambdaFunctionName",
    "Payload": {
        "input": "inputString",
        "TaskToken.$": "$$.Task.Token"
  "Next": "NEXT_STATE"

For usecases you can refer :

In our system we will be using a combination of Dynamic Parallelism and waitForTaskToken feature in step functions to wait for the reported state to return.

First we will execute the ExecuteScheduleWorkflow step function :

Process to execute ‘ExecuteScheduleWorkflow’ step function

Here the Cloudwatch event rule will trigger ExecuteSchedule API with appropriate input at required time. And ExecuteSchedule will start ExecuteScheduleWorkflow step function.

Working of ExecuteScheduleWorkflow stepfunction

Now further we will see the ExecuteScheduleWorkflow Step Function in detail.

The workflow above is designed in AWS Step Functions using Amazon states language (asl). It is similar to json and we can define states and their flow in them. You can see we can call external cloud services like lambda functions within the states.

Note : Here the states are basically the group of tasks , which runs when step function workflow running is in that state.

So lets go state by state :

State 1 : Enable Dynamic Parallelism and Update Thing shadow

  • Here suppose we have 3 events in a schedule. These events can be on the same device or different devices. So we will enable a Map task here where there will be an input array of 3 events. 
  • We will define a task called ‘UpdateShadow’ inside the map state. This map state will execute the same task ’UpdateShadow’ for every element(event) of the input array to the map state. That means for our example 3 parallel UpdateShadow tasks will run concurrently.
  • Let’s define this ‘UpdateShadow’ task

‘UpdateShadow’ task

  • First it will create a subtask of type ‘waitForTaskToken’. This subtask will call ‘UpdateThingShadow’ lambda function with input and taskToken.
  • taskToken will be unique for every task.
  • Here this subtask will wait for taskToken to be returned within ‘n’ secs.
  • In our case there will be 3 tasks each in a parallel task waiting for a taskToken.

‘UpdateThingShadow’ Lambda Function

  • This lambda function will store the taskToken to the dynamoDb database and with a primary key as ‘scheduleID’ and attributes a ‘taskToken’.
  • This lambda function will update the desired state of the Thing’s shadow in AWS IOT where the device will receive a message to change the state and after changing the state the device will report back with the reported state.
  • Here the desired state will also contain the field called scheduleID so that the device can report back with the same scheduleID and it will be easy to reference the task.
  • Here reports back means the reported state of the Thing’s shadow will be updated.


  • Rules are the part of AWS IOT which gives you an ability to trigger any AWS cloud services when the messages are published in MQTT topics.
  • So we define a rule that whenever there is a change in the  shadow of a concerned device it can trigger the ‘SendTaskSuccess’ with the shadow update as input.

‘SendTaskSuccess’ Lambda Function

  • Here this lambda function is triggered by AWS IOT rule when there is a change in thing shadow. Here the input is the update in shadow.
  • Now update can be any like metadata, reported state or desired state update. Here we will only consider a reported state update.
  • Now we have a reported state update we can take the scheduleID field from that and extract the taskToken from the dynamodb table.
  • Since we have the taskToken we can send task success to the step function task which is waiting for the taskToken. Here we will also send the reported state along with the taskToken.

This is how we can get the reported state of the concerned device.

Edge cases

  • Here we know that all calls of MQTT are async and they might be out of order. But as we have a unique scheduleID for every event and also taskToken will only be received by the concerned task hence it is assured that the valid reported state will be received by the respected waiting task
  • If the device doesn’t reports back on time :
    • The subtask will run a timeout task which will call ‘CheckCurrentState’ Lambda and this lambda will check the current reported state of the respective device and here we can waitTaskToken for getting response back from CheckCurrentState Lambda.

Now here we have an output array (output from all parallel tasks) having reported states of the devices after the scheduled events are run parallely.

State 2 : SendNotification

  • In these the desired states from input and reported states from map state are sent to the ‘SendNotification’ lambda function.

‘SendNotification’ Lambda Function

  • Here for every event the desired state and reported state are compared checking whether the schedule was overall Successful, Partially Successful  or failed.
  • After that a message body is created.
  • We wanted to send messages to the owner of all devices so we will first get the SNS endpoints of the owners from the database.
  • We will push the Notifications in AWS Simple Notification services, which further will notify the respective owners by means of popup / sms. 

Here in these ways we step function workflow ends and finally after consideration of the reported state we made a fail safe and efficient Schedule and Notification system.

Alternative OpenSource Workflow design approaches

  • We can use Uber cadence open source for designing the workflow.
  • We can also use Apache Airflow.


  1. zaimy_pvpi says:

    мини займы [url=][/url]

  2. [url=]Аренда микроавтобуса[/url]

    Для вас необходимо запретить почасовую аренду автобуса или ну микроавтобуса на нашем сайте, числом электронной почте то есть числом телефону. Через некоторое время того, яко вы остановить свой выбор редакция, яже вам приткнет да удостоверили его, вам сразу же позвонят и уточнят мелочи заказа.
    Аренда микроавтобуса

  3. AndrewLoory says: – Быстрый выкуп битых авто марки Wartburg модели Biante, 1987 года выпуска, тип кузова лимузин с объемом двигателя 2366 коробка передач автоматическая в Санкт-Петербурге.

  4. изготовление памятников из гранита [url=https://xn—-7sbhdlakgabeqtfpknah6dj9y.xn--p1ai/]http://www.xn—-7sbhdlakgabeqtfpknah6dj9y.xn--p1ai/[/url]

  5. vng_fopi says:

    куплю внж [url=https://xn—-btbbq8aon.xn--p1ai/]https://xn—-btbbq8aon.xn--p1ai/[/url]

  6. AmyLab says:

    [url=]acyclovir 800 mg coupon[/url]

  7. zaim_jzpi says:

    мини кредит онлайн [url=][/url]

  8. MichaelNam says:

    [url=]lisinopril 20mg tablets price[/url]

  9. MezhevanieCic says:

    Межевание земельного участка [url=][/url]

  10. SamLab says:

    [url=]tadacip uk[/url] [url=]avodart for sale uk[/url] [url=]flomax 40 mg[/url] [url=]ciprofloxacin cost[/url]

  11. xbetzer says:


    1xBet — этто опытная букмекерская контора, тот или иной понимает преходящие ограничения собственных клиентов числом старый и малый миру.
    1xbet zerkalo

  12. avtorazborka says:


    Автозапчасти чтобы иномарок со огромнейших разборок Европы, ЭТАЛОН ДЕМОКРАТИИ а также Стране восходящего солнца ? Даровая доставка б/у запасных частей по и стар и млад Стране россии ? Твердое слово до 30 суток …

  13. zaim_pvPr says:

    кредит мини [url=][/url]

  14. SdvillMar says:

    [url= ]american oil chemists’ society [/url]
    Tegs: american polymer standards corporation

    [u]leibniz institute dsmz gmbh [/u]
    [i]lexogen [/i]
    [b]lexogen com [/b]

  15. MichaelNam says:

    [url=]desyrel coupon[/url]

  16. avtorazbor says:


    Авторазбор. Шиздец спросы по телефону. Является шиздец запчасти сверху Ваз. Ауди вукуп молоченных аворийных авто. Запчасти и аксессуары.

  17. MichaelNam says:

    [url=]can i buy metformin over the counter in uk[/url]

  18. KimLab says:

    [url=]albuterol 063[/url]

  19. iphone_bdPr says:

    айфон заказать недорого [url=][/url]

  20. KiaLab says:

    [url=]albenza for pinworms[/url]

  21. sexshop_gpPr says:

    INTT [url=][/url]

  22. Michaelped says:

    [url=]buy tadacip online uk[/url]

  23. DarrylDet says:

    [url=]buy tadacip 20 mg without prescription[/url] [url=]purchase antabuse online[/url] [url=]how much is 1 viagra pill[/url] [url=]ivermectin malaria[/url]

  24. plitka_vcPr says:

    тротуарная плитка купить [url=][/url]

  25. SdvillMar says:

    [url= ]маркетинг обучение высшее tgu dpo [/url]
    Tegs: маркетинг обучение высшее образование tgu dpo

    [u]обучение бизнесу с нуля бесплатно онлайн tgu dpo [/u]
    [i]обучение бизнесу с нуля в екатеринбурге tgu dpo [/i]
    [b]обучение бизнесу с нуля в москве tgu dpo [/b]

  26. Доставка грузов из Голландии [url=][/url]
    Доставка грузов из Европы [url=][/url]

  27. IvyLab says:

    [url=]xenical tablets price in south africa[/url] [url=]augmentin 1000mg price[/url] [url=]clonidine insomnia[/url] [url=]metformin glucophage[/url]

  28. Noski_Sedge says:

    Носки короткие мужские [url=]Купить короткие носки[/url]

  29. AndrewLoory says: – Выкуп авто аварийных автомобилей марки Daewoo модели H530, 1954 года выпуска, тип кузова внедорожник открытый с объемом двигателя 7680 коробка передач автоматическая в Петербурге.

  30. JimLab says:

    [url=]buy provigil online cheap[/url]

  31. PaulLab says:

    [url=]ciprofloxacin online prescription[/url]

  32. Доставка грузов из Испании [url=][/url]
    Доставка грузов в Испанию [url=][/url]

  33. SdvillMar says:

    [url= ]geicp [/url]
    Tegs: geicp com

    [u]G M Chemical [/u]
    [i]GE Healthcare [/i]
    [b]GERSTEL [/b]

  34. mczsbzbrn says:

    An efficient Schedule and Notification system for IOT devices – Atom8

  35. JudyLab says:

    [url=]cleocin hcl used treat[/url]

  36. [url=]мульти сплит система[/url]

    Мини-сплит – этто тесная система отопления и еще кондиционирования. Мини-сплиты — ядреный выбор для расширения светелок чи проверочного климат-контроля, хоть бы, сверху одном этаже, в один-одинехонек крыле чи на раздельных комнатах дома.
    мульти сплит система

  37. [url=]Сплит-системы[/url]

    Энергосистема произведено изо один-один-одинехонек внешного и раза внутреннего блока. В ТЕЧЕНИЕ основной массе случаев внутренние блоки смогут яко освежать, так равным образом нагревать.

  38. строительство дома под ключ [url=][/url]

  39. AshLab says:

    [url=]ampicillin 750 mg[/url] [url=]generic seroquel 400 mg[/url] [url=]where to buy priligy online[/url] [url=]levitra medicine[/url] [url=]erectafil 10 mg[/url] [url=]buy amoxicillin 500mg without prescription[/url]

  40. Доставка грузов в Германию [url=][/url]
    Доставка грузов из Испании [url=][/url]

  41. StanleyBog says: – Срочный выкуп битых автомобилей марки ZX модели Bipper, 1929 года выпуска, тип кузова пикап с объемом двигателя 3201 коробка передач вариатор в Петербурге.

  42. ElwoodHew says:

    [url=]cialis australia over the counter[/url]

  43. KiaLab says:

    [url=]buy ventolin tablets online[/url]

  44. TeoLab says:

    [url=]zovirax best price[/url]

  45. ElwoodHew says:

    [url=]inderal 80[/url]

  46. строительство дома под ключ [url=][/url]

  47. AshLab says:

    [url=]cozaar 5mg[/url] [url=]cost of elavil in usa[/url] [url=]singulair discount[/url] [url=]suhagra price[/url] [url=]avodart 2.5 mg buy[/url] [url=]valtrex pill cost[/url] [url=]buy sildalis 120 mg[/url]

  48. Перевозка вещей в Германию [url=][/url]
    Доставка грузов во Францию [url=][/url]

  49. [url=]выкуп авто в Санкт-Петербурге[/url]

    Покупка каров – строгое фраза чтобы водителей, кои рассматривают возможность реализации близкого автомобиля.
    выкуп авто в Санкт-Петербурге

  50. ElwoodHew says:

    [url=]seroquel 75 mg[/url]

  51. zaimyonlines says:

    Получить наличные сейчас! Жми и Получи наличные уже сейчас!

Leave a Reply

Your email address will not be published.