tkleijkers / homebridge-visonic-powerlink3

MIT License
1 stars 3 forks source link

Panel Code vs. Login - Old API #17

Closed JSVarga closed 1 year ago

JSVarga commented 2 years ago

Request: If the config has a userCode parameter, and no email or password parameters, make a call to the old API. I am hoping this is a straightforward change to provide some backward capability but note from below I think the old plugin versions are making calls to the new API.

I think what is happening is related to the API change a while back but also I use a different alarm provider here in the UK. Been a problem for a while but only had some time to do investigation. My plugin stopped working when the API was updated but I don't have a username and password, only a Panel Name and User Code. The Alarm provider seems to have no idea about this and I am tied into a monitoring contract for another year.

Key point is my Powerlink server address is logonmysecurity.com (not visonic.tycomonitor.com)

So using my usual server (logonmysecurity.com) with the userCode parameter and with or without the email and password parameters Homebridge crashes as follows, and this happens on v1.3.6 and v1.0.0: [3/23/2022, 8:34:53 AM] [PowerLink3] Executing request https://logonmysecurity.com/rest_api/9.0/status [3/23/2022, 8:24:46 AM] [PowerLink3] Updating status (1) [3/23/2022, 8:24:46 AM] SyntaxError: Unexpected token < in JSON at position 0 at JSON.parse () at /homebridge/node_modules/homebridge-visonic-powerlink3/node_modules/visonic-powerlink3/index.js:88:20 at Request._callback (/homebridge/node_modules/homebridge-visonic-powerlink3/node_modules/visonic-powerlink3/index.js:334:4) at Request.self.callback (/homebridge/node_modules/homebridge-visonic-powerlink3/node_modules/request/request.js:185:22) at Request.emit (events.js:315:20) at Request. (/homebridge/node_modules/homebridge-visonic-powerlink3/node_modules/request/request.js:1154:10) at Request.emit (events.js:315:20) at IncomingMessage. (/homebridge/node_modules/homebridge-visonic-powerlink3/node_modules/request/request.js:1076:12) at Object.onceWrapper (events.js:421:28) at IncomingMessage.emit (events.js:327:22) [3/23/2022, 8:24:46 AM] Got SIGTERM, shutting down Homebridge...

NOTE: When I put https://logonmysecurity.com/rest_api/9.0/status in my browser I get 404, which I assume is the new API not implemented on my Powerlink server, but the same API call is being made when I reinstall v1.0.0 of the login.

If I change the server to visonic.tycomonitor.com with the email and password then I get the following error message, which is understandable: [3/23/2022, 8:18:42 AM] [PowerLink3] Updating status (1) [3/23/2022, 8:18:42 AM] [PowerLink3] Error polling: Error: Error getting raw status: Error: Failed to get authentication session-token: Wrong combination

If I change the server to visonic.tycomonitor.com and remove the email and password then I get the following error message: [3/23/2022, 8:31:50 AM] [PowerLink3] Updating status (1) [3/23/2022, 8:31:50 AM] [PowerLink3] Error polling: Error: Error getting raw status: Error: Failed to get authentication session-token: Bad Request Params

blacknerd21 commented 2 years ago

I'm facing the same issue as @JSVarga . I log in to the system using a panel name and user code, not an email address and password.

hopefully the issue can get fixed soon

JSVarga commented 1 year ago

Finally my alarm provider has updated their system and I have a login and password. Applied changes to my config, re-enabled the plug-in and all running. Sorry if this doesn't help @blacknerd21 but I am all working now.

tkleijkers commented 1 year ago

I have no test setup for this, so I cannot implement this change. If anyone can make a PR to make this configurable I will be happy to pull.