0

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

Matthias
  • 3
  • 1
  • But I think when you pass signal to your device due to multiple devices/instances signal confuses where to go because multiple devices with same id exist – Adam Strauss Dec 20 '19 at 05:36
  • Hi Adam, it is only one Device but as Roman explained, I misunderstood the Name field in the Device template. But thank you for your feedback ;) – Matthias Dec 22 '19 at 13:49

1 Answers1

0

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):

enter image description here

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:

enter image description here

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:

enter image description here

Get the device twin properties:

enter image description here

and the IoTC App Dashboard for Occupancy State property:

enter image description here

As you can see, the about state has a value Free.

Roman Kiss
  • 7,925
  • 1
  • 8
  • 21
  • Thank you Roman! I misunderstood the "Name" field in the Device template … I get the right result in the Dashboard now ;) Thanks for the link to the Azure IoT Hub Tester. – Matthias Dec 22 '19 at 13:53