jsiegenthaler / homebridge-eosstb

A homebridge plugin for the EOS set-top box as used by Sunrise, Telenet, Ziggo, Virgin Media and maybe more in various countries on the Horizon Go (HGO) platform
https://github.com/jsiegenthaler/homebridge-eosstb
32 stars 4 forks source link

ReferenceError: accessToken is not defined when connecting on some GB sessions #77

Closed jsiegenthaler closed 1 year ago

jsiegenthaler commented 1 year ago

Reported by @robscousins on issue #76

Occurs after a GB session has connected:

[11/17/2022, 4:19:22 PM] [EOSSTB] VM Front Room: Status Fault changed from undefined [undefined] to 0 [NO_FAULT] [11/17/2022, 4:19:22 PM] [EOSSTB] VM Front Room: Status Active changed from undefined [undefined] to 1 [ACTIVE] [11/17/2022, 4:19:22 PM] [EOSSTB] VM Front Room: In Use changed from undefined [undefined] to 0 [NOT_IN_USE] [11/17/2022, 4:19:22 PM] [EOSSTB] VM Front Room: Picture Mode changed from null [OTHER] to 1 [STANDARD] [11/17/2022, 4:19:22 PM] [EOSSTB] VM Front Room: Program Mode changed from undefined [undefined] to 1 [PROGRAM_SCHEDULED] [11/17/2022, 4:19:22 PM] [EOSSTB] VM Front Room: Input Device Type changed on input 0 ID_UNKNOWN from undefined [undefined] to 1 [TV] [11/17/2022, 4:19:22 PM] [EOSSTB] VM Front Room: Input Source Type changed on input 0 ID_UNKNOWN from undefined [undefined] to 2 [TUNER] [11/17/2022, 4:19:22 PM] [EOSSTB] VM Family Room: Recording state: ongoing recordings found: local 0, network 0, current Recording State 0 [IDLE] [11/17/2022, 4:19:22 PM] [EOSSTB] VM Front Room: Recording state: ongoing recordings found: local 0, network 0, current Recording State 0 [IDLE]

/homebridge/node_modules/homebridge-eosstb/index.js:1627 const config = {headers: {"x-cus": accessToken, "x-oesp-token": this.session.accessToken, "x-oesp-username": this.session.username}}; ^ ReferenceError: accessToken is not defined at stbPlatform.setPersonalizationDataForDevice (/homebridge/node_modules/homebridge-eosstb/index.js:1627:38) at stbDevice.setDeviceName (/homebridge/node_modules/homebridge-eosstb/index.js:4215:19) at ConfiguredName. (/homebridge/node_modules/homebridge-eosstb/index.js:3031:45) at ConfiguredName.emit (node:events:513:28) at /homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1725:16 at new Promise () at ConfiguredName. (/homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1723:14) at step (/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:144:27) at Object.next (/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:125:57) at /homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:118:75 [11/17/2022, 4:19:24 PM] [EOSSTB] Child bridge process ended [11/17/2022, 4:19:24 PM] [EOSSTB] Process Ended. Code: 1, Signal: null

robscousins commented 1 year ago

restarted Child bridge WITHOUT adding individual device to HomeKit - no errors: [logs snipped]

robscousins commented 1 year ago

Now adding accessory in HomeKit (bridge already added) after keying in the setup code and selecting the room:

/homebridge/node_modules/homebridge-eosstb/index.js:1627 const config = {headers: {"x-cus": accessToken, "x-oesp-token": this.session.accessToken, "x-oesp-username": this.session.username}}; ^ ReferenceError: accessToken is not defined at stbPlatform.setPersonalizationDataForDevice (/homebridge/node_modules/homebridge-eosstb/index.js:1627:38) at stbDevice.setDeviceName (/homebridge/node_modules/homebridge-eosstb/index.js:4215:19) at ConfiguredName. (/homebridge/node_modules/homebridge-eosstb/index.js:3031:45) at ConfiguredName.emit (node:events:513:28) at /homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1725:16 at new Promise () at ConfiguredName. (/homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1723:14) at step (/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:144:27) at Object.next (/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:125:57) at /homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:118:75 [11/17/2022, 10:07:31 PM] [EOSSTB] Child bridge process ended [11/17/2022, 10:07:31 PM] [EOSSTB] Process Ended. Code: 1, Signal: null [11/17/2022, 10:07:38 PM] [EOSSTB] Restarting Process...

