misenhower / homebridge-wyze-connected-home

Wyze Connected Home plugin for Homebridge
MIT License
70 stars 52 forks source link

Cannot find the bridged Accessory to remove. #9

Open mpmullally opened 4 years ago

mpmullally commented 4 years ago

I consistently receive an error the moment setup the plugin. It goes through a loop like

[6/10/2020, 1:54:24 PM] [Wyze] Configuring accessory: Hallway Sensor
[6/10/2020, 1:54:24 PM] [Wyze] [MotionSensor] Fetching status of Hallway Sensor"
[6/10/2020, 1:54:24 PM] [Wyze] [MotionSensor] Retrieving previous service for Hallway Sensor"
[6/10/2020, 1:54:24 PM] [Wyze] Configuring accessory: Front Window Sensor
[6/10/2020, 1:54:24 PM] [Wyze] [ContactSensor] Fetching status of Front Window Sensor"
[6/10/2020, 1:54:24 PM] [Wyze] [ContactSensor] Retrieving previous service for "Front Window Sensor"
[6/10/2020, 1:54:24 PM] [Wyze] Unrecognized accessory, removing: Glass door
[6/10/2020, 1:54:24 PM] Error: Cannot find the bridged Accessory to remove.
    at Bridge.Accessory._this.removeBridgedAccessory (C:\Users\micha\AppData\Roaming\npm\node_modules\homebridge\node_modules\hap-nodejs\src\lib\Accessory.ts:470:13)
    at Bridge.Accessory._this.removeBridgedAccessories (C:\Users\micha\AppData\Roaming\npm\node_modules\homebridge\node_modules\hap-nodejs\src\lib\Accessory.ts:482:12)
    at Server.handleUnregisterPlatformAccessories (C:\Users\micha\AppData\Roaming\npm\node_modules\homebridge\src\server.ts:547:17)
    at HomebridgeAPI.emit (events.js:210:5)
    at HomebridgeAPI.unregisterPlatformAccessories (C:\Users\micha\AppData\Roaming\npm\node_modules\homebridge\src\api.ts:331:10)
    at WyzeConnectedHome.configureAccessory (C:\Users\micha\AppData\Roaming\npm\node_modules\homebridge-wyze-connected-home\src\WyzeConnectedHome.js:150:16)
    at C:\Users\micha\AppData\Roaming\npm\node_modules\homebridge\src\server.ts:306:25
    at Array.filter (<anonymous>)
    at Server.restoreCachedPlatformAccessories (C:\Users\micha\AppData\Roaming\npm\node_modules\homebridge\src\server.ts:269:69)
    at Server.start (C:\Users\micha\AppData\Roaming\npm\node_modules\homebridge\src\server.ts:157:10)
    at cli (C:\Users\micha\AppData\Roaming\npm\node_modules\homebridge\src\cli.ts:80:10)
    at Object.<anonymous> (C:\Users\micha\AppData\Roaming\npm\node_modules\homebridge\bin\homebridge:17:22)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
[6/10/2020, 1:54:24 PM] [HB Supervisor] Homebridge Process Ended. Code: 1, Signal: null
TheHun99 commented 4 years ago

Same for me, Homebridge doesn't want to start up until I completely remove the plugin.

misenhower commented 4 years ago

I just published a new version that modifies one of the log messages to help diagnose this problem. Could you try updating and re-enabling the plugin again to see if the error changed?

I don't have any of these devices to test with locally -- support for the contact/motion sensors was added by @pjotal so he might have some more ideas here.

pjotal commented 4 years ago

i saw this a couple of times while i was developing the support for the sensors. it happens when the homebridge accessory is initialized before the plugin receives the response from the wyze backend. it happened less than 5% of the time for me so it was really hard to investigate a way to workaround it. what i noticed is that the response time from wyze sometimes can take a bit longer than usual, specially right after the authentication, and this exactly when the issue happens.

