Skip to content

Cantara/realestate-azure-client-lib

Repository files navigation

realestate-azure-client-lib

Co2 Observations Example Distribute Sensor Observations to Azure IoT Hub and to Azure Data Explorer.

Sensor observations are imported from eg. Metasys using the RealEstate CloudConnector

Azure IoT HUB configuration

Create IoT Hub

See the official Azure IoT Hub documentation for details.

Create IoT Hub Device

See the official Azure Create Device documentation for details. From the Device's config page copy the "Primary connection string". This string need to be copied to the local_override.properties in CloudConnector, "distribution.azure.connectionString="

Verify observations distribution

Startup the CloudConnector and verify that observations are distributed to Azure IoT Hub.

  1. In the logfile (logs/metasys..log) you should see something like this:
Establishing and verifying connection to Azure.
  1. CloudConnector Health on http://:/cloudconnector/health/pretty - look for:
"AzureObservationDistributionClient-isConnected: ": "true",
"AzureObservationDistributionClient-numberofMessagesObserved: ": "1",

Verify data in Azure IoT Hub

In the IoT Hub, select the "Metrics" menu item. Create a new chart with the following settings:

Sum Routing: telemetry messages delivered for <your IoT Hub>

Azure Data Explorer configuration

Create Azure Data Explorer database

See the official Azure Data Explorer documentation for details.

Create Data Connection from IoT Hub to Azure Data Explorer

In the "Overview" of the Azure Data Explorer database, select the "IoT Hub" button, under "Data connections". See the official Azure Data Explorer documentation for details.

Mapping of CloudConnector observations to Json Telemetry Mapping

See JsonMapping input from IoTHub to ADX for details. "Name": JsonTelemetryMapping, "Kind": Json, "Mapping":

 [{
 	"column": "messageId",
 	"path": "$.messageId",
 	"datatype": "",
 	"transform": null
 }, {
 	"column": "sensorId",
 	"path": "$.sensorId",
 	"datatype": "",
 	"transform": null
 }, {
 	"column": "tfm",
 	"path": "$.tfm",
 	"datatype": "",
 	"transform": null
 }, {
 	"column": "realEstate",
 	"path": "$.realEstate",
 	"datatype": "",
 	"transform": null
 }, {
 	"column": "building",
 	"path": "$.building",
 	....

See JsonTelemetryMapping for the full mapping.

Dashboard

In Azure Data Explorer, select "Dashboard" and create a new dashboard. Query for CO2 observations in all rooms, for a single floor:

RealestateTelemetry
| project placementRoom,building,floor,realEstate,sensorType, observationTime, value
| where realEstate == "511" and building == "511" and floor in ("1", "01") 
| where sensorType == "CO2"
| where observationTime  between (['_startTime'] .. ['_endTime']) 

"RealestateTelemetry" is the name of the table created above.

Development

Build

mvn clean install

Manual verification

Run AzureDeviceClientmanualTest from your IDE.

About

Communication back and forth to Azure

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages