NorthernMan54 / homebridge-yamaha-zone-tv

12 stars 5 forks source link

"Cannot read property '0' of undefined" for pre-MusicCast device, Yamaha DSP-Z7 #27

Open radic00l opened 3 years ago

radic00l commented 3 years ago

I'm getting an error that is preventing an older (pre-MusicCast) device from being added, i.e. 1/13/2021, 10:38:28 AM Unhandled rejection TypeError: Cannot read property '0' of undefined

My config is as follows

        {
            "platform": "yamaha-zone-tv",
            "discovery_timeout": 10,
            "radio_presets": true,
            "preset_num": true,
            "max_volume": 10,
            "manual_addresses": {
                "Yamaha RX-A3060": "172.16.31.31",
                "Yamaha DSP-Z7": "172.16.31.30"
            }
        }

To give you more information:

For reference, here is the full extract from the logs for your plugin. You'll see the RX-A3060 being added successfully, but the error thrown for the Z7...

1/13/2021, 10:38:25 AM Loaded plugin 'homebridge-yamaha-zone-tv'
1/13/2021, 10:38:25 AM] Registering platform 'homebridge-yamaha-zone-tv.yamaha-zone-tv'
1/13/2021, 10:38:26 AM [yamaha-zone-tv] Initializing yamaha-zone-tv platform...

1/13/2021, 10:38:26 AM [yamaha-zone-tv] Getting Yamaha AVR devices.
1/13/2021, 10:38:26 AM [yamaha-zone-tv] Possible Yamaha device discovered Yamaha RX-A3060 undefined
1/13/2021, 10:38:26 AM [yamaha-zone-tv] Possible Yamaha device discovered Yamaha DSP-7Z undefined

1/13/2021, 10:38:28 AM [yamaha-zone-tv] Found Yamaha DSP-Z7 - 0CE5E8C3, "Yamaha DSP-7Z"
1/13/2021, 10:38:28 AM Unhandled rejection TypeError: Cannot read property '0' of undefined
1/13/2021, 10:38:28 AM at YamahaAVRPlatform.<anonymous> (/home/hoobs/.hoobs/node_modules/homebridge-yamaha-zone-tv/index.js:188:69)
1/13/2021, 10:38:28 AM at tryCatcher (/home/hoobs/.hoobs/node_modules/bluebird/js/release/util.js:16:23)
1/13/2021, 10:38:28 AM at Promise._settlePromiseFromHandler (/home/hoobs/.hoobs/node_modules/bluebird/js/release/promise.js:547:31)
1/13/2021, 10:38:28 AM at Promise._settlePromise (/home/hoobs/.hoobs/node_modules/bluebird/js/release/promise.js:604:18)
1/13/2021, 10:38:28 AM at Promise._settlePromise0 (/home/hoobs/.hoobs/node_modules/bluebird/js/release/promise.js:649:10)
1/13/2021, 10:38:28 AM at Promise._settlePromises (/home/hoobs/.hoobs/node_modules/bluebird/js/release/promise.js:729:18)
1/13/2021, 10:38:28 AM at Promise._fulfill (/home/hoobs/.hoobs/node_modules/bluebird/js/release/promise.js:673:18)
1/13/2021, 10:38:28 AM at Promise._resolveCallback (/home/hoobs/.hoobs/node_modules/bluebird/js/release/promise.js:489:14)
1/13/2021, 10:38:28 AM at Promise._settlePromiseFromHandler (/home/hoobs/.hoobs/node_modules/bluebird/js/release/promise.js:559:17)
1/13/2021, 10:38:28 AM at Promise._settlePromise (/home/hoobs/.hoobs/node_modules/bluebird/js/release/promise.js:604:18)
1/13/2021, 10:38:28 AM at Promise._fulfillPromises (/home/hoobs/.hoobs/node_modules/bluebird/js/release/promise.js:704:14)
1/13/2021, 10:38:28 AM at Promise._settlePromises (/home/hoobs/.hoobs/node_modules/bluebird/js/release/promise.js:730:18)
1/13/2021, 10:38:28 AM at Promise._fulfill (/home/hoobs/.hoobs/node_modules/bluebird/js/release/promise.js:673:18)
1/13/2021, 10:38:28 AM at Promise._resolveCallback (/home/hoobs/.hoobs/node_modules/bluebird/js/release/promise.js:466:57)
1/13/2021, 10:38:28 AM at Promise._settlePromiseFromHandler (/home/hoobs/.hoobs/node_modules/bluebird/js/release/promise.js:559:17)
1/13/2021, 10:38:28 AM at Promise._settlePromise (/home/hoobs/.hoobs/node_modules/bluebird/js/release/promise.js:604:18)
1/13/2021, 10:38:28 AM at Promise._settlePromise0 (/home/hoobs/.hoobs/node_modules/bluebird/js/release/promise.js:649:10)
1/13/2021, 10:38:28 AM at Promise._settlePromises (/home/hoobs/.hoobs/node_modules/bluebird/js/release/promise.js:729:18)
1/13/2021, 10:38:28 AM at Promise._fulfill (/home/hoobs/.hoobs/node_modules/bluebird/js/release/promise.js:673:18)
1/13/2021, 10:38:28 AM at Promise._resolveCallback (/home/hoobs/.hoobs/node_modules/bluebird/js/release/promise.js:466:57)
1/13/2021, 10:38:28 AM at Promise._settlePromiseFromHandler (/home/hoobs/.hoobs/node_modules/bluebird/js/release/promise.js:559:17)
1/13/2021, 10:38:28 AM at Promise._settlePromise (/home/hoobs/.hoobs/node_modules/bluebird/js/release/promise.js:604:18)
1/13/2021, 10:38:28 AM at Promise._settlePromise0 (/home/hoobs/.hoobs/node_modules/bluebird/js/release/promise.js:649:10)
1/13/2021, 10:38:28 AM at Promise._settlePromises (/home/hoobs/.hoobs/node_modules/bluebird/js/release/promise.js:729:18)
1/13/2021, 10:38:28 AM at Promise._fulfill (/home/hoobs/.hoobs/node_modules/bluebird/js/release/promise.js:673:18)
1/13/2021, 10:38:28 AM at Timeout._onTimeout (/home/hoobs/.hoobs/node_modules/bluebird/js/release/timers.js:26:46)
1/13/2021, 10:38:28 AM at listOnTimeout (internal/timers.js:554:17)
1/13/2021, 10:38:28 AM at processTimers (internal/timers.js:497:7)