if you activate debug mode you’ll see that in the next call the failure is gone completely. if it’s very very relevant to have a flawless status in the first 5 seconds (or whatever is your poll time) then we’ll have to go deep in understanding how homebridge works to see if we can delay a bit the remove and readdition of the accessory.

i can download the new version and run in debug mode to see if i get more details than i already know. will let you know

pjotal commented 4 years ago

can you run homebridge in debug mode and send us the logs so i see exactly where it is failing? i want to make sure the authentication passed fine.

mpmullally commented 4 years ago

logs-everything-setup.txt

I also went ahead and removed all plugins and config options, leaving only the wyze plugin and config and received the same errors

seecoolguy commented 4 years ago

when I try to use my wyze login with 2FA the homebridge on raspberry pi loads up really slow and my 2FA is expired by then.

pjotal commented 4 years ago

hi @seecoolguy. looks like the issue you're facing is different than the originally reported by @mpmullally. could you please report it in a different ticket? also, could you please provide a log of your execution in debug mode in the new ticket?

pjotal commented 4 years ago

hi @mpmullally i'll need a bit of time to investigate this. will try investigate it during the weekend and come back to you. i guess my biggest challenge will be to reproduce it since i don't face this issue since a long time.

pjotal commented 4 years ago

@misenhower could you please update the title of this issue to "Cannot find the bridged Accessory to remove." to avoid people to come and append different behaviours in this ticket due to how much generic its title is?

mpmullally commented 4 years ago

@pjotal would it help if shared access with the device with you to test in the wyze app?

pjotal commented 4 years ago

hi @mpmullally i am having a hard time to reproduce the issue here but maybe i have a fix for it. it's hard to guarantee it's solved as i can't reproduce it easily but i tried different scenarios several times and in all cases the issue was no longer there. i guess that's the best i can do. will submit a PR tomorrow with it. keep us posted when you get the update. fingers crossed! :)

mpmullally commented 4 years ago

Your fix did not work. I did setup a HOOBS install on a spare pi, and everything worked first time.

my plan is to run both bridges since its all working right now.

pjotal commented 4 years ago

hi @mpmullally how you checked the changes? no build was published by @misenhower yet. have you copied the code from the branch and applied to you homebridge directly?

glad to hear you got it working in a vanilla homebridge.

SteveQ2 commented 3 years ago

On windows 10, the plugin also crashes HomeBridge. It works fine when first installed but when I add or remove any device from HomeBridge, the plugin will no longer work; even after uninstalling and reinstalling.

Here is my HomeBridge log:

log file below and attached

