IoT Central - State values error: Another instance with the same id already exists - azure-iot-central

I just don't get it.
If I want to define a status, I must be able to refer to a value several times, right?
Sensor value is occupancy with value 0 (Free) or 1 (Occupied). So I have 2 states, but I can only use "occupancy" in the Name it once ...
Regards,
Matthias
enter image description here

For better understanding, let's call the State property (such as a device twin reported property) as an Occupancy.
The following screen snippet shows its declaration, where the Occupancy state property has two states such as the Free and Occupied (Occupancy.Free and Occupancy.Occupied):
and its declaration in the Interface instance of the Capability Model (in my example):
{
"#id": "urn:rigado:interfaces:S1_Sensor:Occupancy:3",
"#type": [
"Property",
"SemanticType/State"
],
"displayName": {
"en": "Occupancy"
},
"name": "Occupancy",
"schema": {
"#id": "urn:rigado:interfaces:S1_Sensor:Occupancy:xkuwdf9p:3",
"#type": "Enum",
"valueSchema": "integer",
"enumValues": [
{
"#id": "urn:rigado:interfaces:S1_Sensor:Occupancy:xkuwdf9p:Free:3",
"#type": "EnumValue",
"displayName": {
"en": "Free"
},
"enumValue": 0,
"name": "Free"
},
{
"#id": "urn:rigado:interfaces:S1_Sensor:Occupancy:xkuwdf9p:Occupied:3",
"#type": "EnumValue",
"displayName": {
"en": "Occupied"
},
"enumValue": 1,
"name": "Occupied"
}
]
}
}
As you can see in the above schema, the names in the enumValues array must be unique, that is a reason why you get the error, when you used the same enum name.
Note, that the device can change the state of the Occupancy property between the values such as Free (0) and Occupied (1).
For testing purpose can be used the Azure IoT Hub Tester, see the following screen snippet:
The following screen snippets show changing a state in the Occupancy reported property on the PnP device (sensor3) connected to the IoTC App:
Publishing a Occupancy state:
Get the device twin properties:
and the IoTC App Dashboard for Occupancy State property:
As you can see, the about state has a value Free.

Related

It is possible to have varying data structures in an Azure search index?

Below is some of the data I'm putting into an Azure search index:
I could go with this rigid structure but it needs to support different data types. I could keep adding fields - i.e. Field4, Field5, ... but I wondered if I could have something like a JSON field? So the index could be modelled like below:
[
{
"entityId":"dba656d3-f044-4cc0-9930-b5e77e664a8f",
"entityName":"character",
"data":{
"name":"Luke Skywalker",
"role":"Jedi"
}
},
{
"entityId":"b37bf987-0978-4fc4-9a51-b02b4a5eed53",
"entityName":"character",
"data":{
"name":"C-3PO",
"role":"Droid"
}
},
{
"entityId":"b161b9dc-552b-4744-b2d7-4584a9673669",
"entityName":"film",
"data":{
"name":"A new hope"
}
},
{
"entityId":"e59acdaf-5bcd-4536-a8e9-4f3502cc7d85",
"entityName":"film",
"data":{
"name":"The Empire Strikes Back"
}
},
{
"entityId":"00501b4a-5279-41e9-899d-a914ddcc562e",
"entityName":"vehicle",
"data":{
"name":"Sand Crawler",
"model":"Digger Crawler",
"manufacturer":"Corellia Mining Corporation"
}
},
{
"entityId":"fe815cb6-b03c-401e-a871-396f2cd3eaba",
"entityName":"vehicle",
"data":{
"name":"TIE/LN starfighter",
"model":"win Ion Engine/Ln Starfighter",
"manufacturer":"Sienar Fleet Systems"
}
}
]
I know that I can put JSON in a string field, but that would negatively impact the search matching and also filtering.
Is this possible in Azure search or is there a different way to achieve this kind of requirement?
See the article How to model complex data types. The hotel example data translates nicely to your use-case I believe. If your different entities have different sets of properties you can create a "complex type" similar to the Address or Amenities example below.
Structural updates
You can add new sub-fields to a complex field at any time without the
need for an index rebuild. For example, adding "ZipCode" to Address or
"Amenities" to Rooms is allowed, just like adding a top-level field to
an index.
{
"HotelId": "1",
"HotelName": "Secret Point Motel",
"Description": "Ideally located on the main commercial artery of the city in the heart of New York.",
"Tags": ["Free wifi", "on-site parking", "indoor pool", "continental breakfast"]
"Address": {
"StreetAddress": "677 5th Ave",
"City": "New York",
"StateProvince": "NY"
},
"Rooms": [
{
"Description": "Budget Room, 1 Queen Bed (Cityside)",
"RoomNumber": 1105,
"BaseRate": 96.99,
},
{
"Description": "Deluxe Room, 2 Double Beds (City View)",
"Type": "Deluxe Room",
"BaseRate": 150.99,
}
. . .
]
}

