project-chip / zap

ZAP stands for ZCL Advanced Platform. It is used to configure clusters, attributes and other entities for Matter and ZigbeePro applications.
Apache License 2.0
133 stars 82 forks source link

ZAP bombs out with unhelpful message if derived xml clusters (e.g. xyz-mode-cluster.xml is not in mode-base-cluster.xml) #1247

Open jamesharrow opened 8 months ago

jamesharrow commented 8 months ago

Follow the process to add new XML cluster definitions, but due to lack of documentation there was no clear instruction to add the into mode-base-cluster.xml

Running ./scripts/tools/zap_regen_all.py bombs out after 5 mins with this error:

Having more debug to explain what cluster is affected and what type is effected would give the developer a clue where the issue was. Instead I had to reverse engineer zap tool.

🤖 Generating files: ✍ /w/connectedhomeip/connectedhomeip/src/controller/python/chip/clusters/Objects.py ⚠️ Errors: 👎 /w/connectedhomeip/connectedhomeip/src/controller/python/chip/clusters/CHIPClusters.py: ⛔ TypeError: Cannot read properties of undefined (reading 'discriminatorName') Stack trace:

TypeError: Cannot read properties of undefined (reading 'discriminatorName') at Object.as_underlying_python_zcl_type (/snapshot/zap/dist/src-electron/generator/matter/controller/python/templates/helper.js:76:23) at async Promise.all (index 0) at async Promise.all (index 0) at async Promise.all (index 1) at async Promise.all (index 70) at async Promise.all (index 0) at produceContent (/snapshot/zap/dist/src-electron/generator/template-engine.js:150:19) at generateSingleTemplate (/snapshot/zap/dist/src-electron/generator/generation-engine.js:522:27) at async Promise.all (index 1) at generateAllTemplates (/snapshot/zap/dist/src-electron/generator/generation-engine.js:499:5) 🕐 Generation time: 6s 905ms {"src/controller/python/chip/clusters/CHIPClusters.py":{}} Zap generation error: Error: Generation failed: -- blank session -- Error: Generation failed: -- blank session -- at generateSingleFile (/snapshot/zap/dist/src-electron/main-process/startup.js:490:15) at startGeneration (/snapshot/zap/dist/src-electron/main-process/startup.js:543:5)

Propose adding something like:

   if (!dataType)
   {
     throw new Error(`dataType is undefined for clusterId: ${clusterId} ${type} ${packageIds}`);
   }

into https://github.com/project-chip/zap/blob/9c4b5244168a512112d98c5807285a7dbc8b5f3d/src-electron/generator/matter/controller/python/templates/helper.js#L82

Example of the state my draft PR was in when it failed is here: https://github.com/project-chip/connectedhomeip/actions/runs/7568704069/job/20610437501?pr=31506#step:7:1602

To resolve my issue I had to add the EVSE and DEM mode cluster IDs into the mode-base-cluster.xml:

  <struct name="ModeOptionStruct">
    <cluster code="0x0051"/> <!-- Laundry Washer Mode -->
    <cluster code="0x0052"/> <!-- Refrigerator and temperature controlled cabinet Mode -->
    <cluster code="0x0054"/> <!-- RVC Run Mode -->
    <cluster code="0x0055"/> <!-- RVC Clean Mode -->
    <cluster code="0x0059"/> <!-- Dishwasher Mode -->
    <cluster code="0x005E"/> <!-- Microwave Oven Mode -->
    <cluster code="0x0049"/> <!-- Oven Mode -->
    <cluster code="0x009D"/> <!-- Energy EVSE Mode -->
    <cluster code="0x009F"/> <!-- Device Energy Management Mode -->
    <item name="Label"    type="char_string"                length="64" optional="false"/>
    <item name="Mode"     type="int8u"                                  optional="false"/>
    <item name="ModeTags" type="ModeTagStruct" array="true" length="8"  optional="false"/>
  </struct>
paulr34 commented 8 months ago

We will try and add more helpful messages, thanks for the feedback