grover / homebridge-dacp

Remotely control Apple TV and iTunes via HomeKit.
MIT License
151 stars 14 forks source link

Cannot read property 'indexOf' of undefined after pairing (tvOS11.3) #37

Open williamli opened 6 years ago

williamli commented 6 years ago

I am trying to get homebridge-dacp to work with my AppleTV runnign tvOS11.3.

I have added

           {
          "platform": "DACP",
          "devices": [
            {
              "name": "AppleTV",
              "features": {
                "alternate-playpause-switch": true
              }
            }
          ]
        }

and used the passcode to successfully pair it with AppleTV.

I was asked to insert

        {
            "name": "AppleTV",
            "pairing": "6B413D0D21623AEC",
            "serviceName": "ACB0F206EF58248D18A4FC4362CFEEB3050D312E"
        }

into the accessories array.

On restart, homebridge crash with the following TypeError:

TypeError: Cannot read property 'indexOf' of undefined
    at API.accessory (/usr/local/lib/node_modules/homebridge/lib/api.js:50:12)
    at Server._loadAccessories (/usr/local/lib/node_modules/homebridge/lib/server.js:264:42)
    at Server.run (/usr/local/lib/node_modules/homebridge/lib/server.js:86:38)
    at module.exports (/usr/local/lib/node_modules/homebridge/lib/cli.js:40:10)
    at Object.<anonymous> (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)

screen shot 2018-04-01 at 16 52 33

willgonz commented 6 years ago

Me too. What is the fix?

willgonz commented 6 years ago

I figured it out, Someone else posted their config example. You don't put it in the accessories Array, that is a lie. Paste this: "pairing": "6B413D0D21623AEC", "serviceName": "ACB0F206EF58248D18A4FC4362CFEEB3050D312E" into

{ "platform": "DACP", "devices": [ { "name": "AppleTV", "pairing": "6B413D0D21623AEC", "serviceName": "ACB0F206EF58248D18A4FC4362CFEEB3050D312E", "features": { "alternate-playpause-switch": true } } ] }

williamli commented 6 years ago

let me give it a try.

grover commented 6 years ago

I meant the device entry with the text. Sorry about the confusion. Will rework this in 1.0.

BrentonBeltrami commented 5 years ago

I am running into this issue as well, I get the same error in the terminal whether I put the pairing & service in accessories or in the devices.

` { "bridge": { "name": "Homebridge", "username": "CC:22:3D:E3:CE:30", "port": 51826, "pin": "031-45-154" },

"description": "This is an example configuration file with one fake accessory and one fake platform. You can use this as a template for creating your own configuration file containing devices you actually own.",

"accessories": [
],

"platforms": [{
        "platform": "Nest",

        "token": "token",

        "clientId": "id",
        "clientSecret": "secret",
        "code": "code",

        "username": "Username",
        "password": "Password"
    },

    {
        "platform": "cmdSwitch2"

    },
    {
      "bridge": {
        "name": "Bedroom TV",
        "username": "AC:BB:CC:DD:EE:FF",
        "port": 54718,
        "pin": "135-79-864"
      },
      "platforms": [
        {
          "platform": "DACP",
          "devices": [
            {
              "name": "Bedroom TV",
              "pairing": "8428412ED4133D5A",
              "serviceName": "0BA70389F0174F0CA76067647F322E9FAD33B234",
              "features": {
                "alternate-playpause-switch": true
              }
            }
          ]
        }
      ]
    }
]

} `

This is the error i get in terminal.

[1/4/2019,10:27:52 AM] Loaded config.json with 0 accessories and 3 platforms. [1/4/2019, 10:27:52 AM] --- [1/4/2019, 10:27:52 AM] Loaded plugin: homebridge-cmdswitch2 [1/4/2019, 10:27:52 AM] Registering platform 'homebridge-cmdswitch2.cmdSwitch2' [1/4/2019, 10:27:52 AM] --- [1/4/2019, 10:27:53 AM] Loaded plugin: homebridge-dacp [1/4/2019, 10:27:53 AM] Registering platform 'homebridge-dacp.DACP' [1/4/2019, 10:27:53 AM] --- [1/4/2019, 10:27:53 AM] Loaded plugin: homebridge-harmonyhub [1/4/2019, 10:27:53 AM] Registering platform 'homebridge-harmonyhub.HarmonyHub' [1/4/2019, 10:27:53 AM] --- [1/4/2019, 10:27:53 AM] Loaded plugin: homebridge-nest [1/4/2019, 10:27:53 AM] Registering platform 'homebridge-nest.Nest' [1/4/2019, 10:27:53 AM] --- [1/4/2019, 10:27:53 AM] Loading 3 platforms... [1/4/2019, 10:27:53 AM] [Nest] Initializing Nest platform... [1/4/2019, 10:27:53 AM] [Nest] Fetching Nest devices. [1/4/2019, 10:27:53 AM] [cmdSwitch2] Initializing cmdSwitch2 platform... /usr/local/lib/node_modules/homebridge/lib/api.js:108 if (name.indexOf('.') == -1) { ^

TypeError: Cannot read property 'indexOf' of undefined at API.platform (/usr/local/lib/node_modules/homebridge/lib/api.js:108:12) at Server._loadPlatforms (/usr/local/lib/node_modules/homebridge/lib/server.js:316:45) at Server.run (/usr/local/lib/node_modules/homebridge/lib/server.js:86:36) at module.exports (/usr/local/lib/node_modules/homebridge/lib/cli.js:45:10) at Object. (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22) at Module._compile (internal/modules/cjs/loader.js:688:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10) at Module.load (internal/modules/cjs/loader.js:598:32) at tryModuleLoad (internal/modules/cjs/loader.js:537:12) at Function.Module._load (internal/modules/cjs/loader.js:529:3) at Function.Module.runMain (internal/modules/cjs/loader.js:741:12) at startup (internal/bootstrap/node.js:285:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)

BrentonBeltrami commented 5 years ago

I found my error. I had "platforms": [ twice in the document.