now stuck in a loop until I either stop the (child) bridge or remove the (VM media) accessory)

[11/17/2022, 10:07:58 PM] [EOSSTB] VM Front Room: Input Device Type changed on input 0 ID_UNKNOWN from undefined [undefined] to 1 [TV] [11/17/2022, 10:07:58 PM] [EOSSTB] VM Front Room: Input Source Type changed on input 0 ID_UNKNOWN from undefined [undefined] to 2 [TUNER] [11/17/2022, 10:07:58 PM] [EOSSTB] VM Family Room: Recording state: ongoing recordings found: local 0, network 1, current Recording State 1 [ONGOING_NDVR] [11/17/2022, 10:07:58 PM] [EOSSTB] VM Front Room: Recording state: ongoing recordings found: local 0, network 1, current Recording State 1 [ONGOING_NDVR]

/homebridge/node_modules/homebridge-eosstb/index.js:1627 const config = {headers: {"x-cus": accessToken, "x-oesp-token": this.session.accessToken, "x-oesp-username": this.session.username}}; ^ ReferenceError: accessToken is not defined at stbPlatform.setPersonalizationDataForDevice (/homebridge/node_modules/homebridge-eosstb/index.js:1627:38) at stbDevice.setDeviceName (/homebridge/node_modules/homebridge-eosstb/index.js:4215:19) at ConfiguredName. (/homebridge/node_modules/homebridge-eosstb/index.js:3031:45) at ConfiguredName.emit (node:events:513:28) at /homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1725:16 at new Promise () at ConfiguredName. (/homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1723:14) at step (/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:144:27) at Object.next (/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:125:57) at /homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:118:75 [11/17/2022, 10:08:02 PM] [EOSSTB] Child bridge process ended [11/17/2022, 10:08:02 PM] [EOSSTB] Process Ended. Code: 1, Signal: null

jsiegenthaler commented 1 year ago

Yes, that's clear. I need full logs in full debugging mode emailed to me. There's an accessToken missing, and I need to see where it goes missing.

robscousins commented 1 year ago

note - I am still in the Name TV Inout Sources Screen' and when I finish that, HomeKit finishes the process and one of the two VM boxes IS visible in HomeKit and seems to operating ok:

[logs snipped]

The above is new to me as previously it stuck in an error look but that now appears to have cleared up, however, the other VM box isn't visible in HomeKit

jsiegenthaler commented 1 year ago

@robscousins Full logs please. But do not post them here, they are too big. Zip them and mail them. I need to see the json responses and all the data related to the session to find why and where the accessToken is lost.

robscousins commented 1 year ago

yep will do (although I am continue to play. thanks and all the best

robscousins commented 1 year ago

Ok went to Homebridge settings and went to unpair Bridges/cameras/tv etc option and remove the bridge, and the two VM boxes. Removed child bridge from plug in config. rebooted.

Both accessories appeared and I was able to add them successfully to HomeKit (although it did error a couple of times with the token issue but eventually passed and appears to be working )no further errors observed so far in the last few minutes

Will review tomorrow and/or on child bridge

thanks

jsiegenthaler commented 1 year ago

@robscousins I do not want to ignore this issue, I need to resolve what the token was missing. So I need full logs sent by email to analyze the issue.

jsiegenthaler commented 1 year ago

@robscousins any news?

robscousins commented 1 year ago

Sorry but I have been working. This is the logs from this morning I note that whilst the plug in has been stable and working, however, if I attempt to change the name of the device in HomeKit I now get the error spiral as seen in the logs below

I’ve now turned off that child bridge for now.

Best Rob

[log snipped]

jsiegenthaler commented 1 year ago

Hi @robscousins Found the issue. Fixed in 2.0.2-beta.4 Please try the beta and confirm it is working for you. Once confirmed I'll publish a release.

PS: I snipped the logs to clean up this thread and remove some potentially sensitive data from public display

robscousins commented 1 year ago

Thanks very much for the update, much appreciated :-) Erm, stupid question - how do I pull the beta version on GitHub?

