luisiam / homebridge-cmdswitch2

CMD Plugin for HomeBridge (API 2.0): https://github.com/nfarina/homebridge
Apache License 2.0
176 stars 29 forks source link

Cannot add a bridged Accessory with the same UUID as another bridged Accessory #8

Open sethfowler opened 7 years ago

sethfowler commented 7 years ago

Thanks for writing this plugin; it's great! I'm using it with ps4-waker to turn on and off my PS4.

I am running into a problem, though. The first time I start up homebridge with homebridge-cmdswitch2 enabled, everything's fine. The next time, though, I get the following error:

[CMD Switch] Initializing cmdSwitch2 platform...
[CMD Switch] Initializing platform accessory 'Playstation 4'...
/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:222
      throw new Error("Cannot add a bridged Accessory with the same UUID as another bridged Accessory: " + existing.UUID);
      ^
Error: Cannot add a bridged Accessory with the same UUID as another bridged Accessory: 53ad352f-f3dd-4e5c-bfe9-b695be18f9d3
    at Bridge.Accessory.addBridgedAccessory (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:222:13)
    at Bridge.Accessory.addBridgedAccessories (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:268:10)
    at Server._handleRegisterPlatformAccessories (/usr/lib/node_modules/homebridge/lib/server.js:434:16)
    at Server.<anonymous> (/usr/lib/node_modules/homebridge/lib/server.js:33:10)
    at emitOne (events.js:96:13)
    at API.emit (events.js:188:7)
    at API.registerPlatformAccessories (/usr/lib/node_modules/homebridge/lib/api.js:155:8)
    at cmdSwitchPlatform.addAccessory (/usr/lib/node_modules/homebridge-cmdswitch2/index.js:67:14)
    at cmdSwitchPlatform.didFinishLaunching (/usr/lib/node_modules/homebridge-cmdswitch2/index.js:36:37)
    at emitNone (events.js:86:13)
    at API.emit (events.js:185:7)
    at Server.run (/usr/lib/node_modules/homebridge/lib/server.js:90:13)
    at module.exports (/usr/lib/node_modules/homebridge/lib/cli.js:40:10)
    at Object.<anonymous> (/usr/lib/node_modules/homebridge/bin/homebridge:17:22)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.runMain (module.js:590:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)

To get rid of this problem, I have to remove the Playstation 4 section from switches in the configuration file. After that, I can successfully start up homebridge (though with no control over my PS4, obviously), and if I shut it down and add the Playstation 4 section back to the configuration file, everything works fine the next time I start it up.

I need to repeat this process every time I need to restart homebridge. Any idea why this might be happening?

luisiam commented 7 years ago

This may have to do with the cache stored in homebridge. Delete ~/.homebridge/accessories folder and try again.

sethfowler commented 7 years ago

Yeah, that makes sense. Unfortunately I moved recently and I don't have access to the machine that I was running homebridge on right now, so I can't test that at the moment.

gabriellanata commented 7 years ago

Deleting the cache stored in homebridge like luisiam said fixed the problem for me

ThisIsQasim commented 7 years ago

So are supposed to delete cache everytime homebridge restarts?

DJay-X commented 7 years ago

Out of the blue I have the Problem with UUID as well. I already deleted the .homebridge/accessories folder and after a restart the problem was fixed. Until the next restart. And my homebridge is programmed to restart every hour. I use the homebridge-cmdswitch2 to work together with iBrew Of course when I remove the cmdswitch2 part from my config.json homebridge works well even after several restarts. I'm surprised that this behavior appeared after a couple of days working very well. Any idea how to get rid of the UUID problem permanent? Thanks in advance.

[2017-3-6 12:35:07] Initializing platform accessory 'Wasserkocher'... /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:222 throw new Error("Cannot add a bridged Accessory with the same UUID as another bridged Accessory: " + existing.UUID); ^

