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

Crash when using the Apple TV remote app #59

Closed JeroenVdb closed 2 years ago

JeroenVdb commented 2 years ago

Describe The Bug: I can't use the Apple TV Remote to control the set-top-box. Whenever I try to use it the plugin crashes and homebridge is restarted. Other features of this plugin work: box on/off, list of channels, select another channel, etc...

To Reproduce:

  1. TV Box is on
  2. Go the the Apple TV Remote
  3. Select the set-top-box
  4. Press any button (tried left, right, back)

Expected behavior: The buttons from the remote should be emulated.

Logs:

[1/21/2022, 9:58:53 AM] TypeError: Cannot read properties of undefined (reading 'arrowLeftButton')
    at stbDevice.setRemoteKey (/homebridge/node_modules/homebridge-eosstb/index.js:3722:45)
    at RemoteKey.emit (node:events:390:28)
    at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1668:16
    at new Promise (<anonymous>)
    at RemoteKey.<anonymous> (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1666:14)
    at step (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:143:27)
    at Object.next (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:124:57)
    at /usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:117:75
    at new Promise (<anonymous>)
    at __awaiter (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:113:16)
[1/21/2022, 10:17:22 AM] [EOSSTB] Telenet TV: setRemoteKey remoteKey: 7
[1/21/2022, 10:17:22 AM] TypeError: Cannot read properties of undefined (reading 'arrowRightButton')
    at stbDevice.setRemoteKey (/homebridge/node_modules/homebridge-eosstb/index.js:3729:45)
    at RemoteKey.emit (node:events:390:28)
    at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1668:16
    at new Promise (<anonymous>)
    at RemoteKey.<anonymous> (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1666:14)
    at step (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:143:27)
    at Object.next (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:124:57)
    at /usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:117:75
    at new Promise (<anonymous>)
    at __awaiter (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:113:16)
[1/21/2022, 10:17:22 AM] Got SIGTERM, shutting down Homebridge...
[1/21/2022, 10:17:27 AM] [HB Supervisor] Homebridge Process Ended. Code: 143, Signal: null
[1/21/2022, 10:17:32 AM] [HB Supervisor] Restarting Homebridge...

Plugin Config:

{
    "bridge": {
        "name": "Homebridge E8D4",
        "username": "XXX",
        "port": 52034,
        "pin": "XXX"
    },
    "accessories": [],
    "platforms": [
        {
            "name": "Config",
            "port": 8082,
            "platform": "config"
        },
        {
            "name": "EOSSTB",
            "country": "be-nl",
            "username": "XXX",
            "password": "XXX",
            "doublePressTime": 250,
            "doublePressDelayTime": 300,
            "debugLevel": 3,
            "devices": [
                {
                    "syncName": true,
                    "accessoryCategory": "settopbox",
                    "showChannelNumbers": false,
                    "maxChannels": 95,
                    "arrowUpButton": "ArrowUp",
                    "arrowUpButtonDoubleTap": "ChannelUp",
                    "arrowDownButton": "ArrowDown",
                    "arrowDownButtonDoubleTap": "ChannelDown",
                    "arrowLeftButton": "ArrowLeft",
                    "arrowLeftButtonDoubleTap": "MediaRewind",
                    "arrowRightButton": "ArrowRight",
                    "arrowRightButtonDoubleTap": "MediaFastForward",
                    "selectButton": "Enter",
                    "selectButtonDoubleTap": "Enter",
                    "playPauseButton": "MediaPlayPause",
                    "playPauseButtonDoubleTap": "MediaPlayPause",
                    "backButton": "Escape",
                    "backButtonDoubleTap": "Escape",
                    "infoButton": "MediaTopMenu",
                    "infoButtonDoubleTap": "Guide",
                    "viewTvSettingsCommand": "Help"
                }
            ],
            "channels": [
                {
                    "channelId": "com.libertyglobal.app.youtube",
                    "channelName": "YouTube"
                },
                {
                    "channelId": "be.vrt.vrtnu",
                    "channelName": "VRT NU"
                },
                {
                    "channelId": "com.libertyglobal.app.netflix",
                    "channelName": "Netflix"
                }
            ],
            "platform": "eosstb"
        }
    ]
}

Screenshots:

Environment:

jsiegenthaler commented 2 years ago

Interesting. What eosstb plugin version are you using?

JeroenVdb commented 2 years ago

I installed it yesterday, so the latest: homebridge-eosstb v1.2.1

JeroenVdb commented 2 years ago

When I console.log this.config.devices I see on line 3669 I get this:

[
  {
    syncName: true,
    accessoryCategory: 'settopbox',
    showChannelNumbers: false,
    maxChannels: 95,
    arrowUpButton: 'ArrowUp',
    arrowUpButtonDoubleTap: 'ChannelUp',
    arrowDownButton: 'ArrowDown',
    arrowDownButtonDoubleTap: 'ChannelDown',
    arrowLeftButton: 'ArrowLeft',
    arrowLeftButtonDoubleTap: 'MediaRewind',
    arrowRightButton: 'ArrowRight',
    arrowRightButtonDoubleTap: 'MediaFastForward',
    selectButton: 'Enter',
    selectButtonDoubleTap: 'Enter',
    playPauseButton: 'MediaPlayPause',
    playPauseButtonDoubleTap: 'MediaPlayPause',
    backButton: 'Escape',
    backButtonDoubleTap: 'Escape',
    infoButton: 'MediaTopMenu',
    infoButtonDoubleTap: 'Guide',
    viewTvSettingsCommand: 'Help'
  }
]

I guess the problem is that my device has no deviceId. I'll have not set it via config, I'll try to set it via config and see if it then is selected correctly.

JeroenVdb commented 2 years ago

@jsiegenthaler adding deviceId resolved the problem 🎉. I might have missed it in the config but I thought this was not mandatory.

The device can not be selected when it has no deviceId here: https://github.com/jsiegenthaler/homebridge-eosstb/blob/master/index.js#L3670

Should the deviceId not be set in the script when not provided in the config?

jsiegenthaler commented 2 years ago

Thanks for that info, I'll review my code and try and reproduce the error you saw. I'll also review what my code is doing regarding the deviceId...

In the meantime enjoy the plugin :)

jsiegenthaler commented 2 years ago

Root cause found and all fixed in v1.2.2