dubocr / homebridge-gpio-device

Homebridge GPIO device expose several HomeKit accessories interacting with GPIO
Apache License 2.0
65 stars 22 forks source link

Not working with Pi5 #129

Open pofamacska opened 10 months ago

pofamacska commented 10 months ago

The plugin makes homebridge to cars and go into a crash - shut down - restart - crash cycle endlessly with this error message: AssertionError [ERR_ASSERTION]: Cannot generate setupURI on an accessory that isn't published yet! at Bridge.Accessory.setupURI (/var/lib/homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:994:11) at Server.setServerStatus (/var/lib/homebridge/node_modules/homebridge/src/server.ts:155:45) at Server.teardown (/var/lib/homebridge/node_modules/homebridge/src/server.ts:199:10) at signalHandler (/var/lib/homebridge/node_modules/homebridge/src/cli.ts:93:12) at process.emit (node:events:517:28) at process.emit (/var/lib/homebridge/node_modules/homebridge/node_modules/source-map-support/source-map-support.js:516:21)

Any idea how to avoid this?

rajkundu commented 4 months ago

I had this issue too on a Pi Zero 2 W with the latest versions of everything (clean install). The full stack trace was as follows:

homebridge-gpio-device API version: 2.7
[20/07/2024, 18:45:04] Registering accessory 'homebridge-gpio-device.GPIODevice'
[20/07/2024, 18:45:04] ---
[20/07/2024, 18:45:04] Loading 1 platforms...
[20/07/2024, 18:45:04] Loading 1 accessories...
[20/07/2024, 18:45:04] [Front Door] Initializing GPIODevice accessory...
[20/07/2024, 18:45:04] Error: EINVAL: invalid argument, write
    at Object.writeFileSync (node:fs:2368:20)
    at exportGpio (/var/lib/homebridge/node_modules/homebridge-gpio-device/node_modules/onoff/onoff.js:18:8)
    at new Gpio (/var/lib/homebridge/node_modules/homebridge-gpio-device/node_modules/onoff/onoff.js:172:36)
    at Object.init (/var/lib/homebridge/node_modules/homebridge-gpio-device/index.js:22:19)
    at new LockMechanism (/var/lib/homebridge/node_modules/homebridge-gpio-device/index.js:432:7)
    at new DeviceAccesory (/var/lib/homebridge/node_modules/homebridge-gpio-device/index.js:140:18)
    at /var/lib/homebridge/node_modules/homebridge/src/server.ts:367:50
    at Array.forEach (<anonymous>)
    at Server.loadAccessories (/var/lib/homebridge/node_modules/homebridge/src/server.ts:287:29)
    at Server.start (/var/lib/homebridge/node_modules/homebridge/src/server.ts:167:12)
[20/07/2024, 18:45:04] Got SIGTERM, shutting down Homebridge...
[20/07/2024, 18:45:04] AssertionError [ERR_ASSERTION]: Cannot generate setupURI on an accessory that isn't published yet!
    at Bridge.Accessory.setupURI (/var/lib/homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1004:11)
    at Server.setServerStatus (/var/lib/homebridge/node_modules/homebridge/src/server.ts:143:45)
    at Server.teardown (/var/lib/homebridge/node_modules/homebridge/src/server.ts:187:10)
    at signalHandler (/var/lib/homebridge/node_modules/homebridge/src/cli.ts:94:12)
    at process.emit (node:events:519:28)
    at process.emit (/var/lib/homebridge/node_modules/homebridge/node_modules/source-map-support/source-map-support.js:516:21)
[20/07/2024, 18:45:09] [HB Supervisor] Homebridge Process Ended. Code: 143, Signal: null
[20/07/2024, 18:45:14] [HB Supervisor] Restarting Homebridge...
[20/07/2024, 18:45:14] [HB Supervisor] Starting Homebridge with extra flags: -I -P /var/lib/homebridge/node_modules -D --strict-plugin-resolution
[20/07/2024, 18:45:14] [HB Supervisor] Started Homebridge v1.8.4 with PID: 3392
[20/07/2024, 18:45:16] Loaded config.json with 1 accessories and 1 platforms.
[20/07/2024, 18:45:17] Loaded 0 cached accessories from cachedAccessories.
[20/07/2024, 18:45:17] ---
[20/07/2024, 18:45:17] Loaded plugin: homebridge-gpio-device@0.4.9

Thus, the root issue is EINVAL: invalid argument, write in the onoff package, and Googling this error led me to this StackOverflow answer: https://stackoverflow.com/a/78184108 which solved the issue for me. It is perhaps a bit of a hacky workaround, but my use case is quite simple. Hope this helps someone else!