1/13/2021, 10:38:28 AM [yamaha-zone-tv] Found Yamaha RX-A3060 - 089176F3, "Yamaha RX-A3060"
1/13/2021, 10:38:28 AM [yamaha-zone-tv] WARN: Got multiple systems with ID 089176F3! Omitting duplicate!

1/13/2021, 10:38:28 AM [yamaha-zone-tv] Adding TV Control for Main_Zone
1/13/2021, 10:38:29 AM [yamaha-zone-tv] Adding TV Control for Zone_2
1/13/2021, 10:38:29 AM [yamaha-zone-tv] Adding TV Control for Zone_3

1/13/2021, 10:38:48 AM [yamaha-zone-tv] Waited 10 seconds, stopping discovery.
1/13/2021, 10:38:48 AM [yamaha-zone-tv] Discovery finished, found 3 Yamaha AVR devices.

1/13/2021, 10:38:48 AM Yamaha RX-A3060 Main Zone is running on port 43307.
1/13/2021, 10:38:48 AM Please add [Yamaha RX-A3060 Main Zone] manually in Home app. Setup Code: 031-45-154
1/13/2021, 10:38:48 AM Yamaha RX-A3060 Zone 2 is running on port 42097.
1/13/2021, 10:38:48 AM Please add [Yamaha RX-A3060 Zone 2] manually in Home app. Setup Code: 031-45-154
1/13/2021, 10:38:48 AM Yamaha RX-A3060 Zone 3 is running on port 34011.
1/13/2021, 10:38:48 AM Please add [Yamaha RX-A3060 Zone 3] manually in Home app. Setup Code: 031-45-154

Separately (apologies for combining items, but while I have your attention)... Would it not make sense that if a person specifies manual_addresses, the plugin doesn't attempt to scan the network to index devices itself. This would allow a person to control which Yamaha devices are added, by specifying IP for devices to include and leaving out IP for devices they don't want added. Of course, by default, a person could leave blank and search for all devices.

NorthernMan54 commented 3 years ago

Thanks for a very detailed issue

A couple of comments

1 - Without have access to the physical device, adding and troubleshooting support issues is close to impossible. If you want to submit a pull request resolving the issue, I can merge it.

2 - Device Discovery - Yeah that is a bit of a wacky experience, and your correct the plugin does not handle the exclusion use case. In this scenario you could just not add/pair the duplicates, or put them is a 'closet'. And after looking at the code, am wondering if you could disable the discovery by setting the discovery timeout to a really low value, ie 1 or .1

dot-notation commented 3 years ago

Hey...

  1. I'm not sure I'd know how to debug correctly... Is there any chance you'd be interested in trying to debug if I NAT the device to an open public port?
  2. I was wondering what value of 0 would do? Does that effectively disable it, or does it make the timeout infinite?
NorthernMan54 commented 3 years ago

1 - Not sure this would actually work out

2 - Give it a try and see what happens. I'm thinking a really small value like 1 or .1