[10/2/2020, 8:34:27 PM] [HB Supervisor] Started Homebridge v1.1.6 with PID: 5292 [10/2/2020, 8:34:29 PM] Loaded config.json with 0 accessories and 3 platforms. [10/2/2020, 8:34:29 PM] --- [10/2/2020, 8:34:29 PM] Warning: skipping plugin found at 'C:\node_modules\homebridge-config-ui-x' since we already loaded the same plugin from 'C:\Users\Steve\AppData\Roaming\npm\node_modules\homebridge-config-ui-x'. [10/2/2020, 8:34:30 PM] Loaded plugin: homebridge-camera-ffmpeg@3.0.3 [10/2/2020, 8:34:30 PM] Registering platform 'homebridge-camera-ffmpeg.Camera-ffmpeg' [10/2/2020, 8:34:30 PM] --- [10/2/2020, 8:34:30 PM] Loaded plugin: homebridge-config-ui-x@4.28.0 [10/2/2020, 8:34:30 PM] Registering platform 'homebridge-config-ui-x.config' [10/2/2020, 8:34:30 PM] --- [10/2/2020, 8:34:34 PM] Loaded plugin: homebridge-dafang@1.5.1 [10/2/2020, 8:34:34 PM] Registering platform 'homebridge-dafang.Dafang' [10/2/2020, 8:34:34 PM] --- [10/2/2020, 8:34:34 PM] Loaded plugin: homebridge-homeseer4@1.0.10 homebridge API version: 2.6 [10/2/2020, 8:34:34 PM] Registering platform 'homebridge-homeseer4.HomeSeer' [10/2/2020, 8:34:34 PM] --- [10/2/2020, 8:34:34 PM] Loaded plugin: homebridge-wyze-connected-home@0.5.1 [10/2/2020, 8:34:34 PM] Registering platform 'homebridge-wyze-connected-home.WyzeConnectedHome' [10/2/2020, 8:34:34 PM] --- [10/2/2020, 8:34:34 PM] Loading 3 platforms... [10/2/2020, 8:34:34 PM] [Config] Initializing config platform... [10/2/2020, 8:34:34 PM] [Config] Running in Service Mode [10/2/2020, 8:34:34 PM] [HomeSeer] Initializing HomeSeer platform... [10/2/2020, 8:34:34 PM] [HomeSeer] Start [10/2/2020, 8:34:34 PM] [Camera FFmpeg] Initializing Camera-ffmpeg platform... [10/2/2020, 8:34:34 PM] [Camera FFmpeg] [WyzeRTSP] Configuring cached bridged accessory... [10/2/2020, 8:34:34 PM] Failed to find plugin to handle accessory Back Door Sensor [10/2/2020, 8:34:34 PM] Removing orphaned accessory Back Door Sensor [10/2/2020, 8:34:35 PM] Failed to find plugin to handle accessory Bathroom [10/2/2020, 8:34:35 PM] Removing orphaned accessory Bathroom [10/2/2020, 8:34:35 PM] Failed to find plugin to handle accessory Closet door [10/2/2020, 8:34:35 PM] Removing orphaned accessory Closet door [10/2/2020, 8:34:35 PM] Failed to find plugin to handle accessory Front closet [10/2/2020, 8:34:35 PM] Removing orphaned accessory Front closet [10/2/2020, 8:34:35 PM] Failed to find plugin to handle accessory Back Bedroom [10/2/2020, 8:34:35 PM] Removing orphaned accessory Back Bedroom [10/2/2020, 8:34:35 PM] Failed to find plugin to handle accessory Pier Light [10/2/2020, 8:34:35 PM] Removing orphaned accessory Pier Light [10/2/2020, 8:34:35 PM] Failed to find plugin to handle accessory Medicine Cabinet Upstairs [10/2/2020, 8:34:35 PM] Removing orphaned accessory Medicine Cabinet Upstairs [10/2/2020, 8:34:35 PM] Failed to find plugin to handle accessory Motion1 [10/2/2020, 8:34:35 PM] Removing orphaned accessory Motion1 [10/2/2020, 8:34:35 PM] [HomeSeer] End Creating HomeKit devices from HomeSeer data. [10/2/2020, 8:34:35 PM] [HomeSeer] Checking Configuration Data [10/2/2020, 8:34:35 PM] [HomeSeer] Added a battery to device#: 284 [10/2/2020, 8:34:35 PM] [HomeSeer] Added a battery to device#: 245 [10/2/2020, 8:34:35 PM] [HomeSeer] Added a battery to device#: 138 [10/2/2020, 8:34:35 PM] Initializing platform accessory 'Upstairs C7 lamp on X10 TI103'... [10/2/2020, 8:34:35 PM] Initializing platform accessory 'Upstairs Cabinet Rope Lights C13'... [10/2/2020, 8:34:35 PM] Initializing platform accessory 'Outside Outside Driveway Flood Lights'... [10/2/2020, 8:34:35 PM] Initializing platform accessory 'Outside Outside Lights'... [10/2/2020, 8:34:35 PM] Initializing platform accessory 'Dining Room LED Table Lights-Node 13'... [10/2/2020, 8:34:35 PM] Initializing platform accessory 'Upstairs Bathroom Upstairs Bathroom Light'... [10/2/2020, 8:34:35 PM] Initializing platform accessory 'Upstairs Bathroom Shower Light'... [10/2/2020, 8:34:35 PM] Initializing platform accessory 'Dining Room Crystal Lamp by Table-Node 10'... [10/2/2020, 8:34:35 PM] Initializing platform accessory 'sonoff3 Closet LEDs-sonoff3'... [10/2/2020, 8:34:35 PM] Initializing platform accessory 'MQTT Blue Lamp Upstairs-sonoff16'... [10/2/2020, 8:34:35 PM] Initializing platform accessory 'sonoff19 POWER'... [10/2/2020, 8:34:35 PM] Initializing platform accessory 'sonoff13 POWER'... [10/2/2020, 8:34:35 PM] Initializing platform accessory 'Shelly1 POWER'... [10/2/2020, 8:34:35 PM] Initializing platform accessory 'Shelly2 POWER'...