GPS location for IoT central map tile

I am trying to get my IoT Central app to show the GPS location using a map tile. My JSON file sends over the location and i have this tied to the map tile but the map tile keeps saying "Waiting for data" I have tried everything to get this to show and i can't seem to get it to work.
I have followed the JSON layout as shown here
You can see the raw data tab below which shows the data coming in and that it is associating the data with the gps capability but the map shows nothing.
enter image description here
I have just made a quick test and it looks like everything is working well:
New App with a custom device template
Creating a View
Exporting a device template for my tester (simulator):
{
"#id": "urn:custom6ec42lhnjx:gps38u:1",
"#type": "CapabilityModel",
"contents": [],
"displayName": {
"en": "gps"
},
"implements": [
{
"#type": "InterfaceInstance",
"displayName": {
"en": "Interface"
},
"name": "gpsea",
"schema": {
"#id": "urn:custom6ec42lhnjx:gpsea:1",
"#type": "Interface",
"contents": [
{
"#type": [
"Telemetry",
"SemanticType/Location"
],
"displayName": {
"en": "gps"
},
"name": "gps",
"schema": "geopoint"
},
{
"#type": [
"Telemetry",
"SemanticType/Temperature"
],
"displayName": {
"en": "temp"
},
"name": "temp",
"schema": "double"
}
],
"displayName": {
"en": "Interface"
}
}
}
],
"#context": [
"http://azureiot.com/v1/contexts/IoTModel.json"
]
}
Provisioning and Simulating device (with a random values):
Dashboard IoT Central App:
Example with simulating your telemetry data:
I finally got it working, unfortunately only by starting again and deleting everything i had done thus far, as soon as i recreated my IoTC app and reimplemented the function that deals with the webhook everything worked perfectly. Still strange as the data format and everything else remained unchanged. But thank you for your help.

Azure IoT Central - Enum value displaying blank value in Dashboard

We are using a telemetry property "Bulb status" with an enum as shown below
"#id": "urn:veeazigbeeappdemo:ZigbeeDeviceTemplate_12r3:on_off:1",
"#type": "Telemetry",
"displayName": {
"en": "Bulb Status"
},
"name": "on_off",
"schema": {
"#id": "urn:veeazigbeeappdemo:ZigbeeDeviceTemplate_12r3:on_off:hxdsbx1pp:1",
"#type": "Enum",
"displayName": {
"en": "Enum"
},
"valueSchema": "string",
"enumValues": [
{
"#id": "urn:veeazigbeeappdemo:ZigbeeDeviceTemplate_12r3:on_off:hxdsbx1pp:On:1",
"#type": "EnumValue",
"displayName": {
"en": "On"
},
"enumValue": "1",
"name": "On"
},
{
"#id": "urn:veeazigbeeappdemo:ZigbeeDeviceTemplate_12r3:on_off:hxdsbx1pp:Off:1",
"#type": "EnumValue",
"displayName": {
"en": "Off"
},
"enumValue": "0",
"name": "Off"
}
]
}
The tile is made to display "Last Known value" in Template
When we send a payload as follows
payload = '{"on_off": %s}' % (random.choice([0, 1]))
we are getting the Bulb status correctly displayed as follows
when we send a payload which doesn't have Bulb status(on_off) telemetry property in it as below
payload = '{"current_level": %f}' % random.randrange(10.0, 100.0)
we are getting the Bulb status being shown as blank as follows
Correct Behaviour:
The Bulb status should show last know value from on_off property and should not display as blank when we don't send that telemetry property.
This kind of behavior with enum is causing an issue for us. Please provide the solution to overcome this.
Please let me know Where can I post this as a bug of Enum in Azure IoT Central?
It looks like an enum type is handling a null value differently than the other types. It seems to me, the unmodeled data should be not modify a dashboard.
As a workaround, Can you change type to the SemanticType/State? The State History is working well:
The feedback to the IoT Central team is here.

