NorthernMan54 / homebridge-alexa

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

Invalid PIN - PINs matching #480

Open colparkes1 opened 2 years ago

colparkes1 commented 2 years ago

Hi, thanks very much for making this plugin. I’m using it to control some Somfy blinds in conjunction with the homebridge-rpi-RTS plugin. Something strange is happening when I issue a command from Alexa, it will sometimes work fine, and I see a corresponding log message in homebridge.log

[18/12/2021, 10:20:26] [Alexa] PowerController TurnOn DD:22:3D:E3:CE:30 undefined null

I can try it again shortly afterwards and get an invalid PIN message

[18/12/2021,` 11:16:01] [Alexa] PowerController TurnOn DD:22:3D:E3:CE:30 undefined Error: Homebridge auth failed, invalid PIN 031-45-155

Initially I had the default PIN for the Alexa plugin and the main Homebridge process (031-45-154). I tried changing both to 155 as shown above in the log file, it worked for a few commands then the PIN errors returned.

Something I did notice was that I also tried changing the Homebridge username to CC:22:3D:E3:CE:30 in my config.json (through the config-ui plugin). After restarting homebridge the username was still showing as DD:22:3D:E3:CE:30 as if it was cached somewhere?

I’m running a standard homebridge installation in all of the default locations (/var/lib/homebridge) on a Raspberry Pi 2 running Bullseye.

Here’s my /var/lib/homebridge/config.json

{ "bridge": { "name": "Homebridge", "username": "DD:22:3D:E3:CE:30", "port": 51826, "pin": "031-45-155" }, "description": "blah blah.", "platforms": [ { "platform": "LightWaveRF", "name": "LightWaveRF", "ip_address": "192.168.1.5", "manager_host": "web.trustsmartcloud.com", "email": "home@***com", "pin": "", "devices": [ { "roomId": 1, "roomName": "Garage", "deviceId": 1, "deviceName": "Door", "deviceType": "S" }, { "roomId": 3, "roomName": "Back Garden", "deviceId": 1, "deviceName": "Lights", "deviceType": "S" }, { "roomId": 3, "roomName": "Back Garden", "deviceId": 2, "deviceName": "Sprinkler Upper", "deviceType": "S" }, { "roomId": 3, "roomName": "Back Garden", "deviceId": 3, "deviceName": "Sprinkler Centre", "deviceType": "S" }, { "roomId": 3, "roomName": "Back Garden", "deviceId": 4, "deviceName": "Sprinkler Patio", "deviceType": "S" }, { "roomId": 3, "roomName": "Back Garden", "deviceId": 5, "deviceName": "Pergola Lights", "deviceType": "S" }, { "roomId": 4, "roomName": "Front Garden", "deviceId": 1, "deviceName": "Lights", "deviceType": "S" } ] }, { "name": "Config", "port": 8581, "platform": "config" }, { "name": "Alexa", "username": "colin@****.co.uk", "password": "Dgffggghh”, "routines": false, "blind": true, "door": false, "debug": false, "deviceListHandling": "allow", "pin": "031-45-155", "platform": "Alexa" } ], "accessories": [ { "name": "Lounge Left", "id": 1000001, "prog": false, "accessory": "Somfy RTS Remote" }, { "name": "Lounge Right", "id": 1018617, "prog": false, "accessory": "Somfy RTS Remote" }, { "name": "Lounge Both", "id": 1857477, "prog": true, "accessory": "Somfy RTS Remote" } ] }

Very much appreciate any help you can give,

Col

NorthernMan54 commented 2 years ago

On the amazon Alexa side she caches a copy of your configuration so she knows what devices you have and how to reach them. If you change your configuration ask her to discover devices again, and she will refresh the cache.

colparkes1 commented 2 years ago

Hi, thanks for the reply. I’d already tried deleting and rediscovering my devices. They worked initially but then the PIN error returned. I’ll do some more testing tomorrow to see if I can really nail down the circumstances where it happens, thanks, Col

colparkes1 commented 2 years ago

I think it’s something to do with Alexa discovery? If I restart the Homebridge process, I can issue commands through Alexa for 15 minutes, after this I get the error messages.

[21/12/2021, 12:25:18] Homebridge v1.3.8 (HAP v0.9.7) (Homebridge) is running on port 51826. [21/12/2021, 12:25:34] [Alexa] alexaDiscovery - returned 18 devices [21/12/2021, 12:25:50] [Alexa] PowerController TurnOn DD:22:3D:E3:CE:30 undefined null [21/12/2021, 12:26:08] [Alexa] PowerController TurnOn DD:22:3D:E3:CE:30 undefined null [21/12/2021, 12:27:16] [Alexa] PowerController TurnOn DD:22:3D:E3:CE:30 undefined null [21/12/2021, 12:27:23] [Alexa] PowerController TurnOn DD:22:3D:E3:CE:30 undefined null [21/12/2021, 12:37:12] [Alexa] PowerController TurnOn DD:22:3D:E3:CE:30 undefined null [21/12/2021, 12:37:23] [Alexa] PowerController TurnOn DD:22:3D:E3:CE:30 undefined null [21/12/2021, 12:41:09] [Alexa] PowerController TurnOn DD:22:3D:E3:CE:30 undefined Error: Homebridge auth failed, invalid PIN 031-45-155 at HAPNodeJSClient. (/usr/lib/node_modules/homebridge-alexa/node_modules/hap-node-client/HAPNodeJSClient.js:298:18) at Request._callback (/usr/lib/node_modules/homebridge-alexa/node_modules/lodash/lodash.js:10118:25) at Request.requestRetryReply [as reply] (/usr/lib/node_modules/homebridge-alexa/node_modules/requestretry/index.js:115:19) at Request. (/usr/lib/node_modules/homebridge-alexa/node_modules/requestretry/index.js:156:10) at processTicksAndRejections (node:internal/process/task_queues:96:5)

colparkes1 commented 2 years ago

I set the refresh interval in the Alexa plugin down to 300 and the issue started happening after 5 minutes instead of 15. I raised the refresh interval to 86400 to get around it combined with a cron job to restart Homebridge daily and it’s fine now.