Best Rob

On 26 Nov 2022, at 11:09, jsiegenthaler @.***> wrote:

Hi @robscousins https://github.com/robscousins Found the issue. Fixed in 2.0.2-beta.4 Please try the beta and confirm it is working for you. Once confirmed I'll publish a release.

— Reply to this email directly, view it on GitHub https://github.com/jsiegenthaler/homebridge-eosstb/issues/77#issuecomment-1328026474, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFNTRQQO4BVAPLTJOULVRPTWKHVVXANCNFSM6AAAAAASDYXGCI. You are receiving this because you were mentioned.

jsiegenthaler commented 1 year ago

In Homebridge Plugins: click on the Spanner icon of the plugin, select Install Alternate Version, choose the version you wish to install (in this case v2.0.2-beta.4) from the list of available versions.

You can change to any version at any time, just restart Homebridge after each change.

robscousins commented 1 year ago

Ah! Never down that before. Doing now and I will report back hopefully in a couple of days to see how it goes? Best Rob

On 26 Nov 2022, at 11:09, jsiegenthaler @.***> wrote:

Hi @robscousins https://github.com/robscousins Found the issue. Fixed in 2.0.2-beta.4 Please try the beta and confirm it is working for you. Once confirmed I'll publish a release.

— Reply to this email directly, view it on GitHub https://github.com/jsiegenthaler/homebridge-eosstb/issues/77#issuecomment-1328026474, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFNTRQQO4BVAPLTJOULVRPTWKHVVXANCNFSM6AAAAAASDYXGCI. You are receiving this because you were mentioned.

jsiegenthaler commented 1 year ago

To recreate the circumstances that caused the crash, all you have to do is have EOSSTB Sync Name option checked, and then rename the box using the Home app. If the rename completes successfully (check it on the TV ), and there are no errors in the Homebridge logs, then all is good.

It was a simple bug, I should have spotted it with your first bug report. It is fixed.

duckduckwd commented 1 year ago

I have had the same accessToken error appearing when I tried to switch the device on/off from the HomeKit app.

After reading this thread, I have installed v2.0.2-beta.9 and can confirm that the issues seen below have been fixed with this code.

[26/11/2022, 14:12:36] ReferenceError: accessToken is not defined
    at stbPlatform.setPersonalizationDataForDevice (/var/lib/homebridge/node_modules/homebridge-eosstb/index.js:1584:38)
    at stbDevice.setDeviceName (/var/lib/homebridge/node_modules/homebridge-eosstb/index.js:4185:19)
    at ConfiguredName.<anonymous> (/var/lib/homebridge/node_modules/homebridge-eosstb/index.js:3001:45)
    at ConfiguredName.emit (node:events:513:28)
    at /var/lib/homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:2596:16
    at new Promise (<anonymous>)
    at ConfiguredName.<anonymous> (/var/lib/homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:2594:14)
    at step (/var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:144:27)
    at Object.next (/var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:125:57)
    at /var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:118:75
    at new Promise (<anonymous>)
    at Object.__awaiter (/var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:114:16)
    at ConfiguredName.Characteristic.handleSetRequest (/var/lib/homebridge/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/Characteristic.js:871:24)
    at Accessory.<anonymous> (/var/lib/homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1889:29)
    at step (/var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:144:27)
    at Object.next (/var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:125:57)
