mfucci / node-matter

Matter protocol client / server for node.js
Apache License 2.0
118 stars 11 forks source link

Pairing with Alexa not working #159

Closed JimBuzbee closed 1 year ago

JimBuzbee commented 1 year ago

Log file attached. alexa.txt

mfucci commented 1 year ago

Can you try if you can pair with the branch containing the iOs fixes? "support-ios"

I was able to pair with iOs with this branch but most of the fixes in it are too hacky to be able to merge them as is

JimBuzbee commented 1 year ago

Log from from the iOS branch. In the app, it takes quite a while before it finally fails up with: "Is this device set up for control with another assistant or app?"

Log File attached alexa1.txt

mfucci commented 1 year ago

The commissioning seems to have been successful per node-matter logs: GeneralCommissioningClusterHandler Commissioning completed on fabric #43153954716076642 as node #009E91B49E9051D0.

iOs actually does multiple commissioning in a row, so maybe this is what is failing.

The last action seems to read the features of the NetworkCommissioningCluster to check which connectivity is supported on the device. Not implemented yet in the main branch, I will send a MR shortly to fix this.

mfucci commented 1 year ago

Created https://github.com/mfucci/node-matter/pull/162

Can you try with this branch "define-network-cluster"? Now the last read of attribute 0/49/65532 should return the correct value.

I don't have an Alexa device on my side so I will rely on you for the testing. Hopefully I will be able to debug all the issues in 3 / 4 rounds of fixing.

JimBuzbee commented 1 year ago

Here's a run from the "define-network-cluster" branch. I'm still getting the same failure message from the app.

If it would help, I'd be glad to send you an Alexa "Dot" as thanks for your work. Just send me your info.

alexa2.txt

mfucci commented 1 year ago

Thanks for offering to send me a "Dot"! Let me merge down all the fixes I did to support iOs and there is some chance that it will work as well for Alexa. I will let you know when pairing with an iPhone is working in master, probably in a couple of days.

mfucci commented 1 year ago

I remember that I was stuck at the same step you are now with Alexa when debugging iOs... And Android / iOs / Alexa are all using the same codebase to implement the controller so behave in a similar way.

JimBuzbee commented 1 year ago

Nice work! I just cloned add-android-support and Alexa now works! Very cool to say "Alexa, turn on light" and have it reply "ok" and see node-matter respond appropriately.

I do see an error in the log (attached) and I would guess persistence is not there yet? i.e. I have to delete the Alexa device and re-commission every time I start the node-matter server. If I don't, I see messages like the following:

2023-0-4 7:42:3.619 INFO Device node-matter@0.0.11 2023-0-4 7:42:3.698 INFO Device Listening ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ █ ▄▄▄▄▄ ██▀▄▀▄█ ▄▄▄▄▄ █ █ █ █ █▄▀▄▀▄█ █ █ █ █ █▄▄▄█ ██ ▀▀▄█ █▄▄▄█ █ █▄▄▄▄▄▄▄█ █ ▀▄█▄▄▄▄▄▄▄█ █▄ ▄█▄ ▄▄ ▀ █ ▄▀██ █▀█ ██ █▀▀ ▄▄█ █ ▀▄▄██ ▀█▀█ █▄▄████▄▄▄▀▄▀ ▀██▄▄▀▄▀█ █ ▄▄▄▄▄ █ ▄█▄█▄▄█▄ █ █ █ █ █ █▄▀▀█▄ ▄▀▀▄ ▀██ █ █▄▄▄█ █ ▀█▄█ ▀█ ▀ █ █▄▄▄▄▄▄▄█▄█▄█▄██▄██▄█▄█ ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀

QR Code URL: https://project-chip.github.io/connectedhomeip/qrcode.html?data=MT:Y.K90AFN00KA0648G00 Manual pairing code: 34970112332 2023-0-4 7:42:3.919 ERROR ExchangeManager Error: Cannot find a session for ID 55274

2023-0-4 7:42:5.412 DEBUG MessageExchange onMessageReceived id:0/54877/205441394 t:0/48 reqAck:true payload: 15300120a999c1636e2e6fe11c50a11e93cb79461048b590671d8d2c8d9c596eb4e8f2ee2502a5d8300320d9fb5c54de33a95e712719af9b6626a4835691cc16d81a6fa8b09fc1e5c51bdf300441047a593180860c4037c83c12749845c8ee1424dd297fadcb895e358255d2c7d2b2a8ca25580f2626fe579062ff1b99ff91c24a0da06fb32b5be20148c9249f565030061013fccb420c8fa77b3fcc3065e5f4e43c300710c62512664d0c3821b5d48539b0d94ad218 2023-0-4 7:42:5.418 INFO CaseServer Case server: Received pairing request from udp://192.168.1.44:5541 2023-0-4 7:42:5.427 ERROR CaseServer An error occured during the commissioning Error: Fabric cannot be found from destinationId 2023-0-4 7:42:5.433 DEBUG ExchangeManager sending id:0/54877/3773895937 t:0/64 acked:205441394 reqAck:true payload: 0100000000000200 2023-0-4 7:42:5.487 DEBUG MessageExchange onMessageReceived id:0/54877/205441395 t:0/16 acked:3773895937 reqAck:false payload:

....

alexa3.txt

Apollon77 commented 1 year ago

woo ... awesome!

mfucci commented 1 year ago

@JimBuzbee : correct, persistence is not implemented yet... I will close as fixed then.

Is there a screenshot of some interface showing node-matter paired that you can take and attach here? Just to prove to non-believer that it indeed works :-)

JimBuzbee commented 1 year ago

Here's an Android Alexa screenshot after node-matter has been added. image

mfucci commented 1 year ago

Thanks!

Apollon77 commented 1 year ago

@JimBuzbee Is it the "normal" Alexa App on Android? which version exactly is that? Maybe I can also try if my "one alexa device in the whole house" can install that one? ;-)

JimBuzbee commented 1 year ago

@Apollon77 Yes, that is the normal Alexa app, version 2022.21. It is also the only Alexia device i have in the house for me as I typically use Google Home.

I'm not clear on the Matter infrastructure. Does anyone know if we'll be able to control a node-matter "device" from both the Alexa app and Google home app? And what is the vision for commissioning multiple virtual devices through node-matter? Multiple QR codes?

Apollon77 commented 1 year ago

Spec wise it should work to pair a device with multiple controllers ... I think this would be on of the "the next thing" to try now that @mfucci managed to pair in general. Now it could be tried to pair an already paired node-matter with a second controller.

And what is the vision for commissioning multiple virtual devices through node-matter? Multiple QR codes?

Because of the fact that node-matter offers "one device" the next step is to add support to offer "bridged devices". With this node-matter is paired as "one device" and offers "multiple bridged devices" ... it is like what the hue bridge and such will do. I will prepare the needed clusters for this next ...

JimBuzbee commented 1 year ago

Cool. I really appreciate the work you guys are doing. It fits my needs well to think of node-matter (or uses of it) as a bridged device like a Hue bridge etc. I have lots of older devices such as Wemo, Govee, etc. that will never see official Matter support and I also have a lot of custom IOT devices. All of which I can control locally via custom code, so they should be easy to integrate to node-matter in some fashion. It would be great to unify everything. I might even dig up some old X10 devices fo kicks. Wouldn't it be funny to integrate 1970s technology into Matter :-)

Apollon77 commented 1 year ago

My alexa on my Tablet shows version 2.2.490414.0 from 7.12. .... android 8 and older.

Apollon77 commented 1 year ago

@JimBuzbee my goal is to integrate it as Bridge and controller into iobroker as plugins. So then all iobroker devices and stuff is available as bridged devices and it can also pair other matter compatible devices. Let's see how all that goes ;-)

JimBuzbee commented 1 year ago

@Apollon77 - Here's a screenshot of the "about" screen on my Alexa app, running on Android 13. image

Apollon77 commented 1 year ago

Then the same cool. So I can also try my wall Tablet to pair. ;-))

Apollon77 commented 1 year ago

Verified it :-) Cooool

javierbarellano4v commented 1 year ago
  1. When you pair, are you using the manual code 34970112332 (alternatively visible QrCode) or 20202021?
  2. Do you have to have an Alexa device in the network, e.g. Echo?

Thanks!

JimBuzbee commented 1 year ago

I used the QR code. The only Alexa device I have on the network is an Echo Dot, 3rd gen.

javierbarellano4v commented 1 year ago

Gotcha. Thanks. Think I need to get a Alexa device in my network to be able pair, it appears. Appreciate all updates in this thread.

javierbarellano4v commented 1 year ago

@JimBuzbee, forgot to ask, are you running node-matter on a Raspberry Pi, MacBook or ? Thanks.

JimBuzbee commented 1 year ago

@javierbarellano4v - I've been switching back and forth a bit between a Raspberry Pi and a Macbook. I think when I was doing the Alexa testing, I was using the Pi. Most recently I've been only using a MacBook with Google Home, not Alexa.

javierbarellano4v commented 1 year ago

@JimBuzbee Thanks.

In terms of Alexa, when you added a Matter device with Alexa App on Android, did you add it as a "Other" device and then selecting 'Matter' as the connection type which then prompts "Does your device have a Matter logo?"

JimBuzbee commented 1 year ago

Yes - That is the path I took. Selected "Yes" then "Scan Qr Code", then scan code.

Apollon77 commented 1 year ago

In fact the "longer" manual pairing code (34970112332 from above) is in the QR code too, so use this one

javierbarellano4v commented 1 year ago