Error: Cannot add a bridged Accessory with the same UUID as another bridged Accessory: dc71edd5-26c5-4b45-8107-6326e5011e9f at Bridge.Accessory.addBridgedAccessory (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:222:13) at Bridge.Accessory.addBridgedAccessories (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:268:10) at Server._handleRegisterPlatformAccessories (/usr/local/lib/node_modules/homebridge/lib/server.js:437:16) at Server. (/usr/local/lib/node_modules/homebridge/lib/server.js:36:10) at emitOne (events.js:96:13) at API.emit (events.js:189:7) at API.registerPlatformAccessories (/usr/local/lib/node_modules/homebridge/lib/api.js:155:8) at cmdSwitchPlatform.addAccessory (/usr/local/lib/node_modules/homebridge-cmdswitch2/index.js:67:14) at cmdSwitchPlatform.didFinishLaunching (/usr/local/lib/node_modules/homebridge-cmdswitch2/index.js:36:37) at emitNone (events.js:86:13) at API.emit (events.js:186:7) at Server.run (/usr/local/lib/node_modules/homebridge/lib/server.js:93:13) at module.exports (/usr/local/lib/node_modules/homebridge/lib/cli.js:40:10) at Object. (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22) at Module._compile (module.js:571:32) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:488:32) at tryModuleLoad (module.js:447:12) at Function.Module._load (module.js:439:3) at Module.runMain (module.js:605:10) at run (bootstrap_node.js:422:7) at startup (bootstrap_node.js:143:9) at bootstrap_node.js:537:3

sethfowler commented 7 years ago

The only solution I found was to start using Home Assistant for this type of functionality, but I like this plugin and I'm hoping the author can track down the issue.

luisiam commented 7 years ago

If that happens again, can you go to http://ip:port/accessories and check which accessory is having the same UUID?

maldeS commented 7 years ago

Hi, any news regarding this issues? Seems i have the same problem. I have to clear the cache and pair my PS4. As long as the service is not restarted everything is fine.

After the restart i get the same error:

Load homebridge-cmdaccessory.cmdAccessory
[2017-9-3 19:35:42] Initializing platform accessory 'PlayStation'...
/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:225
throw new Error("Cannot add a bridged Accessory with the same UUID as another bridged Accessory: " + existing.UUID);
^

Error: Cannot add a bridged Accessory with the same UUID as another bridged Accessory: 92f1af0d-b7dd-47a6-b89f-0bfaa7f3efe7
at Bridge.Accessory.addBridgedAccessory (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:225:13)
at Bridge.Accessory.addBridgedAccessories (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:251:10)
at Server._handleRegisterPlatformAccessories (/usr/local/lib/node_modules/homebridge/lib/server.js:437:16)
at Server. (/usr/local/lib/node_modules/homebridge/lib/server.js:36:10)
at emitOne (events.js:115:13)
at API.emit (events.js:210:7)
at API.registerPlatformAccessories (/usr/local/lib/node_modules/homebridge/lib/api.js:159:8)
at cmdSwitchPlatform.addAccessory (/usr/local/lib/node_modules/homebridge-cmdswitch2/index.js:67:14)
at cmdSwitchPlatform.didFinishLaunching (/usr/local/lib/node_modules/homebridge-cmdswitch2/index.js:36:37)
at emitNone (events.js:110:20)
at API.emit (events.js:207:7)
at Server.run (/usr/local/lib/node_modules/homebridge/lib/server.js:93:13)
at module.exports (/usr/local/lib/node_modules/homebridge/lib/cli.js:40:10)
at Object. (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)

This is the content of cachedAccessories:

[{"plugin":"homebridge-cmdswitch2","platform":"cmdSwitch2","displayName":"PlayStation","UUID":"92f1af0d-b7dd-47a6-b89f-0bfaa7f3efe7","category":8,"context":{},"services":[{"UUID":"0000003E-0000-1000-8000-0026BB765291","characteristics":[{"displayName":"Identify","UUID":"00000014-0000-1000-8000-0026BB765291","props":{"format":"bool","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pw"]},"value":false,"eventOnlyCharacteristic":false},{"displayName":"Manufacturer","UUID":"00000020-0000-1000-8000-0026BB765291","props":{"format":"string","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pr"]},"value":"Default-Manufacturer","eventOnlyCharacteristic":false},{"displayName":"Model","UUID":"00000021-0000-1000-8000-0026BB765291","props":{"format":"string","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pr"]},"value":"Default-Model","eventOnlyCharacteristic":false},{"displayName":"Name","UUID":"00000023-0000-1000-8000-0026BB765291","props":{"format":"string","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pr"]},"value":"PlayStation","eventOnlyCharacteristic":false},{"displayName":"Serial Number","UUID":"00000030-0000-1000-8000-0026BB765291","props":{"format":"string","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pr"]},"value":"Default-SerialNumber","eventOnlyCharacteristic":false}]},{"displayName":"PlayStation","UUID":"00000049-0000-1000-8000-0026BB765291","characteristics":[{"displayName":"Name","UUID":"00000023-0000-1000-8000-0026BB765291","props":{"format":"string","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pr"]},"value":"PlayStation","eventOnlyCharacteristic":false},{"displayName":"On","UUID":"00000025-0000-1000-8000-0026BB765291","props":{"format":"bool","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pr","pw","ev"]},"value":false,"eventOnlyCharacteristic":false}]}]}]

jarrah31 commented 7 years ago

@luisiam I too have the same problem, as does someone else on this forum thread: https://community.home-assistant.io/t/homekit-location-to-trigger-automations-in-home-assistant-using-a-software-switch-requires-no-homekit-hardware/17235/62?u=jarrah

This is using the HASSIO image on a Raspberry Pi, with Homebridge installed as a plugin. It seems to be a repeatable bug so happy to help troubleshoot.

From your earlier post I'm not sure what you mean by going to http://ip:port/accessories and check which accessory is having the same UUID? I've tried using my HASSIO IP:Port but that didn't work.

I have the following extra lines in /config/homebridge/config.json

, {
      "platform": "cmdSwitch2",
      "name": "CMD switch",
      "switches": [{
        "name": "User isHome",
        "on_cmd": "/config/homebridge/userhome.sh",
        "off_cmd": "/config/homebridge/useraway.sh",
        "state_cmd": "/config/homebridge/userstatus.sh",
        "polling": "true"
      }]
    }

Before I restart home bridge I have to remove the cache file as you suggested above:

rm /config/homebridge/accessories/cachedAccessories

Is this a cmdswitch2 or homebridge issue?

My error looks like this:

[9/4/2017, 5:42:18 PM] Loaded config.json with 0 accessories and 2 platforms.
[9/4/2017, 5:42:18 PM] ---
[9/4/2017, 5:42:18 PM] Loading 2 platforms...
[9/4/2017, 5:42:18 PM] [HomeAssistant] Initializing HomeAssistant platform...
[9/4/2017, 5:42:18 PM] [HomeAssistant] Fetching HomeAssistant devices.
[9/4/2017, 5:42:18 PM] [CMD switch] Initializing cmdSwitch2 platform...
[9/4/2017, 5:42:18 PM] Loading 0 accessories...
[9/4/2017, 5:42:18 PM] [CMD switch] Initializing platform accessory 'User isHome'...
/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:256
      throw new Error("Cannot add a bridged Accessory with the same UUID as another bridged Accessory: " + existing.UUID);
      ^
Error: Cannot add a bridged Accessory with the same UUID as another bridged Accessory: 3dd34efe-097b-4b8b-a688-352f08cd38d6
    at Bridge.Accessory.addBridgedAccessory (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:256:13)
    at Bridge.Accessory.addBridgedAccessories (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:282:10)
    at Server._handleRegisterPlatformAccessories (/usr/lib/node_modules/homebridge/lib/server.js:437:16)
    at Server.<anonymous> (/usr/lib/node_modules/homebridge/lib/server.js:36:10)
lorenzo999 commented 6 years ago

I used cmdswitch2 for months with no problems. Recently I did a fresh install on my Raspberry Pi 3 and now I got this error. I switched to deprecated version cmdswitch temporarily, hope this error will disappear in the future.

Is there any other homebridge plugin to run bash command lines?

TheTherminator commented 6 years ago

That seems to be a problem with an existing UUID. Stop homebridge, create a backup of your persist folder (better safe than sorry) and delete all the files in that folder, then restart home bridge. If that does not work, do the same with the Accessories Folder. (That should be your last resort, because then you have to pair and rename all your devices again).

lorenzo999 commented 6 years ago

