beele / homebridge-unifi-protect-camera-motion

Camera & Motion sensor support for Unifi Protect cameras in Homekit via Homebridge
Apache License 2.0
103 stars 12 forks source link

HB won't start after install #65

Closed twynne closed 4 years ago

twynne commented 4 years ago

Describe the bug After installing this plugin via Config UI X, Homebridge repeatedly crashes during startup.

Specifications What hardware and OS is your Homebridge running on?
Mac OS Homebridge 1.2.0b33 (any issues with current beta?)

What Unifi hardware are you using CKG2+ Flex-G3 camera

In case you have issues with streaming via FFMpeg, have you tried with https://www.npmjs.com/package/homebridge-camera-ffmpeg first, if not, do this first!
Will try

Logging Debug is not showing any additional information. I can't even see the plugin loading in logs.

To Reproduce Steps to reproduce the behavior: I have checked that

Additional context My homebridge install is otherwise stable and has been for many months. The Unifi camera is new, but is otherwise working perfectly. Is there any reason to suspect issues with the HB beta and this plugin?

twynne commented 4 years ago

This is all I'm seeing in the logs following installing/configuring the plugin:

[37m[8/3/2020, 12:00:53 PM] [HB Supervisor] Restarting Homebridge... [8/3/2020, 12:00:53 PM] [HB Supervisor] Starting Homebridge with extra flags: -I [8/3/2020, 12:00:53 PM] [HB Supervisor] Started Homebridge v1.2.0-beta.33 with PID: 68703 [8/3/2020, 12:00:53 PM] Loaded config.json with 3 accessories and 5 platforms. [8/3/2020, 12:00:53 PM] --- [8/3/2020, 12:00:54 PM] Loaded plugin: homebridge-accessory-bandwidth-quality@0.9.10 [8/3/2020, 12:00:54 PM] Registering accessory 'homebridge-accessory-bandwidth-quality.bandwidth-quality' [8/3/2020, 12:00:54 PM] --- [8/3/2020, 12:00:54 PM] Loaded plugin: homebridge-config-ui-x@4.24.0 [8/3/2020, 12:00:54 PM] Registering platform 'homebridge-config-ui-x.config' [8/3/2020, 12:00:54 PM] --- [8/3/2020, 12:00:54 PM] Loaded plugin: homebridge-dyson-pure-cool@1.7.11 [8/3/2020, 12:00:54 PM] Registering platform 'homebridge-dyson-pure-cool.DysonPureCoolPlatform' [8/3/2020, 12:00:54 PM] --- [8/3/2020, 12:00:55 PM] Loaded plugin: homebridge-harmony@1.3.11 [8/3/2020, 12:00:55 PM] Registering platform 'homebridge-harmony.HarmonyHubWebSocket' [8/3/2020, 12:00:55 PM] --- [8/3/2020, 12:00:55 PM] Loaded plugin: homebridge-platform-wemo@1.5.6 [8/3/2020, 12:00:55 PM] Registering platform 'homebridge-platform-wemo.BelkinWeMo' [8/3/2020, 12:00:55 PM] --- [8/3/2020, 12:00:55 PM] Loaded plugin: homebridge-ssh@0.0.6 [8/3/2020, 12:00:55 PM] Registering accessory 'homebridge-ssh.SSH' [8/3/2020, 12:00:55 PM] --- [8/3/2020, 12:00:55 PM] Loaded plugin: homebridge-unifi-occupancy-sensor@1.0.0 [8/3/2020, 12:00:55 PM] Registering accessory 'homebridge-unifi-occupancy-sensor.UniFi Occupancy Sensor' [8/3/2020, 12:00:55 PM] --- [8/3/2020, 12:00:56 PM] [HB Supervisor] Homebridge Process Ended. Code: null, Signal: SIGILL

My current plugin config is:

{
        "name": "Unifi protect cameras & motion sensors",
        "platform": "UnifiProtectMotion",
        "unifi": {
            "enhanced_classes": [],
            "controller": "https://192.168.1.4:7443",
            "controller_rtsp": "rtsp://192.168.1.4:7447",
            "username": "user",
            "password": "pwd",
            "motion_interval": 5000,
            "motion_repeat_interval": 30000,
            "motion_score": 0,
            "enhanced_motion": true,
            "enhanced_motion_score": 50,
            "enable_motion_trigger": true,
            "save_snapshot": false,
            "debug": true,
            "debug_network_traffic": false
        },
        "googlePhotos": {
            "upload_gphotos": false,
            "auth_redirectUrl": "http://localhost:8080/oauth2-callback"
        },
        "videoConfig": {
            "maxStreams": 2,
            "maxWidth": 1920,
            "maxHeight": 1080,
            "maxFPS": 15,
            "maxBitrate": 3000,
            "vcodec": "libx264",
            "packetSize": 376,
            "audio": false,
            "additionalCommandline": "-protocol_whitelist https,crypto,srtp,rtp,udp"
        }
    }

All of this was set via ConfigUI X and the config validated fine.

twynne commented 4 years ago

Trying with just the ffmpeg plugin, I don't see video either. The log reflects only the following:

[8/3/2020, 1:03:48 PM] [Camera FFmpeg] [Lounge-temp] An error occurred while making snapshot request: Error: spawn ffmpeg ENOENT [8/3/2020, 1:03:48 PM] [Camera FFmpeg] [Lounge-temp] Video stream requested: 1280x720, 30 fps, 299 kbps [8/3/2020, 1:03:48 PM] [Camera FFmpeg] [Lounge-temp] Starting video stream: 1280x720, 15 fps, 299 kbps [8/3/2020, 1:03:48 PM] [Camera FFmpeg] [Lounge-temp] Stream command: ffmpeg -i rtsp://192.168.1.4:7447/FDZaYME3mL4DtUy5 -map 0:0 -vcodec libx264 -pix_fmt yuv420p -r 15 -f rawvideo -preset ultrafast -tune zerolatency -vf scale=1280:720 -b:v 299k -bufsize 598k -maxrate 299k -payload_type 99 -ssrc 5258608 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params AP8NGf3voMzUdxNEGgkhQDrABBKSI6DCHCJrv966 srtp://192.168.1.111:64101?rtcpport=64101&localrtcpport=64101&pkt_size=1316 -loglevel level+verbose [8/3/2020, 1:03:48 PM] [Camera FFmpeg] [Lounge-temp] Failed to start stream: spawn ffmpeg ENOENT [8/3/2020, 1:03:48 PM] [Camera FFmpeg] [Lounge-temp] Stopped video stream. [8/3/2020, 1:03:49 PM] [Camera FFmpeg] [Lounge-temp] Snapshot requested: 1280x720 [8/3/2020, 1:03:49 PM] [Camera FFmpeg] [Lounge-temp] Sending snapshot: 1280x720 [8/3/2020, 1:03:49 PM] [Camera FFmpeg] [Lounge-temp] Snapshot command: ffmpeg -i rtsp://192.168.1.4:7447/FDZaYME3mL4DtUy5 -frames:v 1 -vf scale=1280:720 -f image2 - [8/3/2020, 1:03:49 PM] [Camera FFmpeg] [Lounge-temp] An error occurred while making snapshot request: Error: spawn ffmpeg ENOENT

Viewing the feed via the camera's rtsp address, in a browser, works fine.

I assume therefore that the issue is ffmpeg, but I understood that this plugin had it's own deployment of ffmpeg. What else should I check?

twynne commented 4 years ago

Got a bit further... installed camera-ffmpeg plugin, then installed/updated ffmpeg externally and was able to get the video to stream. Reinstalled the protect-motion plugin and it still fails, but the log now shows the following:

[37m[8/3/2020, 3:45:37 PM] ERROR LOADING PLUGIN homebridge-unifi-protect-camera-motion: [8/3/2020, 3:45:37 PM] Error: Cannot find module 'axios' Require stack: - /usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/src/unifi/unifi.js - /usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/src/unifi-protect-motion-platform.js - /usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/src/index.js - /usr/local/lib/node_modules/homebridge/lib/plugin.js - /usr/local/lib/node_modules/homebridge/lib/pluginManager.js - /usr/local/lib/node_modules/homebridge/lib/api.js - /usr/local/lib/node_modules/homebridge/lib/server.js - /usr/local/lib/node_modules/homebridge/lib/cli.js - /usr/local/lib/node_modules/homebridge/bin/homebridge  at Function.Module._resolveFilename (internal/modules/cjs/loader.js:976:15)  at Function.Module._load (internal/modules/cjs/loader.js:859:27)  at Module.require (internal/modules/cjs/loader.js:1036:19)  at require (internal/modules/cjs/helpers.js:72:18)  at Object. (/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/src/unifi/unifi.js:25:15)  at Module._compile (internal/modules/cjs/loader.js:1147:30)  at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)  at Module.load (internal/modules/cjs/loader.js:996:32)  at Function.Module._load (internal/modules/cjs/loader.js:896:14)  at Module.require (internal/modules/cjs/loader.js:1036:19)  at require (internal/modules/cjs/helpers.js:72:18)  at Object. (/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/src/unifi-protect-motion-platform.js:4:17)  at Module._compile (internal/modules/cjs/loader.js:1147:30)  at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)  at Module.load (internal/modules/cjs/loader.js:996:32)  at Function.Module._load (internal/modules/cjs/loader.js:896:14)  at Module.require (internal/modules/cjs/loader.js:1036:19)  at require (internal/modules/cjs/helpers.js:72:18)  at Object. (/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/src/index.js:2:41)  at Module._compile (internal/modules/cjs/loader.js:1147:30)  at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)  at Module.load (internal/modules/cjs/loader.js:996:32)  at Function.Module._load (internal/modules/cjs/loader.js:896:14)  at Module.require (internal/modules/cjs/loader.js:1036:19)  at require (internal/modules/cjs/helpers.js:72:18)  at Plugin.load (/usr/local/lib/node_modules/homebridge/src/plugin.ts:181:27)  at /usr/local/lib/node_modules/homebridge/src/pluginManager.ts:120:16  at Map.forEach ()  at PluginManager.initializeInstalledPlugins (/usr/local/lib/node_modules/homebridge/src/pluginManager.ts:118:18)  at Server.start (/usr/local/lib/node_modules/homebridge/src/server.ts:148:24)  at cli (/usr/local/lib/node_modules/homebridge/src/cli.ts:80:10)  at Object. (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22)  at Module._compile (internal/modules/cjs/loader.js:1147:30)  at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)  at Module.load (internal/modules/cjs/loader.js:996:32)  at Function.Module._load (internal/modules/cjs/loader.js:896:14)  at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)  at internal/main/run_main_module.js:17:47