@JimBuzbee @Apollon77 Successfully paired (used QrCode) node-matter running on MacBook in my home environment once I setup my Alexa Echo Dot. Upon success, Alexa Echo Dot audibly confirmed adding a "light bulb.."

Initially, had trouble but the Alexa app on my Android table, recommended to "reconnect" my matter-enabled device so I relaunched node-matter and bingo! It discovered it, paired it. Able to instruct Alexa Echo Dot to turn off and on the "light bulb"

Very cool!

node-matter/MacBook Alexa app/Android tablet Alexa hub/Echo Dot

Apollon77 commented 1 year ago

@JimBuzbee Hey, I tested today again with Alexa and was surprised because pairing was no longer possible ... It stops when handling the certificate signing ... It seems to me they blocked self-signed (aka Development) devices which would be really bad ...

From what I can see is that some days ago I updated to a new Alexa App on my Tablet ... If you have time it would be awesome if you could also check it and verify that ...

@mfucci @turon FYI

JimBuzbee commented 1 year ago

Playing with it now - not having much luck. The app itself seems to hang up. I see lots of "odd" messages from "adb logcat | grep -i amazon" :

02-03 17:01:04.434 7413 7515 E Metrics:NonVolatileBoun: remove - Unable to delete the file./data/user/0/com.amazon.dee.app/app_NORMAL_ANONYMOUS/1675468157553: open failed: ENOENT (No such file or directory); 02-03 17:01:04.434 7413 7515 E Metrics:BatchTransmitte: QueuePusher.sendBatches - Unable to send NORMAL_ANONYMOUS queue batchesjava.io.FileNotFoundException: /data/user/0/com.amazon.dee.app/app_NORMAL_ANONYMOUS/1675468157553: open failed: ENOENT (No such file or directory); 02-03 17:01:07.523 7413 7951 W .amazon.dee.app: Cleared Reference was only reachable from finalizer (only reported once) 02-03 17:01:07.577 7413 7951 I .amazon.dee.app: Explicit concurrent copying GC freed 535979(26MB) AllocSpace objects, 310(9120KB) LOS objects, 50% free, 27MB/55MB, paused 242us,725us total 448.424ms 02-03 17:01:07.756 7413 7427 W SQLiteConnectionPool: A SQLiteConnection object for database '/data/user/0/com.amazon.dee.app/databases/AlertRecords.db' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed. 02-03 17:01:07.822 7413 7951 I .amazon.dee.app: Explicit concurrent copying GC freed 1469(117KB) AllocSpace objects, 0(0B) LOS objects, 50% free, 27MB/55MB, paused 155us,252us total 234.344ms 02-03 17:01:07.984 7413 7951 I AlarmAuthTokenManager: Cancelling alarm with actioncom.amazon.comms.ringservice.ACTION_AUTH_TOKEN_ALARM

JimBuzbee commented 1 year ago

Got it to try, but failed. "adb logcat | grep -i matter" showed a bunch of messages like so (I modded session id with XXX):

02-03 17:13:29.184 17230 17474 I [ELEMENTS]: [matter-provisioning] making network request for: {"path":"https://alexa.amazon.com/api/gordonservice/v1/sessions/XXXXXXX/checkPairingStatus","queryParameters":{"commissionSessionID":"XXXXXXXX"}} 02-03 17:13:29.329 17230 17474 I MobilyticsMetricsServic: react.lmnt.smart-home.matter.pairingStatus.responseTime.mobilytics-operational latency 0.136 seconds 02-03 17:13:29.330 17230 17474 I [ELEMENTS]: [matter-provisioning] ALPHA DEBUG: pairingStatusHelper: rawResponse: {"endpointId":null,"failureReason":"COMMISSIONER_FAILURE_INTERNAL_ERROR","pairingStateInfo":{"detailedState":"PASE_SESSION_FAILED","userInputInfo":null},"pairingStatus":"FAILED"} 02-03 17:13:29.330 17230 17474 I [ELEMENTS]: [matter-provisioning] ALPHA DEBUG: PairingStatus response: {"endpointId":null,"failureReason":"COMMISSIONER_FAILURE_INTERNAL_ERROR","pairingStateInfo":{"detailedState":"PASE_SESSION_FAILED","userInputInfo":null},"pairingStatus":"FAILED"} 02-03 17:13:29.330 17230 17474 E [ELEMENTS]: [matter-provisioning] pollPairingStatus: pairing failed with failureReason: COMMISSIONER_FAILURE_INTERNAL_ERROR 02-03 17:13:29.332 17230 17474 I [ELEMENTS]: [matter-provisioning] updateManagerStateAndPublish is called with state SETUP_ERROR 02-03 17:13:29.338 17230 17474 I [ELEMENTS]: [matter-provisioning] publishToEventBus: chipProvisioning publishing event: Matter:GD:StatusUpdate 02-03 17:13:29.348 17230 17474 I [ELEMENTS]: [guided-discovery] Recieved matter state change event with message: {"uuid":"aacf922c-8326-4110-8367-de07e707ddd9","source":"Local","eventType":"Matter:GD:StatusUpdate","date":null,"ttl":0,"payload":"{\"message\":\"chipManager state is updated\"}"}