I really like this plugin! Can this be fixed?

Steve Q

SerpentDrago commented 3 years ago

Still getting this issue , even after trying the fix branch from @pjotal

image

This is a Fresh clean install of Homebridge , instalaled the wyze connected home plugin , and then after it did what it did above on first restart before doing anything besides entering my login / pass into the wyze plugin config .

I stopped it and copied over the contents of pjotal's branch (9_fix_cannot_remove_accessory) into the appdata/roaming/npm/node_modules/homebridge-wyze-connected-home folder and tried to start run homebridge . still no nice still same error . but i have no idea if thats the proper way to update from a forked github repo . and know little to nothing about homebridge config

anyone have any idea what to do ?

I have not added anything else

This is windows 10 x64 . I'm technically adept and can do anything requested

SerpentDrago commented 3 years ago

Ok completely removed , homebridge , all node folders . wiped the crap out of it . reinstalled fresh , then installed this addon/plugin . but before i restarted for the first time after installing . I replaced the node module with the one from @pjotal I think it worked . UPDATE: yep works great . i guess some leftover stuff was from the old version . Anyone else having this issues i suggest replacing this version with the one from pjotal 's branch for this fix , Do it right before you restart after installing "official" version

Thanks !

SteveQ2 commented 3 years ago

Thanks, I found the pjotal repository.

I am new to HomeBridge and GitHub. How/where do I install this?

SerpentDrago commented 3 years ago

download the zip from the 9_fix_cannot_remove_accessory branch on his repo , and then extract the continents replacing what is in > appdata/roaming/npm/node_modules/homebridge-wyze-connected-home

you will need to clear out your homebridge existing stuff (look in HB settings ) or completly remove it and all userdata folders and install fresh . good luck

Hopefully @misenhower will just accept the PR's and merge the fix's into this official repo soon

SteveQ2 commented 3 years ago

Thanks for the info. But I can’t find any of these directories or HomeBridge files on the computer I installed it on. I do have HomeBridge running on another computer on my network.

I don’t know anything about JavaScript.

I’m willing to learn if you can point me to a starting site.

SteveQ2 commented 3 years ago

Ok, I found the files. AppData was a hidden file and was not showing even though “show hidden files” was selected. I will continue to work on it.

SteveQ2 commented 3 years ago

No luck! I cannot reinstall homebridge. I’ve deleted all the files I can find but the installer says the UI is already installed. I will keep looking. ☹️

Sent from my iPhone

On Oct 5, 2020, at 9:19 AM, SerpentDrago notifications@github.com wrote:

 download the zip from the 9_fix_cannot_remove_accessory branch on his repo , and then extract the continents replacing what is in > appdata/roaming/npm/node_modules/homebridge-wyze-connected-home

you will need to clear out your homebridge existing stuff (look in HB settings ) or completly remove it and all userdata folders and install fresh . good luck

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

SteveQ2 commented 3 years ago

OK, It was brutal, but I was finally able to reinstall everything and I now have the the Wyze Connected Home plugin running on HomeBridge. I can See and control my Wyze sensors and plug via my Home app on my iPhone and iPad. I copied the @pjotal repository on top of the @Misenhower files before I used the plugin "settings" button.

I will continue to work with the plugin to see if it will continue to function after I maks changes to the config file. I will post back in a day or two.