I tried again to do clear the cached stuff and I found out the first error in daemon.log is the following:

child_process.js:380
throw new TypeError('"file" argument must be a non-empty string');

My config.json in platform is the following:

"platforms":[
        {
        "platform":"cmdSwitch2",
        "name": "CMD Switch",       
        "switches":[
            {
                "name":"Leddy",
                "on_cmd":"~/433Utils/RPi_utils/codesend 1361",
                "off_cmd":"~/433Utils/RPi_utils/codesend 1364"
            }

        ]
         }
    ]

Any ideas? :|

TheTherminator commented 6 years ago

Currently not on my desk ... have you tried to validate your config.json here? https://jsonlint.com

lorenzo999 commented 6 years ago

Yes I did, the config.json is a valid json.

casouri commented 6 years ago

I ran into the same issue. Apparently cmdswitch2 wants you to provide a "state_cmd". And it will call it on start up. Adding "state_cmd" solves the problem for me.

lorenzo999 commented 6 years ago

THANK YOU!

That was the problem. Since I don't have a real state command I just added this below my "Off" command: "state_cmd": "ping -c 2 -W 1 192.168.1.1 | grep -i 'poo'" and it worked!

maldeS commented 6 years ago

After I switched from docker to a Raspberry running homebridge it worked fine for several weeks. For whatever reason it stopped and i have the same error as mentioned above.

Had already a state:

    "platform": "cmdSwitch2",
"switches": [{
    "name": "PlayStation",
    "on_cmd": "sudo ps4-waker",
    "off_cmd": "sudo ps4-waker standby",
    "state_cmd": "sudo ps4-waker search | grep -i '200 Ok'",
    "polling": true,
    "interval": 5,
    "timeout": 2000,
    "manufacturer": "Sony Corporation",
    "model": "CUH-1001A",
    "serial": "<myserial>"

Json is valid and verified. Thanks for your help.

RobotLimeLtd commented 6 years ago

In my case, the problem was an additional entry for one of my Logitech Harmony Hubs. To fix, I simply pasted the entire contents of accessories/cachedAccessories into a JSON formatter, removed the redundant section, then pasted those contents back into the original file.

It was pretty easy to tell which HarmonyHub entry was defective - it was the one with lots of "null" values for everything.

I wonder if this can happen if your devices are using DHCP, and are suddenly assigned a new IP address?

xMadNet commented 6 years ago

Homebridge installed Plugin 1/homebridge-garage-gate-opener 2/homebridge-camera-rpi
3/homebridge-hs100 => Run ok Add homebridge-netatmo-schmittx ==>Cannot add a bridged Accessory with the same UUID as another bridged Accessory Purge cache, => Still don't work. name in config.json are all different Please help

TheTherminator commented 6 years ago

Delete persist folder and accessories folder and restart homebridge

Best, TT

On Mar 9, 2018, at 13:57, xMadelain notifications@github.com wrote:

Homebridge installed Plugin 1/homebridge-garage-gate-opener 2/homebridge-camera-rpi 3/homebridge-hs100 => Run ok Add homebridge-netatmo-schmittx ==>Cannot add a bridged Accessory with the same UUID as another bridged Accessory Purge cache, => Still don't work. name in config.json are all different Please help

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

xMadNet commented 6 years ago

Hi Already done Purge all (persist and accessories), Stop hb, restart alwas same error Seem to have an incompatibility between HS100 and homebridge-netatmo-schmittx why do I have same UUID with different type of platform and names ? Regards

willyk0 commented 6 years ago

Same problem here. Moving to homebridge-cmd4.

shereefalkady commented 5 years ago

i realized i have that problem when i am running homebridge on a virtual machine - connected to the network through a virtual switch... does that tell anyone anything

alextop30 commented 4 years ago

So I was experiencing this issue so I went through my devices and noticed there are two sensors with the same name - changed the name restarted homebridge and it worked. Hope this helps!

shamasis commented 4 years ago

Same issue here. Duplicate UUID error and only after a restart of homebridge. I will investigate further once I have more time (I have a lot of plugins to go through.) However, my hunch is that the accessory UUID generation method is clashing with common code across separate modules.