JimBuzbee commented 1 year ago

Finally got a coherent response from Alexa. Something has definitely changed. Here's the logcat error followed by the Alexa screenshot

02-03 17:53:06.396 30894 3599 I [ELEMENTS]: [matter-provisioning] ALPHA DEBUG: pairingStatusHelper: rawResponse: {"endpointId":null,"failureReason":"COMMISSIONER_FAILURE_UNSUPPORTED_DEVICE","pairingStateInfo":{"detailedState":"PASE_SESSION_ESTABLISHED","userInputInfo":null},"pairingStatus":"FAILED"} 02-03 17:53:06.396 30894 3599 I [ELEMENTS]: [matter-provisioning] ALPHA DEBUG: PairingStatus response: {"endpointId":null,"failureReason":"COMMISSIONER_FAILURE_UNSUPPORTED_DEVICE","pairingStateInfo":{"detailedState":"PASE_SESSION_ESTABLISHED","userInputInfo":null},"pairingStatus":"FAILED"} 02-03 17:53:06.396 30894 3599 E [ELEMENTS]: [matter-provisioning] pollPairingStatus: pairing failed with failureReason: COMMISSIONER_FAILURE_UNSUPPORTED_DEVICE 02-03 17:53:06.397 30894 3599 I [ELEMENTS]: [matter-provisioning] updateManagerStateAndPublish is called with state MATTER_DEVICE_NOT_SUPPORTED 02-03 17:53:06.397 30894 3599 I [ELEMENTS]: [matter-provisioning] publishToEventBus: chipProvisioning publishing event: Matter:GD:StatusUpdate

Screenshot_20230203-174550

Apollon77 commented 1 year ago

COMMISSIONER_FAILURE_UNSUPPORTED_DEVICE looks like that :-(

Can you try to go back to the Alexa App version we had beginning january? I think was one of the december ones?

And thank you very much for all your support!

JimBuzbee commented 1 year ago

I uninstalled the Alexa app and went to the Google Play store to re-install. Now it works again. There was an option on the play store Alexa page to allow automatic updates, so I unchecked that - hope it wasn't for all apps and hope Alexa can't bypass. We'll see. Screenshot of Alexa version

Screenshot_20230204-063347

Apollon77 commented 1 year ago

Interesting ... i have the same version of the app ... but ok ... I will try again now ... too

JimBuzbee commented 1 year ago

Mine started failing again. Uninstalled and reinstalled twice without success.

Apollon77 commented 1 year ago

:-( COuld you try the version of alexa app from end december

Apollon77 commented 1 year ago

PS: Are you on discord? Please send me your Username

s-hadinger commented 1 year ago

I'm curious about the Alexa devices you have. When I try, the requests don't come from the Android app but from my Fire TV. Could it be possible that it's linked to the version of the Alexa devices?

Apollon77 commented 1 year ago

This could also be the case ... then it would be not the App but a "Firmware" and we have no chance to workaround it ... Honestly never did look at the IP :-)

JimBuzbee commented 1 year ago

@s-hadinger - The only Alexa device I have on my network is an Echo Dot.

@Apollon77 - I went back to version 2022.21 and still failed The "adb logcat" file looks the same or similar during an attempt. I see a call to "checkPairingStatus" on https://alexa.amazon.com/api/... followed by a debug message of failureReason":"COMMISSIONER_FAILURE_UNSUPPORTED_DEVICE" - Leads me to believe the significant change was on the Amazon server side - wonder if they started using a similar "developer" setup to Google where you need to register your development "device"

discord - have not used it.

Apollon77 commented 1 year ago

I would more asume a "Firware update of the Echo devices" ... but yes :-( Difficult ... I did not heared of any dev dloper account things so far.

Discord more like a "chat tool"

JimBuzbee commented 1 year ago

FYI - I successfully paired "Device.js" with Alexa using main as of Feb 7 - Not sure what to make of the inconsistencies.

JimBuzbee commented 1 year ago

Alexa app version 2023.3 build 2.2.495391.0

s-hadinger commented 1 year ago

Thanks for reporting this good news. I can't test this week, but I'm eager to see what changed. Could you also report the version of your echo device?

JimBuzbee commented 1 year ago

It's an Echo Dot 3rd Gen, software version:

8289070468

s-hadinger commented 1 year ago

Thanks. Mine is still at 8289069444

Apollon77 commented 1 year ago

I will check tomorrow ...