1

I have location added to a space that sits 2 levels above sensor but I am finding no way with the current client reference operation to get the location as I want to enrich the telemetry with space location information.

I have used the following getSpaceMetadata getSpaceExtendedProperty(spaceId, propertyName) //As it is not extended property

I need the functionality similar to this

https://urlofdigitaltwin/management/api/v1.0/spaces/633a40d6-790d-4bd5-92c5-1cc8b1a86141/?includes=location

Please let me know if there is a way I can always do it inside some other azure service by going and reading these separately.

  • space with location
    • device
    • sensor -matcher -udf

1 Answers1

0

Thanks for the great question! Azure Digital Twins is undergoing continuous improvement. I hope you'll find the documentation significantly improved.

Assuming you have extracted the location ID from the sensor or device, you can find the associated parentSpaceId:

{
    "id": "aa000aaa-a0a0-0000-a0aa-00000a000aa0",
    "name": "Example Room",
    "typeId": 14,
    "parentSpaceId": "1b1b1111-b1b1-1111-111b-1b1b11b11111",
    "subtypeId": 13,
    "statusId": 12
}

From there you can call the top-level space directly. You can combine that operation with several API query parameters such as traverse, minLevel, and maxLevel which should allow you to fetch everything you need in one call.

Two new resources that describe those API operations are now available:

Thanks!

Adam Gerard
  • 708
  • 2
  • 8
  • 23
  • 1
    Does this work in the context of the UDF was more that I was after the ability to have the udf fetching those details – Bala Takkallapati Jan 22 '19 at 01:58
  • If I understand your original question more fully, you can use the same API features above within a UDF. You could, for instance, call an API using the query features describe above and traverse to find the desired extended type or subtype. – Adam Gerard May 13 '19 at 17:51
  • A few code samples that demonstrate how to work with complex UDF operations live here: https://learn.microsoft.com/en-us/azure/digital-twins/tutorial-facilities-setup and here: https://github.com/Azure-Samples/digital-twins-samples-csharp/tree/master/occupancy-quickstart/src/actions/userDefinedFunctions. The second link includes a UDF itself, the rest of the code (C#) interacts with the DT API's and handles UDF deployment. – Adam Gerard May 13 '19 at 17:56
  • You might find it more convenient to do that kind of API traversing within your wrapping code (in the examples that'd be equivalent to the C# code). – Adam Gerard May 13 '19 at 18:03