Skip to content

Commit

Permalink
fix: do not expose Basic CC current value if Set is mapped to another CC
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone committed Jul 8, 2024
1 parent a14af6a commit 92589dc
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/cc/src/cc/BasicCC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ remaining duration: ${basicResponse.duration?.toString() ?? "undefined"}`;
ret.push(BasicCCValues.compatEvent.endpoint(endpoint.index));
} else if (
!endpoint.supportsCC(CommandClasses.Basic) && (
endpoint.controlsCC(CommandClasses.Basic)
(endpoint.controlsCC(CommandClasses.Basic)
&& compat?.mapBasicSet !== "Binary Sensor")
|| compat?.mapBasicReport === false
|| compat?.mapBasicSet === "report"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { BasicCCValues } from "@zwave-js/cc";
import { CommandClasses } from "@zwave-js/core";
import path from "node:path";
import { integrationTest } from "../integrationTestSuite";

integrationTest(
Expand Down Expand Up @@ -44,3 +45,60 @@ integrationTest(
},
},
);

integrationTest(
"On devices that MUST not support Basic CC, and map Basic Set to a different CC, NO Basic CC values should be exposed",
{
// debug: true,

nodeCapabilities: {
manufacturerId: 0xdead,
productType: 0xbeef,
productId: 0xcafe,

// Routing Multilevel Sensor, MUST not support Basic CC
genericDeviceClass: 0x21,
specificDeviceClass: 0x01,
commandClasses: [
CommandClasses["Manufacturer Specific"],
CommandClasses.Version,
// But it reports support if asked
CommandClasses.Basic,
],
},

additionalDriverOptions: {
storage: {
deviceConfigPriorityDir: path.join(
__dirname,
"fixtures/mapBasicSetBinarySensor",
),
},
},

async testBody(t, driver, node, mockController, mockNode) {
const valueIDs = node.getDefinedValueIDs();
t.false(
valueIDs.some((v) => BasicCCValues.currentValue.is(v)),
"Found Basic CC currentValue although it shouldn't be exposed",
);
t.false(
valueIDs.some((v) => BasicCCValues.targetValue.is(v)),
"Found Basic CC targetValue although it shouldn't be exposed",
);
t.false(
valueIDs.some((v) => BasicCCValues.duration.is(v)),
"Found Basic CC duration although it shouldn't be exposed",
);
t.false(
valueIDs.some((v) => BasicCCValues.restorePrevious.is(v)),
"Found Basic CC restorePrevious although it shouldn't be exposed",
);

t.false(
valueIDs.some((v) => BasicCCValues.compatEvent.is(v)),
"Found Basic CC compatEvent although it shouldn't be exposed",
);
},
},
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"manufacturer": "Test Manufacturer",
"manufacturerId": "0xdead",
"label": "Test Device",
"description": "With Basic Event",
"devices": [
{
"productType": "0xbeef",
"productId": "0xcafe"
}
],
"firmwareVersion": {
"min": "0.0",
"max": "255.255"
},
"compat": {
"mapBasicSet": "Binary Sensor"
}
}

0 comments on commit 92589dc

Please sign in to comment.