SteveQ2 commented 3 years ago

Sorry to say, the plugin crashed HomeBridge when I tried to add another accessory to HomeBridge. Everything worked fine for 2 days until tonight when I tried to add a switch device to HomeBridge.

Here is my log: homebridge.log

SteveQ2 commented 3 years ago

One work-around is to add a second instance of homebridge dedicated to the wyze connected home plugin. ( see https://github.com/oznu/homebridge-config-ui-x/wiki/Homebridge-Service-Command#multiple-instances) This will keep the plugin and wyze devices separated from the other Home accessories.

theclamps commented 3 years ago

I have tried everything mentioned in this thread and am unable to get it to function correctly. I tried making a new instance of Homebridge (but it just acted like the first one), I tried overwriting with the new files. I feel like I am missing something easier than I would think at this point. Any other advice?

SteveQ2 commented 3 years ago

To get HomeBridge working again (Windows 10) , I uninstalled it and deleted all the HomeBridge related sub directories in the user directory and the app data directory. I then reinstalled hb-service. After HomeBridge is running, The Wyze plugin for HomeBridge can then be reinstalled and will work. But HomeBridge will fail again if I make any change to the Wyze config.Json file. The pjotal repository did not solve the problem for me.

theclamps commented 3 years ago

I have tried that, but it keeps giving me the same issue. I tried the repo and it was the same exact thing. Maybe I am missing a folder somewhere as I delete both the npm and npm-cache folder in AppData and the .homebridge folder that is made in user folder. Are there others?

Edit: I figured out how to get it to work. I turned on Debug Mode to see what was happening and it looked like the accessories were cached. So, I went in to Homebridge Settings and removed all of these as cached accessories and it reset them all and it has been working for a little bit now. Haven't added a new one in yet, but I plan to when I can. My phone is currently on iOS 14.2 beta and for some reason the Wyze app refuses to let plugs be set up with it.

Edit 2: It was shortlived...every time Homebridge has to be restarted I have to go through and remove the cached accessories. This also removes them from the Home App and then removes the organizing I did so I have to do it all over again.

SteveQ2 commented 3 years ago

I believe that when you uninstall hb-service any cached device info is deleted, but the config info is not.

I have 8 Wyze devices. I am using a second instance of HomeBridge and the Wyze connected home plugin for only these devices, nothing else. It has been running for 4 days now.

OohTheZigbee commented 3 years ago

I'm a couple months late to the party but am still dealing with this issue. Has anyone found a more permanent fix than starting a second instance of HomeBridge??

OohTheZigbee commented 3 years ago

I'm a couple months late to the party but am still dealing with this issue. Has anyone found a more permanent fix than starting a second instance of HomeBridge??

UPDATE: Using a child bridge does not work as well as hoped. Any restart of the parent bridge (adding a new plugin, etc) results in the error code being thrown by the child bridge. I restarted a second instance, reset the bridge so that Apple HomeKit would recognize it as a new device, and removed all cached accessories. I don't plan to add any other plugins to this instance so that if it ever needs to be reset I only lose the Wyze devices and no others.

I am just getting back into Git so when I've got my feet under me I may try to tackle this issue.

@misenhower @pjotal can you label as "good first issue" to point new users towards this thread?

SteveQ2 commented 3 years ago

I hope someone can fix this issue. The plugin works great running in a second instance of Homebridge as long as nothing changes. I had a power failure and had to reconfigure the plugin. I have 13 Wyze devices. When you restart a new instance of Homebridge you have to delete the old bridge from your iphone. This destroys all HomeKit scenes and automations containing Wyze devices. It is a real pain to get the iphone HomeKit working again .

Please, please, please fix this.

SteveQ2 commented 3 years ago

By the way, the plugin fails whenever the computer is rebooted. Windows automatic updates can force a reboot. This kills the plugin. This is a major issue!

SteveQ2 commented 3 years ago

Any new information about this issue? I now have 13 wyze devices. The plugin fails about once every 3-4 weeks.