[26/11/2022, 14:12:36] Got SIGTERM, shutting down Homebridge...
[26/11/2022, 14:12:37] [EOSSTB] Goodbye
[26/11/2022, 14:12:37] [EOSSTB] mqttClient: Connection closed
[26/11/2022, 14:16:58] [EOSSTB] Family Room: In Use changed from 0 [NOT_IN_USE] to 1 [IN_USE]
[26/11/2022, 14:16:58] [EOSSTB] Family Room: Media state changed from 2 [STOP] to 0 [PLAY]
[26/11/2022, 14:19:42] ReferenceError: accessToken is not defined
    at stbPlatform.setPersonalizationDataForDevice (/var/lib/homebridge/node_modules/homebridge-eosstb/index.js:1584:38)
    at stbDevice.setDeviceName (/var/lib/homebridge/node_modules/homebridge-eosstb/index.js:4185:19)
    at ConfiguredName.<anonymous> (/var/lib/homebridge/node_modules/homebridge-eosstb/index.js:3001:45)
    at ConfiguredName.emit (node:events:513:28)
    at /var/lib/homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:2596:16
    at new Promise (<anonymous>)
    at ConfiguredName.<anonymous> (/var/lib/homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:2594:14)
    at step (/var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:144:27)
    at Object.next (/var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:125:57)
    at /var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:118:75
    at new Promise (<anonymous>)
    at Object.__awaiter (/var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:114:16)
    at ConfiguredName.Characteristic.handleSetRequest (/var/lib/homebridge/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/Characteristic.js:871:24)
    at Accessory.<anonymous> (/var/lib/homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1889:29)
    at step (/var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:144:27)
    at Object.next (/var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:125:57)
[26/11/2022, 14:19:44] [BraviaTVOS] [DEBUG] Living Room TV: Polling API...
[26/11/2022, 14:19:45] ReferenceError: accessToken is not defined
    at stbPlatform.setPersonalizationDataForDevice (/var/lib/homebridge/node_modules/homebridge-eosstb/index.js:1584:38)
    at stbDevice.setDeviceName (/var/lib/homebridge/node_modules/homebridge-eosstb/index.js:4185:19)
    at ConfiguredName.<anonymous> (/var/lib/homebridge/node_modules/homebridge-eosstb/index.js:3001:45)
    at ConfiguredName.emit (node:events:513:28)
    at /var/lib/homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:2596:16
    at new Promise (<anonymous>)
    at ConfiguredName.<anonymous> (/var/lib/homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:2594:14)
    at step (/var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:144:27)
    at Object.next (/var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:125:57)
    at /var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:118:75
    at new Promise (<anonymous>)
    at Object.__awaiter (/var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:114:16)
    at ConfiguredName.Characteristic.handleSetRequest (/var/lib/homebridge/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/Characteristic.js:871:24)
    at Accessory.<anonymous> (/var/lib/homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1889:29)
    at step (/var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:144:27)
    at Object.next (/var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:125:57)
[26/11/2022, 14:19:45] Got SIGTERM, shutting down Homebridge...
[26/11/2022, 14:19:46] [EOSSTB] Goodbye

When powering off now, the log records a successful operation:

[26/11/2022, 14:37:43] [EOSSTB] sendKey: processing key 1 of 1: Power
[26/11/2022, 14:37:43] [EOSSTB] sendKey: sending key Power to Family Room 3C36E4-EOSSTB-003458068602
[26/11/2022, 14:37:45] [EOSSTB] Family Room: Power changed from 1 [ON] to 0 [OFF]
[26/11/2022, 14:37:45] [EOSSTB] Family Room: In Use changed from 1 [IN_USE] to 0 [NOT_IN_USE]
[26/11/2022, 14:37:45] [EOSSTB] Family Room: Media state changed from 0 [PLAY] to 2 [STOP]

Thanks for your work on this! I look forward to the update being released!

jsiegenthaler commented 1 year ago

@duckduckwd Thanks for the feedback, I hope to release v2.0.2 in the next few days

jsiegenthaler commented 1 year ago

Issues resolved in v2.0.2, published just now 28.11.2022