Azure Advisor REST API Recommendation Extended Properties Do Not Populate?

I am pulling Recommendations from the Azure Advisor Rest Api and am not able to retrieve the extendedProperties values.
Specifically, I am looking for savings data from Recommendations of the Cost category.
In the following video at 58 seconds there is an example of the expected response.
https://www.youtube.com/watch?v=hAxrdmOAB8s
Are there specific permissions necessary to give my account in order to pull the data, or is the API not capable of supplying the values?
I am able to see the data in the portal, but the extendedProperties property is always empty.
I'm supposing you're trying the Recommendations - List API.
Essentially, extended properties expose additional information about a recommendation from Azure Advisor.
AFAIK, they need not be present for every recommendation, and shouldn't need additional privileges to list. It could just be the case that the type of recommendations you are receiving do not have any to list.
Here is a sample response that I received that has a mix of both:
[
{
"properties": {
"category": "Cost",
"impact": "Medium",
"impactedField": "Microsoft.Network/publicIPAddresses",
"impactedValue": "foo",
"lastUpdated": "2020-03-20T14:10:24.6928024Z",
"recommendationTypeId": "1b4dd958-c202-47af-af97-99bfc98376a5",
"shortDescription": {
"problem": "Delete Public IP address not associated to a running Azure resource",
"solution": "Delete Public IP address not associated to a running Azure resource"
},
"extendedProperties": {}
},
"id": "xxx",
"type": "Microsoft.Advisor/recommendations",
"name": "xxx"
},
{
"properties": {
"category": "Cost",
"impact": "Medium",
"impactedField": "Microsoft.Sql/servers/databases",
"impactedValue": "bar",
"lastUpdated": "2020-03-20T13:27:35.8394386Z",
"recommendationTypeId": "b83241d3-47ba-4603-8d5a-a1b3331e74f4",
"shortDescription": {
"problem": "Right-size underutilized SQL Databases",
"solution": "Right-size underutilized SQL Databases"
},
"extendedProperties": {
"ServerName": "fooserver",
"DatabaseName": "fooDB",
"IsInReplication": "1",
"ResourceGroup": "xyz",
"DatabaseSize": "6",
"Region": "East US 2",
"ObservationPeriodStartDate": "03/04/2020 00:00:00",
"ObservationPeriodEndDate": "03/19/2020 00:00:00",
"Recommended_DTU": "10",
"Recommended_SKU": "S0",
"HasRecommendation": "true"
}
}
}
]

Azure resource ID reported depending on consumed volumes

guys, couldn't find similar question, so asking here.
We have a client to Microsoft REST API, and we receive consumed usage normally for multiple subscriptions.
But there's a problematic point.
There are some resource types, which are billed depending on the consumed volume. Each of these has got it's own resource ID. For example for BLOB storage there're at least 3 different IDs depending on the consumed amount (which I suspect, should be billed differently).
The question is - am I right presuming, that when end user (our customer) will exceed amount of resources allocated for a particular usage resource ID, next report will contain different resource ID for the same, well, resource?
Here's the REST response i'm talking about:
{
"usageStartTime": "2017-06-07T17:00:00-07:00",
"usageEndTime": "2017-06-08T17:00:00-07:00",
"resource": {
"id": "**8767aeb3-6909-4db2-9927-3f51e9a9085e**", //I'm talking about this one
"name": "Storage Admin",
"category": "Storage",
"subcategory": "Block Blob",
"region": "Azure Stack"
},
"quantity": 0.217790327034891,
"unit": "1 GB/Hr",
"infoFields": {},
"instanceData": {
"resourceUri": "/subscriptions/ab7e2384-eeee-489a-a14f-1eb41ddd261d/resourcegroups/system.local/providers/Microsoft.Storage/storageaccounts/srphealthaccount",
"location": "azurestack",
"partNumber": "",
"orderNumber": "",
"additionalInfo": {
"azureStack.MeterId": "09F8879E-87E9-4305-A572-4B7BE209F857",
"azureStack.SubscriptionId": "dbd1aa30-e40d-4436-b465-3a8bc11df027",
"azureStack.Location": "local",
"azureStack.EventDateTime": "06/05/2017 06:00:00"
}
"attributes": {
"objectType": "AzureUtilizationRecord"
}
}

Resources