-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve handling of Door/Window state #23
Comments
Here's a mock config file to test. This automatically sends random door state notifications every 5 seconds: // @ts-check
const { NotificationCCReport } = require("@zwave-js/cc/NotificationCC");
const { CommandClasses } = require("@zwave-js/core");
const { ccCaps, createMockZWaveRequestFrame } = require("@zwave-js/testing");
let simulationTimer;
process.on("SIGINT", () => {
if (simulationTimer) clearInterval(simulationTimer);
});
/** @type {import("zwave-js/Testing").MockServerOptions["config"]} */
module.exports.default = {
nodes: [
{
id: 2,
capabilities: {
commandClasses: [
CommandClasses.Version,
ccCaps({
ccId: CommandClasses.Notification,
isSupported: true,
version: 11,
notificationTypesAndEvents: {
// Access Control - Door state
[0x06]: [0x16, 0x17],
},
}),
],
},
behaviors: [
{
// Small hack - start the state simulation timer when the node
// receives a command from the controller
async handleCC(controller, self, _frame) {
if (!simulationTimer) {
// Then send notifications regularly
simulationTimer = setInterval(() => {
// 75% of reports are open, 25% are closed
const isOpen = Math.random() < 0.75;
// 50% of reports include the tilt parameter
const supportsTilt = Math.random() < 0.5;
// 50% of those are tilted, 50% are not
const isTilted = Math.random() < 0.5;
const cc = new NotificationCCReport(self.host, {
nodeId: controller.host.ownNodeId,
notificationType: 0x06, // Access Control
notificationEvent: isOpen ? 0x16 : 0x17,
eventParameters: isOpen && supportsTilt
? Buffer.from([
isTilted ? 0x01 : 0x00,
])
: undefined,
});
self.sendToController(
createMockZWaveRequestFrame(cc, {
ackRequested: false,
}),
);
// Tune this value according to how often you want to get notifications
}, 5000).unref();
}
return undefined;
},
},
],
},
],
}; |
Its not possible to detect if the device support tilt so pre-creating an additional binary sensor for this will cause confusion. |
This results in two identical-named entities with different states: zwave_js-01J2ZVFHVQG8V8J9D9360S4VCQ-Node 2-5bce3bf4e843614bfa12a4fa32c6243b.json.txt |
|
Z-Wave JS exposes two semi-duplicate values for the Door/Window state notification value:
Unfortunately it is impossible to detect whether a device supports the "open in ... position" states, or just supports the CC version that includes them. As a result, the 4-state sensor is exposed as 3 or 4 binary sensor in HA, in addition to the 2-state sensor which adds another binary sensor.
This should be simplified into two binary sensors: open / close and tilted / not tilted.
The text was updated successfully, but these errors were encountered: