RealEstateCore / rec

RealEstateCore ontologies.
http://realestatecore.io
BSD 3-Clause "New" or "Revised" License
84 stars 37 forks source link

Missing Enum Array in Model dtmi:org:brickschema:schema:Brick:PV_Panel;1 #245

Closed WesVerhagen closed 1 year ago

WesVerhagen commented 1 year ago

Issue Description: I encountered an issue with the model dtmi:org:brickschema:schema:Brick:PV_Panel;1 while using it in my project. The problem seems to be related to the definition of the enum values, which are currently represented without an array syntax.

Error Message: Screenshot 2023-07-28 115605

Current Enum Definition:

"enumValues": {
    "enumValue": "PERCENT",
    "name": "PERCENT"
}

Proposed Enum Definition (with Array Syntax):

"enumValues": [{
    "enumValue": "PERCENT",
    "name": "PERCENT"
}]

So the complete code would be:

{
 "@id": "dtmi:org:brickschema:schema:Brick:PV_Panel;1",
 "@type": "Interface",
 "contents": [
  {
   "@type": "Property",
   "displayName": {
    "en": "Measured module conversion efficiency"
   },
   "name": "measuredModuleConversionEfficiency",
   "schema": {
    "@type": "Object",
    "fields": [
     {
      "name": "value",
      "schema": "string"
     },
     {
      "name": "hasUnit",
      "schema": {
       "@type": "Enum",
       "enumValues": [{
        "enumValue": "PERCENT",
        "name": "PERCENT"
       }],
       "valueSchema": "string"
      }
     }
    ]
   },
   "writable": true
  },
  {
   "@type": "Property",
   "displayName": {
    "en": "Rated module conversion efficiency"
   },
   "name": "ratedModuleConversionEfficiency",
   "schema": {
    "@type": "Object",
    "fields": [
     {
      "name": "value",
      "schema": "string"
     },
     {
      "name": "hasUnit",
      "schema": {
       "@type": "Enum",
       "enumValues": [{
        "enumValue": "PERCENT",
        "name": "PERCENT"
       }],
       "valueSchema": "string"
      }
     }
    ]
   },
   "writable": true
  }
 ],
 "description": {
  "en": "An integrated assembly of interconnected photovoltaic cells designed to deliver a selected level of working voltage and current at its output terminals packaged for protection against environment degradation and suited for incorporation in photovoltaic power systems."
 },
 "displayName": {
  "en": "PV Panel"
 },
 "extends": "dtmi:org:brickschema:schema:Brick:Equipment;1",
 "@context": [
  "dtmi:dtdl:context;2"
 ]
}

Alternative Suggestion: As the model dtmi:org:brickschema:schema:Brick:PV_Panel;1 only contains one enum value, it might be more straightforward to remove the enum and object and instead use a semantic type.

Proposed Code with Semantic Type:

{
 "@id": "dtmi:org:brickschema:schema:Brick:PV_Panel;1",
 "@type": "Interface",
 "contents": [
  {
   "@type": ["Property", "Efficiency"],
   "displayName": {
    "en": "Measured module conversion efficiency"
   },
   "name": "measuredModuleConversionEfficiency",
   "schema": "integer",
   "unit": "Percent",
   "writable": true
  },
  {
    "@type": ["Property", "Efficiency"],
    "displayName": {
     "en": "Rated module conversion efficiency"
    },
    "name": "ratedModuleConversionEfficiency",
    "schema": "integer",
    "unit": "Percent",
    "writable": true
   }
 ],
 "description": {
  "en": "An integrated assembly of interconnected photovoltaic cells designed to deliver a selected level of working voltage and current at its output terminals packaged for protection against environment degradation and suited for incorporation in photovoltaic power systems."
 },
 "displayName": {
  "en": "PV Panel"
 },
 "extends": "dtmi:org:brickschema:schema:Brick:Equipment;1",
 "@context": [
  "dtmi:dtdl:context;2"
 ]
}

Steps to Reproduce: To reproduce the issue, use the current version of the model dtmi:org:brickschema:schema:Brick:PV_Panel;1 and attempt to access the enum values via the UI in Azure Digital Twin.

Expected Behavior: After the proposed fix (using array syntax for enum values or utilizing semantic types), the model dtmi:org:brickschema:schema:Brick:PV_Panel;1 should work as intended without any errors.

Thank you for your attention to this matter, and I hope we can improve the model for better usability and compatibility.

Please let me know if there is any further information needed or if you have any questions.

WesVerhagen commented 1 year ago

i have created pr #246

WesVerhagen commented 1 year ago

I owe you an apology! It turns out I was using an older version and had no idea the issue was already fixed. How on earth did I miss that?

I feel really silly about it, and I'm sorry for any confusion I might have caused. But hey, at least the problem is sorted out, right?

I promise to be more vigilant in the future and keep myself up-to-date. Thanks for bringing this to my attention.

If there's anything else you need or any questions you have, feel free to hit me up.

Thanks for your understanding!