diff --git a/.github/workflows/hacs-distribution.yml b/.github/workflows/hacs-distribution.yml index 4dd595b..0c60621 100644 --- a/.github/workflows/hacs-distribution.yml +++ b/.github/workflows/hacs-distribution.yml @@ -348,7 +348,7 @@ jobs: run: node tools/extract-changelog.js "$VERSION" > source-release-notes.md - name: Create source-repo GitHub Release - uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3 + uses: softprops/action-gh-release@8a0cd651e5b2365bd640854a3fa5dfc70e4875f3 # v3.0.4 with: tag_name: v${{ steps.version.outputs.version }} name: v${{ steps.version.outputs.version }} @@ -421,7 +421,7 @@ jobs: fi - name: Create distribution-repo GitHub Release - uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3 + uses: softprops/action-gh-release@8a0cd651e5b2365bd640854a3fa5dfc70e4875f3 # v3.0.4 with: repository: ${{ env.DISTRIBUTION_REPO }} token: ${{ secrets.HACS_DEPLOY_TOKEN }} diff --git a/docs/KEYPAD_PRESS_INVESTIGATION.md b/docs/KEYPAD_PRESS_INVESTIGATION.md new file mode 100644 index 0000000..e68492c --- /dev/null +++ b/docs/KEYPAD_PRESS_INVESTIGATION.md @@ -0,0 +1,89 @@ +# Keypad Press Types (short, long, double) — Investigation Notes + +Where cgateweb stands on telling a short, long or double press of a C-Bus keypad key apart, what +is still unknown, and how to capture the data needed to decide. Tracks +[issue #172](https://github.com/dougrathbone/cgateweb/issues/172). + +> **Status legend:** ✅ verified against real hardware · ⚠️ expected from how C-Bus keys are +> programmed, not yet observed through C-Gate · ❓ unknown / not captured. + +## Current state + +A key press reaches Home Assistant as whatever the key is programmed to send. Nothing infers a +press type. + +- **Trigger Control keys (app 202)** ✅: each action selector the bus reports fires the trigger + group's `event` entity with `{"event_type":"trigger","level":N}`, and the sending unit is + published to `cbus/read/{net}/202/{group}/source_unit`. Keypad `trigger min|max` lines are + decoded as selectors 0 and 255. +- **Lighting keys (app 56)** ✅: the group's state and level change like any other lighting group. + There is no event for the press itself. +- **Raw capture** ✅: set `cbus_raw_event_log_apps` to the keypad's applications and every line + for them is logged with a millisecond timestamp and republished to + `cbus/read/{net}/{app}/{group}/raw`. Since this investigation started, comment-prefixed lines + (`# lighting on …`, `# trigger event …`) are captured too; before, they were dropped unseen. + +## Why press type is not on the bus + +C-Bus has no "long press" message. A key sends the commands its programming in C-Bus Toolkit gives +it, so a press type can only be inferred from which commands arrive and how far apart. What each +key mode is expected to send (⚠️ — none of this has been captured through C-Gate yet): + +| Key mode | Expected traffic | Press type recoverable from | +|---|---|---| +| Bell press | `on` at press, `off` at release | Time between the two | +| Dimmer | Short press: `on`/`off`. Hold: `ramp`, then `terminateramp` at release | Which commands arrive | +| Toggle / on / off | One `on` or `off` per press | Nothing: a hold looks like a press | +| Trigger | One action selector per press | Nothing, unless the key sends a different selector on hold | + +Double press is two short presses close together under any mode, so it can only be recognised by +waiting to see whether a second press follows. Waiting delays every single press by that window. + +## What we do not know (❓) + +1. **Whether press and release both appear on the event port**, and in which form (`lighting on`, + `# lighting on`, `#e# …`), for bell press and dimmer keys. +2. **Whether `ramp` and `terminateramp` from a held dimmer key appear at all.** C-Gate may report + only the resulting level change. +3. **Timing jitter through C-Gate.** Timestamps are taken when the bridge receives a line, not when + the key was pressed. If C-Gate batches lines, short and long presses could blur together. +4. **Whether `#sourceunit` is on every line**, which is needed to tell two keypads driving the same + group apart. +5. **What thresholds real presses fall into**: how long a deliberate hold is, and how close two + presses of a double press land. + +## Why not guess + +A wrong press type fires the wrong automation, which is worse than firing none: the user presses +"scene off" and gets "scene on". The HVAC and audio work set the rule that a decoder ships only +once real captures confirm what it reads (see [AUDIO_INVESTIGATION.md](./AUDIO_INVESTIGATION.md)). + +## Home Assistant mapping + +The MQTT `event` platform supports this directly: a per-key `event` entity with `event_types` such +as `press`, `long_press` and `double_press`, which HA automations can trigger on. If it ships, it +would be opt-in per group and leave the existing light, switch and trigger entities unchanged, so +installs that never configure it see no difference. + +## How to capture (for testers) + +1. Set `cbus_raw_event_log_apps` to the applications your keys use, usually `[56, 202]`. + App 56 captures all lighting traffic, so do this when the house is quiet. +2. Restart the bridge. For each key you want to test, note its unit address and key mode + (bell press, dimmer, toggle, trigger) from C-Bus Toolkit, then: + - press it once, briefly + - press and hold it for about two seconds + - press it twice quickly + - wait a few seconds between each so the groups of lines are easy to tell apart +3. Write down what you did and when, next to the lines it produced. +4. Collect the `C-Gate raw capture [app N]` lines from the add-on log. Use the log rather than the + MQTT topic: the log keeps the timestamp, which is the measurement. + +## Plan + +1. **Capture** (now): every line a keypad produces is capturable. +2. **Measure** from real captures which key modes carry a recoverable press type, and the timing + thresholds that separate them. +3. **Decide** whether the result is reliable enough to ship, and for which key modes. +4. **Publish** an opt-in `event` entity per configured key, with fixtures taken verbatim from the + captures. diff --git a/docs/SETTINGS.md b/docs/SETTINGS.md index baa012c..d734ded 100644 --- a/docs/SETTINGS.md +++ b/docs/SETTINGS.md @@ -390,7 +390,7 @@ The add-on does this for you: its service script exports `LOG_LEVEL` from the `l | Setting | Add-on option | Type | Default | Notes | |---|---|---|---|---| -| `cbusRawEventLogApps` | `cbus_raw_event_log_apps` | number[] | `[]` | Applications whose raw C-Gate event lines are logged verbatim and republished to `cbus/read/{net}/{app}/{group}/raw` (`cbus/read/{net}/{app}/raw` for applications with no group address: Audio 205, Media Transport 192, Clock 223). For capturing ground-truth protocol samples before writing a decoder (e.g. `[172]`, or `[205, 192]` for audio). Empty disables. Leave empty in normal operation — it is noisy. | +| `cbusRawEventLogApps` | `cbus_raw_event_log_apps` | number[] | `[]` | Applications whose raw C-Gate event lines are logged verbatim and republished to `cbus/read/{net}/{app}/{group}/raw` (`cbus/read/{net}/{app}/raw` for applications with no group address: Audio 205, Media Transport 192, Clock 223). For capturing ground-truth protocol samples before writing a decoder (e.g. `[172]`, `[205, 192]` for audio, or `[56, 202]` for keypad presses; see [KEYPAD_PRESS_INVESTIGATION.md](./KEYPAD_PRESS_INVESTIGATION.md)). Comment-prefixed lines (`# lighting on …`) for a listed application are captured too. Empty disables. Leave empty in normal operation — it is noisy. | --- diff --git a/package-lock.json b/package-lock.json index c21ea4d..315424c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,12 +11,12 @@ "dependencies": { "adm-zip": "^0.6.1", "mqtt": "^5.16.1", - "sql.js": "^1.16.0", + "sql.js": "^1.17.0", "xml2js": "^0.6.2" }, "devDependencies": { "@eslint/js": "^10.0.1", - "@types/node": "^26.6.6", + "@types/node": "^26.6.10", "eslint": "^10.15.0", "globals": "^17.14.0", "jest": "^30.5.2", @@ -648,23 +648,6 @@ "node": "^20.19.0 || ^22.13.0 || >=24" } }, - "node_modules/@eslint/config-array/node_modules/minimatch": { - "version": "11.0.9", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-11.0.9.tgz", - "integrity": "sha512-KCFkfyjqerNlSstjlhIGNXIKZGA/6O4V4RlhZ+Dsr621SPPw0mzlypE9D9ZOoPiVefHID+j7/XuMMlqfD/F60Q==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "@isaacs/nonrecursive-glob-match": "^1.1.0", - "brace-expansion": "^5.0.12" - }, - "engines": { - "node": "20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/@eslint/config-helpers": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.7.0.tgz", @@ -802,109 +785,6 @@ "url": "https://github.com/sponsors/nzakas" } }, - "node_modules/@isaacs/cliui": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", - "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", - "dev": true, - "license": "ISC", - "dependencies": { - "string-width": "^5.1.2", - "string-width-cjs": "npm:string-width@^4.2.0", - "strip-ansi": "^7.0.1", - "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", - "wrap-ansi": "^8.1.0", - "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/@isaacs/cliui/node_modules/ansi-regex": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.3.0.tgz", - "integrity": "sha512-WpDfL7NO6j7tH88IDBNVdUJxDh9nmCteAVW9dsep846XdwF4naCBK+/tGLX3KJgcpgMRXCFlTM2hKGoK9FsdrQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-regex?sponsor=1" - } - }, - "node_modules/@isaacs/cliui/node_modules/ansi-styles": { - "version": "6.2.3", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz", - "integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/@isaacs/cliui/node_modules/emoji-regex": { - "version": "9.2.2", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", - "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", - "dev": true, - "license": "MIT" - }, - "node_modules/@isaacs/cliui/node_modules/string-width": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", - "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", - "dev": true, - "license": "MIT", - "dependencies": { - "eastasianwidth": "^0.2.0", - "emoji-regex": "^9.2.2", - "strip-ansi": "^7.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@isaacs/cliui/node_modules/strip-ansi": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz", - "integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-regex": "^6.2.2" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/strip-ansi?sponsor=1" - } - }, - "node_modules/@isaacs/cliui/node_modules/wrap-ansi": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", - "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-styles": "^6.1.0", - "string-width": "^5.0.1", - "strip-ansi": "^7.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, "node_modules/@isaacs/nonrecursive-glob-match": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@isaacs/nonrecursive-glob-match/-/nonrecursive-glob-match-1.1.0.tgz", @@ -1576,9 +1456,6 @@ "arm" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1600,9 +1477,6 @@ "arm" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1624,9 +1498,6 @@ "arm64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1648,9 +1519,6 @@ "arm64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1672,9 +1540,6 @@ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1696,9 +1561,6 @@ "x64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1754,17 +1616,6 @@ "url": "https://opencollective.com/parcel" } }, - "node_modules/@pkgjs/parseargs": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", - "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", - "dev": true, - "license": "MIT", - "optional": true, - "engines": { - "node": ">=14" - } - }, "node_modules/@pkgr/core": { "version": "0.3.6", "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.3.6.tgz", @@ -1910,9 +1761,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "26.6.6", - "resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.6.tgz", - "integrity": "sha512-MzQj+8Kx3XI40OmUAE6Qoh58ZMNstNNMwn2nfd3qWsfe7nDNSqJNzes4njhz6AHwrSHOffSLwXU6yb474Q4aog==", + "version": "26.6.10", + "resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.10.tgz", + "integrity": "sha512-WJuPHoGB8WNQuTksNF7SOQpnH02PXeDYz4iueWbBT6/hTWnShY5F3T/hoJA3fY9+uYReDZ7pyTKKx83jQa7aGg==", "license": "MIT", "dependencies": { "undici-types": "~8.9.0" @@ -2413,9 +2264,6 @@ "arm64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2430,9 +2278,6 @@ "arm64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -2447,9 +2292,6 @@ "loong64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2464,9 +2306,6 @@ "loong64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -2481,9 +2320,6 @@ "ppc64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2498,9 +2334,6 @@ "riscv64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2515,9 +2348,6 @@ "riscv64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -2532,9 +2362,6 @@ "s390x" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2549,9 +2376,6 @@ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2566,9 +2390,6 @@ "x64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -3251,9 +3072,9 @@ "license": "MIT" }, "node_modules/cross-spawn": { - "version": "7.0.6", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", - "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.1.2.tgz", + "integrity": "sha512-8BPK2r+sKWC8sDinRwLwrFMq2lXTBBwzYYEB9LiCznfMurOi4FOvQflq3XOLGG+HPdMSVpe+k/s96+AtDEOgPg==", "dev": true, "license": "MIT", "dependencies": { @@ -3334,13 +3155,6 @@ "node": ">=8" } }, - "node_modules/eastasianwidth": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", - "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", - "dev": true, - "license": "MIT" - }, "node_modules/electron-to-chromium": { "version": "1.5.439", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.439.tgz", @@ -3499,23 +3313,6 @@ "url": "https://opencollective.com/eslint" } }, - "node_modules/eslint/node_modules/minimatch": { - "version": "11.0.9", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-11.0.9.tgz", - "integrity": "sha512-KCFkfyjqerNlSstjlhIGNXIKZGA/6O4V4RlhZ+Dsr621SPPw0mzlypE9D9ZOoPiVefHID+j7/XuMMlqfD/F60Q==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "@isaacs/nonrecursive-glob-match": "^1.1.0", - "brace-expansion": "^5.0.12" - }, - "engines": { - "node": "20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/espree": { "version": "11.2.0", "resolved": "https://registry.npmjs.org/espree/-/espree-11.2.0.tgz", @@ -3758,36 +3555,6 @@ "dev": true, "license": "ISC" }, - "node_modules/foreground-child": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz", - "integrity": "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==", - "dev": true, - "license": "ISC", - "dependencies": { - "cross-spawn": "^7.0.6", - "signal-exit": "^4.0.1" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/foreground-child/node_modules/signal-exit": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", - "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/gensync": { "version": "1.0.0-beta.2", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", @@ -3832,15 +3599,15 @@ } }, "node_modules/glob": { - "version": "13.0.6", - "resolved": "https://registry.npmjs.org/glob/-/glob-13.0.6.tgz", - "integrity": "sha512-Wjlyrolmm8uDpm/ogGyXZXb1Z+Ca2B8NbJwqBVg0axK9GbBeoS7yGV6vjXnYdGm6X53iehEuxxbyiKp8QmN4Vw==", + "version": "14.0.7", + "resolved": "https://registry.npmjs.org/glob/-/glob-14.0.7.tgz", + "integrity": "sha512-ob8P0VbyEjcLG2ycNYmzYhZj65kkcN5b7tt5moGhTq3rkXtuU8MB+i0GIzPtLnSHVF2DkK4M+nQRojDvsOGVJw==", "dev": true, "license": "BlueOak-1.0.0", "dependencies": { - "minimatch": "^10.2.2", + "minimatch": "^11.0.5", "minipass": "^7.1.3", - "path-scurry": "^2.0.2" + "path-scurry": "^3.0.0" }, "engines": { "node": "18 || 20 || >=22" @@ -4164,22 +3931,6 @@ "node": ">=8" } }, - "node_modules/jackspeak": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", - "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "@isaacs/cliui": "^8.0.2" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - }, - "optionalDependencies": { - "@pkgjs/parseargs": "^0.11.0" - } - }, "node_modules/jest": { "version": "30.5.2", "resolved": "https://registry.npmjs.org/jest/-/jest-30.5.2.tgz", @@ -4946,16 +4697,17 @@ } }, "node_modules/minimatch": { - "version": "10.2.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz", - "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==", + "version": "11.0.10", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-11.0.10.tgz", + "integrity": "sha512-L3/cjhQ5E6lft0VCp/2mO3Ic74RnutKy3rz7iGwp/6w1hKcO262g2rbfacFyw6eBig5OdI0nu5PpuA0/WQs9Tw==", "dev": true, "license": "BlueOak-1.0.0", "dependencies": { - "brace-expansion": "^5.0.8" + "@isaacs/nonrecursive-glob-match": "^1.1.0", + "brace-expansion": "^5.0.12" }, "engines": { - "node": "18 || 20 || >=22" + "node": "20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -5180,13 +4932,6 @@ "node": ">=6" } }, - "node_modules/package-json-from-dist": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", - "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", - "dev": true, - "license": "BlueOak-1.0.0" - }, "node_modules/parse-json": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", @@ -5227,9 +4972,9 @@ } }, "node_modules/path-scurry": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.2.tgz", - "integrity": "sha512-3O/iVVsJAPsOnpwWIeD+d6z/7PmqApyQePUtCndjatj/9I5LylHvt5qluFaBT3I5h3r1ejfR056c+FCv+NnNXg==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-3.0.3.tgz", + "integrity": "sha512-Ie3c3F+7WJOUCr0r8V8uEunY5Sj4PGFDoBZvFw7JmHJs/+H5GZK+GsIM8tHMcZy7c27Zj+U1NOcVzqlC7tBJpg==", "dev": true, "license": "BlueOak-1.0.0", "dependencies": { @@ -5244,9 +4989,9 @@ } }, "node_modules/path-scurry/node_modules/lru-cache": { - "version": "11.5.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz", - "integrity": "sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==", + "version": "11.5.4", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.4.tgz", + "integrity": "sha512-B8nJCTi8JuSaDBg0tBdnImV6j5O2CXaqKfdj24ZTCFbyivN8KZ2Z+RL3aHjwJAfLutD9cNnObG4SIgW4gMufiw==", "dev": true, "license": "BlueOak-1.0.0", "engines": { @@ -5621,9 +5366,9 @@ } }, "node_modules/sql.js": { - "version": "1.16.0", - "resolved": "https://registry.npmjs.org/sql.js/-/sql.js-1.16.0.tgz", - "integrity": "sha512-q/JOZuJfmVh8Zf8Eo+cMJvtxAWeWBqTfJ6AQYGXZmcaLGHMwhA2niH3fQYHrBtPeOss1ttzHec07K5+rHaMRMw==", + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/sql.js/-/sql.js-1.17.0.tgz", + "integrity": "sha512-HNdo5+2eSTEm7iLcfXUd2mjZX3Oe+5mJ0uDgIpirS7gSLHhZIw9kWDWxNcDVeFGEIBxJlkgo525g0CZJoH8GgA==", "license": "MIT" }, "node_modules/stack-utils": { @@ -5687,22 +5432,6 @@ "node": ">=8" } }, - "node_modules/string-width-cjs": { - "name": "string-width", - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "license": "MIT", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", @@ -5716,20 +5445,6 @@ "node": ">=8" } }, - "node_modules/strip-ansi-cjs": { - "name": "strip-ansi", - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/strip-bom": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", @@ -5807,85 +5522,6 @@ "node": ">=18" } }, - "node_modules/test-exclude/node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true, - "license": "MIT" - }, - "node_modules/test-exclude/node_modules/brace-expansion": { - "version": "2.1.7", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.7.tgz", - "integrity": "sha512-uZbew1NqdmPDTMJ8ah1y+b+9QEJrfkXFk3RcTQw3X0jW/xRUvFKsg1CfQdSYGdTbXZWExtU3J3ccxtnfw1Fi0g==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "node_modules/test-exclude/node_modules/glob": { - "version": "10.5.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.5.0.tgz", - "integrity": "sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==", - "deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me", - "dev": true, - "license": "ISC", - "dependencies": { - "foreground-child": "^3.1.0", - "jackspeak": "^3.1.2", - "minimatch": "^9.0.4", - "minipass": "^7.1.2", - "package-json-from-dist": "^1.0.0", - "path-scurry": "^1.11.1" - }, - "bin": { - "glob": "dist/esm/bin.mjs" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/test-exclude/node_modules/glob/node_modules/minimatch": { - "version": "9.0.9", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.9.tgz", - "integrity": "sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^2.0.2" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/test-exclude/node_modules/lru-cache": { - "version": "10.4.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", - "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", - "dev": true, - "license": "ISC" - }, - "node_modules/test-exclude/node_modules/path-scurry": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", - "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "lru-cache": "^10.2.0", - "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" - }, - "engines": { - "node": ">=16 || 14 >=14.18" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/tslib": { "version": "2.8.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", @@ -6166,25 +5802,6 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, - "node_modules/wrap-ansi-cjs": { - "name": "wrap-ansi", - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, "node_modules/write-file-atomic": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-5.0.1.tgz", @@ -6213,9 +5830,9 @@ } }, "node_modules/ws": { - "version": "8.21.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.21.0.tgz", - "integrity": "sha512-Vsp28b7DRcimFQvrqu2Wek3z1iYxDCWqHYB8Qsnk/S4RfaCQzPGPyBNuVjJV3cd6UiKtUtp6sNM77gWvzcCH+g==", + "version": "8.23.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.23.1.tgz", + "integrity": "sha512-1rzWDSN0NOi3tpwgHsQExjWRoKUGtjCkJ2gZRaaRtzhYLboMytOI9pj9PU7yCgY37auqdd4OyLofZDbkeuZmPA==", "license": "MIT", "engines": { "node": ">=10.0.0" diff --git a/package.json b/package.json index 4cc128a..a4600df 100644 --- a/package.json +++ b/package.json @@ -32,12 +32,12 @@ "dependencies": { "adm-zip": "^0.6.1", "mqtt": "^5.16.1", - "sql.js": "^1.16.0", + "sql.js": "^1.17.0", "xml2js": "^0.6.2" }, "devDependencies": { "@eslint/js": "^10.0.1", - "@types/node": "^26.6.6", + "@types/node": "^26.6.10", "eslint": "^10.15.0", "globals": "^17.14.0", "jest": "^30.5.2", @@ -48,7 +48,9 @@ "overrides": { "js-yaml": "5.5.0", "browserslist": "4.28.8", - "@humanfs/node": "0.16.8" + "@humanfs/node": "0.16.8", + "minimatch": "11.0.10", + "glob": "14.0.7" }, "scripts": { "start": "node index.js", diff --git a/src/cgateWebBridge.js b/src/cgateWebBridge.js index a1fa050..35321de 100644 --- a/src/cgateWebBridge.js +++ b/src/cgateWebBridge.js @@ -640,6 +640,9 @@ class CgateWebBridge { if (appLine.consumed) return; if (line.startsWith('#')) { + // Status-change-port traffic arrives as commands or comments, so a + // comment can still be a keypad press on a captured application. + this._publishRawEventCapture(line); this.logger.debug(`Ignoring comment from event port: ${redactCgateLine(line)}`); return; } diff --git a/tests/cgateWebBridge.test.js b/tests/cgateWebBridge.test.js index 5879fda..3df788d 100644 --- a/tests/cgateWebBridge.test.js +++ b/tests/cgateWebBridge.test.js @@ -1105,6 +1105,42 @@ describe('CgateWebBridge', () => { publishEventSpy.mockRestore(); }); + it('captures a comment-prefixed line for a configured application', () => { + bridge.settings.cbusRawEventLogApps = [56, 202]; + const publishEventSpy = jest.spyOn(bridge.eventPublisher, 'publishEvent'); + const line = '# lighting on //TestProject/254/56/7 #sourceunit=12 OID=abc'; + + bridge._processEventLine(line); + + expect(publishSpy).toHaveBeenCalledWith('cbus/read/254/56/7/raw', line, expect.anything()); + expect(publishEventSpy).not.toHaveBeenCalled(); + publishEventSpy.mockRestore(); + }); + + it('captures a comment-prefixed numeric trigger event once, without publishing it', () => { + bridge.settings.cbusRawEventLogApps = [202]; + const publishEventSpy = jest.spyOn(bridge.eventPublisher, 'publishEvent'); + + bridge._processEventLine('# trigger event //TestProject/254/202/9 2'); + + const rawPublishes = publishSpy.mock.calls.filter((call) => call[0] === 'cbus/read/254/202/9/raw'); + expect(rawPublishes).toHaveLength(1); + expect(publishEventSpy).not.toHaveBeenCalled(); + publishEventSpy.mockRestore(); + }); + + it('does not capture comment lines for applications that are not configured', () => { + bridge.settings.cbusRawEventLogApps = [202]; + + bridge._processEventLine('# lighting on //TestProject/254/56/7 #sourceunit=12'); + + expect(publishSpy).not.toHaveBeenCalledWith( + expect.stringMatching(/\/raw$/), + expect.anything(), + expect.anything() + ); + }); + it('parses a project name that ends in digits as the address, not the selector', () => { bridge._processEventLine('# trigger max //MIDSTRM2026/254/202/2 #sourceunit=33');