Any ideas what I'm missing?

twynne commented 4 years ago

Just one more thing to add, homebridge-unifi-protect is now installed and working fine. So, there is something specific to the motion plugin that seems to have an issue. Either an issue with the platform on which I'm trying to run it (MacOS native), or there's an install/config issue. I've used the same values to configure Unifi-protect and they seem to work.

It would of course be nice to get the motion detection working, so would appreciate any suggestions or feedback based on the above.

Thanks 👍

beele commented 4 years ago

Could you try with: sudo npm i -g --unsafe-perm=true homebridge-unifi-protect-camera-motion@0.4.2-beta.1

twynne commented 4 years ago

Hi,

Same result I'm afraid. Homebridge just fails to load successfully once that is installed and config added. Uninstalling and removing the config, all is well again.

beele commented 4 years ago

The strange thing is that you are getting a: Signal: SIGILL message ==> illegal instruction which is kinda weird, I'm gonna try locally with the homebridge beta. I suspect it's related to that or it might be clashing with another plugin

EDIT: just installed homebridge@1.2.0-beta.33 on my machine (osx catalina) and it works just fine. Could you try to spin up a different homebridge instance with only this plugin in the config, no need to add it to your home, just to see if it will start up correctly

twynne commented 4 years ago

I'm afraid I've no idea how I would go about creating a second homebridge instance. Is there guidance on that somewhere?

