The config synchronization service facilitates the synchronization of the state information between a device and a device twin.
A device twin is a database entry, associated with a specific device, stored in the cloud. A device twin contains desired properties and reported properties. A desired property is set by a back-end application and read by a device. A reported property is set by a device and read by a back-end application.
The device can access the digital twin through the api. The base url and api key are provided by the Device Provisioning service.
Device properties/states are sent to the cloud through the api whenever they are updated. The json payload is saved in the database as reported properties
.
curl -X POST -H "Authorization: apikey <API_KEY>" <BASE_URL>/properties
Reported properties
{
"address": {
"latitude": number,
"longitude": number
},
"control": {
"enabled": boolean
},
"pvForecasting": {
"enabled": boolean,
"peakPower": number,
"azimuth": number,
"inclination": number
}
}
The desired properties
are a subset of the reported properties
that can be updated throught the back-end service. The device polls the api for changes to the desired device configuration. Whenever one or more properties have a desired value that is different from the actual/reported value, the device makes the changes and sends the entire configuration back to the cloud.
curl -X GET -H "Authorization: apikey <API_KEY>" <BASE_URL>/properties
Desired properties
{
"address": {
"latitude": number,
"longitude": number,
"timeZone": "string",
"postalCode": "string",
"city": "string",
"country": "string",
"countryCode": "string"
},
"control": {
"enabled": boolean
},
"pvForecasting": {
"enabled": boolean,
"azimuth": number,
"inclination": number,
"peakPower": number
}
}
Note that the device only needs to update the latitude and longitude in the address object. The other address properties are derived from these coördinates in the cloud.