renssies / homebridge-am43-blinds

A homebridge plugin to control the AM43 based blind motors in HomeKit
MIT License
18 stars 6 forks source link

Duplicate Devices #9

Open sholeh86 opened 3 years ago

sholeh86 commented 3 years ago

I am trying to link this plugin with alexa, and get this error. I think it has to do with the way the plugin names the devices. Is there any way to change that? I have 4 blinds and it recognizes the first one.

[8/30/2020, 22:05:30] [Alexa] WARNING: Duplicate device name AM43 Blind Motor [8/30/2020, 22:05:30] [Alexa] WARNING: Duplicate device name AM43 Blind Motor [8/30/2020, 22:05:30] [Alexa] WARNING: Duplicate device name AM43 Blind Motor [8/30/2020, 22:05:30] [Alexa] ERROR: Parsing failed, removing duplicate endpointID => AM43 Blind Motor [8/30/2020, 22:05:30] [Alexa] ERROR: Parsing failed, removing duplicate endpointID => AM43 Blind Motor [8/30/2020, 22:05:30] [Alexa] ERROR: Parsing failed, removing duplicate endpointID => AM43 Blind Motor

torroa commented 3 years ago

Try using the "great" app Blind Engine on the phone or tablet you used to set up the motors. You should find the option to name the motors there.

renssies commented 3 years ago

The plugin can't change the name and I don't think it is desired to implement this in the plugin.

You can indeed use the Blinds Engine app to change the name. However, make sure you quit Homebridge before opening the blinds engine app. And quit the blinds engine app before starting homebridge.

The blinds motor can only have 1 connection and the motor won't be available until it gets disconnected from a client.

sholeh86 commented 3 years ago

The blinds are properly named.

"[8/30/2020, 22:27:20] [am43-blinds] Found known AM43 Motor: Living Room TV (02:27:47:62:3a:bd) [8/30/2020, 22:27:20] [am43-blinds] Found known AM43 Motor: Living Room Small (02:86:49:72:03:33)"

That doesn't prevent the alexa plugin from considering all them the same. I think its because the IID is the same for all the blinds as shown below which creates identical endpointIDs. I tried making multiple homebridge instances, but this plugin does not support multiple instances. There must be a way to change that IID? Where is it assigned within the code? I tried looking through it, but I have to admit I'm not that proficient.

" '{"host":"192.168.1.14","port":51925,"aid":4,"iid":9}': { '0': 'DETECTED', '1': 'NOT_DETECTED', endpointID: 'MEU6RUQ6QjQ6OTU6N0Q6OTItSG9tZWJyaWRnZSA3RDkyLXJlbnNzaWVzLUFNNDMgQmxpbmQgTW90b3ItMDAwMDAwOEMtMDAwMC0xMDAwLTgwMDAtMDAyNkJCNzY1Mjkx', template: 'ContactSensor' }, '{"host":"192.168.1.14","port":51925,"aid":5,"iid":9}': { '0': 'DETECTED', '1': 'NOT_DETECTED', endpointID: 'MEU6RUQ6QjQ6OTU6N0Q6OTItSG9tZWJyaWRnZSA3RDkyLXJlbnNzaWVzLUFNNDMgQmxpbmQgTW90b3ItMDAwMDAwOEMtMDAwMC0xMDAwLTgwMDAtMDAyNkJCNzY1Mjkx', template: 'ContactSensor' }, '{"host":"192.168.1.14","port":51925,"aid":6,"iid":9}': { '0': 'DETECTED', '1': 'NOT_DETECTED', endpointID: 'MEU6RUQ6QjQ6OTU6N0Q6OTItSG9tZWJyaWRnZSA3RDkyLXJlbnNzaWVzLUFNNDMgQmxpbmQgTW90b3ItMDAwMDAwOEMtMDAwMC0xMDAwLTgwMDAtMDAyNkJCNzY1Mjkx', template: 'ContactSensor' } ] 2020-08-31T09:09:40.578Z alexaActions Event Register 192.168.1.14:51925 -> { characteristics: [ { aid: 2, iid: 9, ev: true }, { aid: 4, iid: 9, ev: true }, { aid: 5, iid: 9, ev: true }, { aid: 6, iid: 9, ev: true }

renssies commented 3 years ago

The iid is suppose to be the same. IID stands for the characteristic also known as a feature of the device. Since both motors have the same features the ID is supposed to be the same. t

The AID (Accessory ID) is supposed to be unique.

I can't seem to figure out why you are getting this error. Maybe the maker of the Alexa plugin can help you out, feel free to report back here if they found something.

The name generation code can be found here: https://github.com/renssies/homebridge-am43-blinds/blob/ab9365b701c0cf89e501f3b8a746a85f8d9a28ff/lib/AM43Device.js#L30 localName is supposed to be the name you've set in the blinds engine app.

neil-morrison44 commented 3 years ago

HomeKit also calls each device "AM43 Motor" in the UI rather than the name given to it by Blinds Engine - I managed to change it in my experimental branch but I wasn't 100% sure if it was correct since, as you say, it's naming the characteristic.

But with multiple blind motors in the same room you need some way of differentiating them

It could make sense to have the option available in the config of assigning a name to a motor ID - stop people having to open Blinds Engine to rename devices. Not sure though Something like:

output: [
  { name: "Window 1", motor: "03:7b:12:60:53:ad" }
]

(could also allow for future features where multiple motors are exposed as one accessory to support 2 cord blinds)

renssies commented 3 years ago

That would be a nice workaround indeed.

How would you do the JSON syntax to combine 2 motors for the same blind?

Even if the plugin doesn't support it yet it might be good to already have the syntax for it so old configs work with newer versions of the plugin.

neil-morrison44 commented 3 years ago

I was thinking along the lines of supporting motor then adding support for motors where it's something like:

output: [
  { name: "Window 1", motors: { pull: "03:7b:12:60:53:ad", tilt: "04:7b:12:60:53:ad"  } }
]

Though, just had a look through the Apple HomeKit docs and they seem to call them "slats" so something like:

output: [
  { name: "Window 1", motor: "03:7b:12:60:53:ad", slats: { verticalTilt: "04:7b:12:60:53:ad" } }
]

Where either verticalTilt or horizontalTilt would set the HMCharacteristicValueSlatType & match the names used for Tilting Mechanisms

renssies commented 3 years ago

The first one looks the best to me, but do keep in mind that the motor mac address might not be available on all systems. macOS doesn't give Noble access to the mac address, so it uses the ID instead.

Also, output might not be the best config key.

neil-morrison44 commented 3 years ago

Yeah, output probably isn't the best Also the tilt in the first one would probably need to be either horizontalTilt or verticalTilt.

Didn't realise that about the MAC address on Macs, I guess it'd just need to match whatever goes into the allowed_devices list there

Jacksonbm1 commented 2 years ago

This is an old thread, but I have this issue as well. I tried renaming my devices in the blind motor app and it didn't work. Basically both alexa and node red think they're the same device which makes it really hard to do what I want with them. Any solutions?