NorthernMan54 / homebridge-alexa

Expose your homebridge controlled devices to Amazon Alexa.
https://www.homebridge.ca
455 stars 68 forks source link

Alexa Discovers Duplicate Devices #97

Closed brentleeper closed 5 years ago

brentleeper commented 6 years ago

Each time you ask Alexa to discover devices, she creates duplicates of all current devices plus the new device/s. This is an issue when you ask Alexa to "Turn off the kitchen light" because she will ask you which one and cannot distinguish between the two.

This occurs after stoping Homebridge, adding a new accessory in config.json, starting Homebridge, and then asking Alexa to discover devices.

Darko2 commented 6 years ago

I have the same issue. My workarround was deleting all devices on Alexa website, then discover again. But its a bad way to do it as you have to setup all your Routines again.

NorthernMan54 commented 6 years ago

Give me a couple of days on this, I need to look at how it linking the HomeBridge devices to Alexa devices and think you have uncovered a couple of use cases that cause issues.

brentleeper commented 6 years ago

It appears each device is assigned to a random port number at each HomeBridge start up. I haven’t had an opportunity to view the source but could it be as simple as storing each device’s originally assigned port number and checking if each device was previously assigned a port at HomeBridge start?

Thanks

jak1502 commented 6 years ago

I am also getting this with the homebridge-zp plugin. I think its probably due to it setting new IDs on the fly.

NorthernMan54 commented 6 years ago

For the Alexa integration, I'm creating a user unique identifier for each device made up of

host - aka IP of homebridge instance port - port of homebridge instance aid - HomeKit Accessory Instance ID iid - HomeKit Service and Characteristic Instance ID

If any of these change, Alexa will think its a new accessory.

And based on what your saying, it appears that the plugin is changing the AID and IID. If this was happening, I thought that the accessories would also move to the default room at the same time, are you seeing this?

Also I'm surprised that the plugin is changing the AID and IID, as I thought this was against the HAP Spec.

jak1502 commented 6 years ago

I thought that might be the case but no I’m not seeing new devices in HomeKit, they stay static.

NorthernMan54 commented 6 years ago

When your running homebridge, do you have the port set in every config.json?

On May 31, 2018, at 1:06 AM, jak1502 notifications@github.com wrote:

I thought that might be the case but no I’m not seeing new devices in HomeKit, they stay static.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/NorthernMan54/homebridge-alexa/issues/97#issuecomment-393404209, or mute the thread https://github.com/notifications/unsubscribe-auth/AS5CmDk3OS0wFpVGpIf47LqDJ488Z5SNks5t33pLgaJpZM4TzzbK.

Darko2 commented 6 years ago

Im running five homebridge instances and every one has a unique port, pin, name and username.

NorthernMan54 commented 5 years ago

One potential cause of this issue, is your homebridge server changing ip addresses or port. As part of the unique id of a device I'm including the ip address and port of your homebridge instance.

sschuste commented 5 years ago

Some additional info from me: my homebridge server never changes its IP address or the port and I only use one instance. A few weeks ago all switches were displayed twice in the Alexa app, some even three times. After I had deleted all devices using the Alexa app, the problem only remains with homebridge-zp. This is actually displayed 14 times. I can use every of the 14 switches to control my Sonos system. They all work. I hardly ever use the Alexa app, so it doesn't bother me too much.

jcwlim commented 5 years ago

I can confirm when the device IP is changed, new device will discover then the old device can't be control (become unresponsive in Alexa app). Possible to use MAC address as a identifier so it won't duplicate new device and still able to control when IP is different?

NorthernMan54 commented 5 years ago

The current endpoint identifier code is

https://github.com/NorthernMan54/homebridge-alexa/blob/dc0ba68b6856e06c8fb2af85e8acef463798d792/lib/alexaTranslator.js#L409

Which uses homebridge host and port plus the device aid/Iid

With this pattern, there also is a use case where homebridge changes the device aid/iid as well. And causes the same issue, I see that in my setup occasionally as well.

I have been thinking about changing the endpoint identifier logic, but as it would be a breaking change am rather reluctant to proceed with it.

NorthernMan54 commented 5 years ago

I was looking at my setup, as I have a single device that moves around after restart of homebridge and found that the IID was changing for the last characteristic on the device. And the plugin was using the last IID as the unique endpoint ID.

NorthernMan54 commented 5 years ago

For this issue, I have implemented a fix in the event branch of the plugin, so I will be publishing this shortly to the world. I'm waiting for the current skill back to be certified by Amazon before publishing this to the world.

For the fix, I changed the unique device key supplied to Amazon Alexa to be a combination of homebridge name, homebridge username, plugin manufacturer, accessory name and service characteristic. ( homebridge name and username are from the config.json bridge settings.) As part of updating to the newer version, you will need to have Alexa forget all your existing devices and discover again.

If this is an annoying issue for yourself, you could install a early version of this. Let me know

https://github.com/NorthernMan54/homebridge-alexa/tree/event

