In many cases the devices do not have to be always connected to the internet because they only send or receive data in large time intervals. However, in some cases, devices must always be connected to the internet,but occasionally the connection fails and it takes a certain amount of time to reconnect. For both cases, the idea of ‘Thing Shadow’ or ‘Device Shadow’ has emerged where the state of sensor connected to the device is stored in a JSON document and can be retrieved at any time.
This state can be requested or set via MQTT or HTTP even if the device is currently not connected to the internet. For example, the device is not connected to the internet for a certain period of time, but while the device is ofﬂine, the user sets the desired state of the light from ‘off’ to ‘on’. The desired state will be submitted to the device as soon as the device is online again and the state will be reported back to the application. Eventually, once the change of state has been carried out, the state changes and is saved as ‘delta’. The three methods of interacting with device shadows are: update, get and delete, while the states are: desired, reported, and delta.