beele commented 4 years ago

In your second log I don't see the SIGILL but I see this: Cannot find module 'axios' Which means that the axios dependency can not be found, which the latest beta isn't even using anymore. This leads me to believe that the package did not update correctly. Could you try removing the folder where the plugin is installed? use: npm root -g => prints where global npm packages are installed, enter that folder via the terminal then remove the plugin directory with rm -rf homebridge-unifi-protect-camera-motion then reinstall the plugin again with sudo npm i -g --unsafe-perm=true homebridge-unifi-protect-camera-motion@0.4.2-beta.2

I added a new beta as there might have been some leftover files included in that build that might have caused this issue

twynne commented 4 years ago

No joy. You're correct that the folder was still there, which I removed. Reinstalled using your command above, then added back the config lines (all default values).

Homebridge repeatedly fails to load until I remove the plugin (uninstall via Config UI fails, have to do via command line). Nothing useful showing in logs beyond the above.

[8/5/2020, 4:43:46 PM] [HB Supervisor] Restarting Homebridge... [8/5/2020, 4:43:46 PM] [HB Supervisor] Starting Homebridge with extra flags: -I [8/5/2020, 4:43:46 PM] [HB Supervisor] Started Homebridge v1.2.0-beta.33 with PID: 26678 [8/5/2020, 4:43:46 PM] Loaded config.json with 3 accessories and 6 platforms. [8/5/2020, 4:43:46 PM] --- [8/5/2020, 4:43:47 PM] Loaded plugin: homebridge-accessory-bandwidth-quality@0.9.11 [8/5/2020, 4:43:47 PM] Registering accessory 'homebridge-accessory-bandwidth-quality.bandwidth-quality' [8/5/2020, 4:43:47 PM] --- [8/5/2020, 4:43:47 PM] Loaded plugin: homebridge-config-ui-x@4.24.0 [8/5/2020, 4:43:47 PM] Registering platform 'homebridge-config-ui-x.config' [8/5/2020, 4:43:47 PM] --- [8/5/2020, 4:43:47 PM] Loaded plugin: homebridge-dyson-pure-cool@1.7.11 [8/5/2020, 4:43:47 PM] Registering platform 'homebridge-dyson-pure-cool.DysonPureCoolPlatform' [8/5/2020, 4:43:47 PM] --- [8/5/2020, 4:43:48 PM] Loaded plugin: homebridge-harmony@1.3.11 [8/5/2020, 4:43:48 PM] Registering platform 'homebridge-harmony.HarmonyHubWebSocket' [8/5/2020, 4:43:48 PM] --- [8/5/2020, 4:43:48 PM] Loaded plugin: homebridge-platform-wemo@1.5.6 [8/5/2020, 4:43:48 PM] Registering platform 'homebridge-platform-wemo.BelkinWeMo' [8/5/2020, 4:43:48 PM] --- [8/5/2020, 4:43:48 PM] Loaded plugin: homebridge-ssh@0.0.6 [8/5/2020, 4:43:48 PM] Registering accessory 'homebridge-ssh.SSH' [8/5/2020, 4:43:48 PM] --- [8/5/2020, 4:43:48 PM] Loaded plugin: homebridge-unifi-occupancy-sensor@1.0.0 [8/5/2020, 4:43:48 PM] Registering accessory 'homebridge-unifi-occupancy-sensor.UniFi Occupancy Sensor' [8/5/2020, 4:43:48 PM] --- [8/5/2020, 4:43:49 PM] [HB Supervisor] Homebridge Process Ended. Code: null, Signal: SIGILL

