Replace node-libgpiod with gpiomon CLI – remove electron-rebuild#2
Replace node-libgpiod with gpiomon CLI – remove electron-rebuild#2rkorell merged 1 commit intorkorell:mainfrom
node-libgpiod with gpiomon CLI – remove electron-rebuild#2Conversation
…n-rebuild - Replace native node-libgpiod with gpiomon (gpiod CLI) for PIR edge detection - Auto-detect libgpiod version (1.x vs 2.x) for correct gpiomon argument syntax - Auto-fallback to Python/gpiozero if gpiomon is unavailable or crashes on startup - Delete postinstall script (was: @electron/rebuild trigger) - Remove node-libgpiod from optionalDependencies; package-lock regenerated (0 vulnerabilities) - Add stop() cleanup method to node_helper - Update README: installation, GPIO section, troubleshooting, changelog
Replace unconditional console.log calls with this.log() using appropriate debug levels (simple/complex). Only errors remain as console.error. With debug: "off" (default), pm2 logs are now clean — no more updatePresence/updateScreen noise every few seconds. Discovered during PR #2 testing — thanks to KristjanESPERANTO.
|
Dear Kristjan, @KristjanESPERANTO, Thank you so much for this contribution! I've tested it on my Pi 5 (Debian Trixie, libgpiod 2.x) This is a huge improvement over the previous approach. Eliminating node-libgpiod, Your PR also helped me discover a pre-existing log spam issue: several console.log calls in Warm regards, |
|
Hi Ralf 🙂 I'm glad it's working! I'm trying to get rid of electron-rebuild in the MagicMirror ecosystem, but I don't think that's possible for all modules, or at least it's very difficult. |
|
Dear Kristjan, BTW: I've tried to join the private group "module developers" but my ask is still "invitation pending" - are you aware who can approve this? Thanks again! Warmest regards, |
The mass is not the problem at all. Of the more than 1000 modules, I know exactly which ones use electron-rebuild, and there are only a handful. But some packages cannot be replaced as “easily” as node-libgpiod. I have already successfully converted the simple cases. The rest may always have to remain with electron-rebuild.
The core team. But there are no notifications about that. I just accepted your request to join 🙂 Thanks for your contributions! 😃 What I noticed in your module: you are using your own complex logger in node_helper. Is this an old legacy from the previous modules? You could use the logger from the core: |
|
this ist pretty COOL. Thank you SO much ! Regarding the core-logger: Good point, I looked into it — the core logger doesn't support file output (logFileName) or forwarding debug messages to the frontend, which we need. |
Replaces the native
node-libgpioddependency withgpiomon(from thegpiodpackage) for PIR edge detection – the same approach used by MMM-Buttons.Key benefits:
electron-rebuildafternpm installgpiomonis pre-installed on Raspberry Pi OS – no extraapt installneeded for most usersDetails:
pirLib.js: spawnsgpiomonviachild_process; auto-detects libgpiod version (1.x:gpiomon gpiochip0 4/ 2.x:gpiomon -c gpiochip0 -p 200ms 4); falls back to Python/gpiozero on failurenode_helper.js: addedstop()cleanup; removed stale refspackage.json/package-lock.json:node-libgpiodandpostinstallremovedREADME.md: updated accordinglyLet me know if anything isn't working 🙂