nicoh88 commented 5 years ago

Hi @NorthernMan54,

i had exactly this problem two weeks ago and i disable the plugin. Is the problem solved? Does the amazon skill need to be updated or only the homebridge plugin?

Is the event branch meanwhile merged into the master branch?

Many Greetings Nico

NorthernMan54 commented 5 years ago

@nicoh88 The event branch is not merged into the main branch yet. I have been completing more testing of the events module to ensure it is 100% ready for prime time prior to releasing. But it is stable enough for use, as I have been using it for a few weeks along with several others.

NorthernMan54 commented 5 years ago

This was published as the main version about a month ago, so this issue is now resolved.

bubez81 commented 5 years ago

Hello, i'm not sure this is the right place, but in the logs i can see: [2019-9-5 07:56:33] [Alexa] WARNING: Duplicate device name Zona Giorno [2019-9-5 07:56:33] [Alexa] WARNING: Duplicate device name Zona Notte they are not the same device and alexa recognize the two device separately. I can't understand what does that mean.

NorthernMan54 commented 5 years ago

What the warning is saying is that you have 2 devices named Zona Giorno and 2 devices named Zona Notte that were passed to Alexa. This is just an FYI, and if you look in the Alexa app you may find duplicate devices

bubez81 commented 5 years ago

eh...it's not true I can see only one device named Zona giorno and one Zona Notte. ...ahhh ok....in homebridge this daikin conditioner is divided into two devices, one for the split and one for the fan...maybe it's this the problem!

NorthernMan54 commented 5 years ago

That sounds like why the warning is being triggered

On Sep 5, 2019, at 1:28 PM, Michele Galanti notifications@github.com wrote:

eh...it's not true I can see only one device named Zona giorno and one Zona Notte. ...ahhh ok....in homebridge this daikin conditioner is divided into two devices, one for the split and one for the fan...maybe it's this the problem!

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or mute the thread.

bubez81 commented 5 years ago

the warning is gone....

NorthernMan54 commented 5 years ago

Cool

netzpixel commented 4 years ago

Hi, I have the following error with all my yeelights: [Alexa] WARNING: Duplicate device name Color Light [Alexa] ERROR: Parsing failed, removing duplicate endpointID => Color Light

I get this for every light and in the end I have only one light in the home app. I tried renaming them with the yeelight plugin, but no success. I renamed them everywhere I cloud find them. Any idea why this is?

Ah, forgot to mention. I use the Yeelighter plugin in homebridge.

NorthernMan54 commented 4 years ago

@BenAndDevelopment Please open as a new issue, and include a homebridge accessory dump, details are in the README. Also what plugin are you using for the yee lights ( GitHub url )

varn-lt commented 4 years ago

I have the same warnings with https://github.com/homebridge-plugins/homebridge-camera-ffmpeg plugin where each camera gets duplicates in Alexa:

[6/29/2020, 13:05:00] [Alexa] WARNING: Duplicate device name Garage View
[6/29/2020, 13:05:00] [Alexa] WARNING: Duplicate device name Garage View
[6/29/2020, 13:05:00] [Alexa] WARNING: Duplicate device name Parking View
[6/29/2020, 13:05:00] [Alexa] WARNING: Duplicate device name Parking View
[6/29/2020, 13:05:00] [Alexa] ERROR: Parsing failed, removing duplicate endpointID => Garage View
[6/29/2020, 13:05:00] [Alexa] ERROR: Parsing failed, removing duplicate endpointID => Parking View

and here is what I see in https://alexa.amazon.com : Capture question would be who should fix this bug homebridge-alexa or homebridge-camera-ffmpeg

NorthernMan54 commented 4 years ago

As the duplicates are camera’s they can be ignored

On Jun 29, 2020, at 8:23 AM, varn-lt notifications@github.com wrote:

 I have the same warnings with https://github.com/homebridge-plugins/homebridge-camera-ffmpeg plugin where each camera gets duplicates in Alexa:

[6/29/2020, 13:05:00] [Alexa] WARNING: Duplicate device name Garage View [6/29/2020, 13:05:00] [Alexa] WARNING: Duplicate device name Garage View [6/29/2020, 13:05:00] [Alexa] WARNING: Duplicate device name Parking View [6/29/2020, 13:05:00] [Alexa] WARNING: Duplicate device name Parking View [6/29/2020, 13:05:00] [Alexa] ERROR: Parsing failed, removing duplicate endpointID => Garage View [6/29/2020, 13:05:00] [Alexa] ERROR: Parsing failed, removing duplicate endpointID => Parking View and here is what I see in https://alexa.amazon.com :

question would be who should fix this bug homebridge-alexa or homebridge-camera-ffmpeg

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or unsubscribe.

varn-lt commented 4 years ago

I understand it but log full of warnings and errors does not look nice and correct, there should be a way how to solve it. For example there could be option where I could set list of devices I do not want to send to alexa from homebridge, so I could ignore all cameras and other unsupported devices