beele commented 4 years ago

Make a basic config.json file with only this plugin configured. Place that file in a folder you remember. Open a terminal and execute: homebridge -D -U FULL_PATH_TO_FOLDER/ This should run a new homebridge instance using the config from that folder

twynne commented 4 years ago

Not sure if that worked, but I get the following output in terminal:

wl21:node_modules homeserver$ homebridge -D -U /Users/homeserver/homebridge2 [05/08/2020, 17:54:54] Loaded config.json with 0 accessories and 1 platforms. [05/08/2020, 17:54:54] --- [05/08/2020, 17:54:55] Loaded plugin: homebridge-accessory-bandwidth-quality@0.9.11 [05/08/2020, 17:54:55] Registering accessory 'homebridge-accessory-bandwidth-quality.bandwidth-quality' [05/08/2020, 17:54:55] --- [05/08/2020, 17:54:55] Loaded plugin: homebridge-config-ui-x@4.24.0 [05/08/2020, 17:54:55] Registering platform 'homebridge-config-ui-x.config' [05/08/2020, 17:54:55] --- [05/08/2020, 17:54:55] Loaded plugin: homebridge-dyson-pure-cool@1.7.11 [05/08/2020, 17:54:55] Registering platform 'homebridge-dyson-pure-cool.DysonPureCoolPlatform' [05/08/2020, 17:54:55] --- [05/08/2020, 17:54:56] Loaded plugin: homebridge-harmony@1.3.11 [05/08/2020, 17:54:56] Registering platform 'homebridge-harmony.HarmonyHubWebSocket' [05/08/2020, 17:54:56] --- [05/08/2020, 17:54:56] Loaded plugin: homebridge-platform-wemo@1.5.6 [05/08/2020, 17:54:56] Registering platform 'homebridge-platform-wemo.BelkinWeMo' [05/08/2020, 17:54:56] --- [05/08/2020, 17:54:57] Loaded plugin: homebridge-ssh@0.0.6 [05/08/2020, 17:54:57] Registering accessory 'homebridge-ssh.SSH' [05/08/2020, 17:54:57] --- [05/08/2020, 17:54:57] Loaded plugin: homebridge-unifi-occupancy-sensor@1.0.0 [05/08/2020, 17:54:57] Registering accessory 'homebridge-unifi-occupancy-sensor.UniFi Occupancy Sensor' [05/08/2020, 17:54:57] --- Illegal instruction: 4

beele commented 4 years ago

Hmm this seems really weird => Illegal instruction: 4 which is something, if coming from my plugin, which I've never seen before.

beele commented 4 years ago

If you fully remove the plugin and reinstall it, what does the full install log say?

beele commented 4 years ago

Closing due to inactivity