bbriatte / homebridge-soundtouch-platform

Homebridge & SoundTouch using Lightbulb to change the volume
BSD 3-Clause "New" or "Revised" License
17 stars 8 forks source link

Plugin crashes after launch? #3

Closed Nastras closed 5 years ago

Nastras commented 5 years ago

Hello, I wanted to try your plugin. Unfortunately, I have a problem after starting it runs short and then aborts with this error:

Bildschirmfoto 2019-05-03 um 18 15 03

My test Config:

"accessories": [],

"platforms": [{

    "platform": "SoundTouchPlatform",
    "name": "SoundTouch",
    "accessories": [{
        "name": "Lautsprecher Wohnzimmer",
        "room": "Wohnzimmer",
        "unmuteVolume": 40,
        "maxVolume": 80
    }]

}]

}

I use node 10.15.2 npm 5.8.0

and homebridge-soundtouch-platform@1.0.0 i have read in Issue # 1 that it should already V1.0.2? This is not offered to me via sudo npm install -g --unsafe -perm homebridge-soundtouch-platform @ latest -g.

Do you have any idea why this error occurs?

bbriatte commented 5 years ago

Hi @Nastras,

I push a new release: homebridge-soundtouch-platform@1.0.1 to raise an error when the device isn't found on the network

I think your device is not available, try my config:

{
    "platform": "SoundTouchPlatform",
    "name": "SoundTouch",
    "discoverAllAccessories": true
 }

If the problem isn't solved fix the IP of your device in the config file as follow :

{
    "platform": "SoundTouchPlatform",
    "name": "SoundTouch",
    "accessories": [
      {
        "name": "XXX",
        "ip": "<ip>"
      }
    ]
 }
Nastras commented 5 years ago

Thank you, I'll test it as soon as I'm home 👍👍👍

Krocko commented 5 years ago

I got this

Mai 04 13:43:27 raspberrypi homebridge[454]: (node:454) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'serialNumber' of undefined Mai 04 13:43:27 raspberrypi homebridge[454]: at /usr/local/lib/node_modules/homebridge-soundtouch-platform/dist/sound-touch-device.js:124:78 Mai 04 13:43:27 raspberrypi homebridge[454]: at Array.find (<anonymous>) Mai 04 13:43:27 raspberrypi homebridge[454]: at /usr/local/lib/node_modules/homebridge-soundtouch-platform/dist/sound-touch-device.js:124:49 Mai 04 13:43:27 raspberrypi homebridge[454]: at step (/usr/local/lib/node_modules/homebridge-soundtouch-platform/dist/sound-touch-device.js:32:23) Mai 04 13:43:27 raspberrypi homebridge[454]: at Object.next (/usr/local/lib/node_modules/homebridge-soundtouch-platform/dist/sound-touch-device.js:13:53) Mai 04 13:43:27 raspberrypi homebridge[454]: at /usr/local/lib/node_modules/homebridge-soundtouch-platform/dist/sound-touch-device.js:7:71 Mai 04 13:43:27 raspberrypi homebridge[454]: at new Promise (<anonymous>) Mai 04 13:43:27 raspberrypi homebridge[454]: at __awaiter (/usr/local/lib/node_modules/homebridge-soundtouch-platform/dist/sound-touch-device.js:3:12) Mai 04 13:43:27 raspberrypi homebridge[454]: at _deviceFromApi (/usr/local/lib/node_modules/homebridge-soundtouch-platform/dist/sound-touch-device.js:118:12) Mai 04 13:43:27 raspberrypi homebridge[454]: at Object.<anonymous> (/usr/local/lib/node_modules/homebridge-soundtouch-platform/dist/sound-touch-device.js:57:63) Mai 04 13:43:27 raspberrypi homebridge[454]: at step (/usr/local/lib/node_modules/homebridge-soundtouch-platform/dist/sound-touch-device.js:32:23) Mai 04 13:43:27 raspberrypi homebridge[454]: at Object.next (/usr/local/lib/node_modules/homebridge-soundtouch-platform/dist/sound-touch-device.js:13:53) Mai 04 13:43:27 raspberrypi homebridge[454]: at fulfilled (/usr/local/lib/node_modules/homebridge-soundtouch-platform/dist/sound-touch-device.js:4:58) Mai 04 13:43:27 raspberrypi homebridge[454]: (node:454) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2) Mai 04 13:43:27 raspberrypi homebridge[454]: (node:454) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Krocko commented 5 years ago

If i use

{
    "platform": "SoundTouchPlatform",
    "name": "SoundTouch",
    "accessories": [
      {
        "name": "XXX",
        "ip": "<ip>"
      }
    ]
 }

I got the following error:

Mai 04 14:02:33 raspberrypi homebridge[15288]: [SoundTouch] TypeError: Cannot read property 'serialNumber' of undefined
Mai 04 14:02:33 raspberrypi homebridge[15288]:     at /usr/local/lib/node_modules/homebridge-soundtouch-platform/dist/sound-touch-device.js:124:78
Mai 04 14:02:33 raspberrypi homebridge[15288]:     at Array.find (<anonymous>)
Mai 04 14:02:33 raspberrypi homebridge[15288]:     at /usr/local/lib/node_modules/homebridge-soundtouch-platform/dist/sound-touch-device.js:124:49
Mai 04 14:02:33 raspberrypi homebridge[15288]:     at step (/usr/local/lib/node_modules/homebridge-soundtouch-platform/dist/sound-touch-device.js:32:23)
Mai 04 14:02:33 raspberrypi homebridge[15288]:     at Object.next (/usr/local/lib/node_modules/homebridge-soundtouch-platform/dist/sound-touch-device.js:13:53)
Mai 04 14:02:33 raspberrypi homebridge[15288]:     at /usr/local/lib/node_modules/homebridge-soundtouch-platform/dist/sound-touch-device.js:7:71
Mai 04 14:02:33 raspberrypi homebridge[15288]:     at new Promise (<anonymous>)
Mai 04 14:02:33 raspberrypi homebridge[15288]:     at __awaiter (/usr/local/lib/node_modules/homebridge-soundtouch-platform/dist/sound-touch-device.js:3:12)
Mai 04 14:02:33 raspberrypi homebridge[15288]:     at _deviceFromApi (/usr/local/lib/node_modules/homebridge-soundtouch-platform/dist/sound-touch-device.js:118:12)
Mai 04 14:02:33 raspberrypi homebridge[15288]:     at Object.<anonymous> (/usr/local/lib/node_modules/homebridge-soundtouch-platform/dist/sound-touch-device.js:88:50)
Mai 04 14:02:33 raspberrypi homebridge[15288]:     at step (/usr/local/lib/node_modules/homebridge-soundtouch-platform/dist/sound-touch-device.js:32:23)
Mai 04 14:02:33 raspberrypi homebridge[15288]:     at Object.next (/usr/local/lib/node_modules/homebridge-soundtouch-platform/dist/sound-touch-device.js:13:53)
Mai 04 14:02:33 raspberrypi homebridge[15288]:     at fulfilled (/usr/local/lib/node_modules/homebridge-soundtouch-platform/dist/sound-touch-device.js:4:58)
bbriatte commented 5 years ago

Your SoundTouch device is up to date ?

Krocko commented 5 years ago

I have 3 SoundTouch devices. All are up to date.

bbriatte commented 5 years ago

What models ? I tried on SoundTouch 300

Krocko commented 5 years ago

SoundTouch 10 SoundTouch 20 SoundTouch 300

bbriatte commented 5 years ago

hmm, the problem come from the soundtouch api reference of Bose...

I don't know is the field serialNumber is optional or not.

wait 5 min, i will push an update with an optional serialNumber

Krocko commented 5 years ago

SoundTouch 10 and 300 are in Homekit. SoundTouch 20 is missing. Maybe this device causes the error?

Krocko commented 5 years ago

If i delete the SoundTouch 20 from the config, i don't get an error.

  • serialNumber | string | Element. The serial number of the component.

is it better to use the mac adress instead?

bbriatte commented 5 years ago

update the plugin & tell me if it works

Krocko commented 5 years ago

The update solves the error. But now i can't get preset 0 to work.

If i use the following config, all devices have the preset 0. But preset 0 don't exist on SoundTouch 10 and 20.

{
    "platform": "SoundTouchPlatform",
    "name": "SoundTouch",
    "discoverAllAccessories": true
}

If i use the extended config, i can't see a preset 0 in HomeKit.

      {
         "platform":"SoundTouchPlatform",
         "name":"Bose SoundTouch",
         "accessories":[
            {
               "name":"Bose SoundTouch 10",
               "ip":"xxx.xxx.xxx.xx",
               "presets":[
                  {
                     "name":"Sender 1",
                     "index":1
                  },
                  {
                     "name":"Sender 2",
                     "index":2
                  },
                  {
                     "name":"Sender 3",
                     "index":3
                  },
                  {
                     "name":"Sender 4",
                     "index":4
                  },
                  {
                     "name":"Sender 5",
                     "index":5
                  },
                  {
                     "name":"Sender 6",
                     "index":6
                  }
               ]
            },
            {
               "name":"Bose SoundTouch 20",
               "ip":"xxx.xxx.xxx.xx",
               "presets":[
                  {
                     "name":"Sender 1",
                     "index":1
                  },
                  {
                     "name":"Sender 2",
                     "index":2
                  },
                  {
                     "name":"Sender 3",
                     "index":3
                  },
                  {
                     "name":"Sender 4",
                     "index":4
                  },
                  {
                     "name":"Sender 5",
                     "index":5
                  },
                  {
                     "name":"Sender 6",
                     "index":6
                  }
               ]
            },
            {
               "name":"Bose SoundTouch 300",
               "ip":"xxx.xxx.xxx.xx",
               "presets":[
                  {
                     "name":"TV Eingang",
                     "index":0
                  },
                  {
                     "name":"Sender 1",
                     "index":1
                  },
                  {
                     "name":"Sender 2",
                     "index":2
                  },
                  {
                     "name":"Sender 3",
                     "index":3
                  },
                  {
                     "name":"Sender 4",
                     "index":4
                  },
                  {
                     "name":"Sender 5",
                     "index":5
                  },
                  {
                     "name":"Sender 6",
                     "index":6
                  }
               ]
            }
         ]
      }

Found it: With the above extended config i got preset 0 for the SoundTouch 10 and 20 in Homekit. If i delete "index":0 from the SoundTouch 300 und add it to the SoundTouch 10 and 20, i have it only for the SoundTouch 300 in Homekit.

Is this a bug in your plugin?

Nastras commented 5 years ago

I have just tried it with the minimal config and update is running.

{
"platform": "SoundTouchPlatform",
"name": "SoundTouch",
"discoverAllAccessories": true

}

I tested the following hardware:

Bose SA-5 Soundtouch 300 Soundtouch 10

I noticed the same as @Krocko it will be displayed on all devices, a TV input. This works only with the Soundtouch 300. For all other devices, the device is turned off when it is activated.

Here Bose SA-5

IMG_0540

Would not it be possible at this point to display all inputs as switches from the devices? Aux, Bluetooth etc.? So only the inputs that are really available?

What would also be nice if an output would be done in the log on the control of the devices.

Until here anyway a very horny plugin!

Krocko commented 5 years ago

Would not it be possible at this point to display all inputs as switches from the devices? Aux, Bluetooth etc.? So only the inputs that are really available?

What would also be nice if an output would be done in the log on the control of the devices.

Both a really good idea! +1 for this.

a very horny plugin!

There is nothing more to say! 😂

bbriatte commented 5 years ago

Normally i solve some problems in the 1.0.3 @Nastras @Krocko

Check the new README.md, maybe you need to remove the accessory because I change the 0 preset to a product (TV, HDMI, ...)

Tonight i will check

Would not it be possible at this point to display all inputs as switches from the devices? Aux, Bluetooth etc.? So only the inputs that are really available?

What would also be nice if an output would be done in the log on the control of the devices.

Nastras commented 5 years ago

This sounds very good, unfortunately I am on the road again and can only test it tomorrow morning. Maybe you already have the inputs installed when the API offers it 😉

I have one more question, but I'm not sure if that works. You've taken the brightness as volume to control this with Siri. Is not it possible to use a neutral slider and still change the volume via Siri?

Similar to this: https://github.com/grover/homebridge-automation-switches/blob/master/docs/Slider.md

Krocko commented 5 years ago

The problem with preset 0 is solved for me with

"products":[
                  {
                     "account":"TV"
                  }
               ]

Thank you very much for your work! But the following don’t work

"products":[
                  {
                     "account":"AUX"
                  },
                  {
                     "account":"Bluetooth"
                  }
               ]
bbriatte commented 5 years ago

@Nastras I think it doesn't work : The slider is not useable in the official Apple Home app as it makes use of a custom service and characteristic.

Nastras commented 5 years ago

Good Morning, I suspected it. A pity, but not bad.

I saw that you have uploaded an update for the source selection. Great I will try it out and tell you.

Nastras commented 5 years ago

Everything works great. I've set sources to true for each device now. What I do not realize yet, I get displayed on all devices, two source called QPlay. What function does this have?

IMG_0541

{ "name":"Lautsprecher Badezimmer", "ip":"192.168.xxx.xx", "unmuteVolume":20, "source": "true", "presets":[ { "name":"Sender 1", "index":1 }, { "name":"Sender 2", "index":2 }, { "name":"Sender 3", "index":3 }, { "name":"Sender 4", "index":4 }, { "name":"Sender 5", "index":5 }, { "name":"Sender 6", "index":6 } ] },

Is it possible in the log to show at startup all available sources from the device so you know which can be individually entered into the config?

Another question / idea is it possible to install an option similar to unmute for the turn on volume?

Edit Is it even possible to specify the sources individually? If yes how? I have tried it but without success. "source": "Bluetooth, Aux In 1,

Nastras commented 5 years ago

Have now tried a little bit more.

The unmute / mute works. What surprises me something that after switching from mute to unmute the volume does not change although in the Config in the config is set? "unmuteVolume":20,

Bildschirmfoto 2019-05-05 um 06 00 11

Everything else works perfectly. Fantastic work!

Nastras commented 5 years ago

I noticed something else. When selecting a source, undefined precedes the message. The change works anyway.

Bildschirmfoto 2019-05-05 um 06 27 30
Krocko commented 5 years ago

@bbriatte for me everything is working now. Thank you again!

@Nastras QPlay is a chinese streaming service. QPlay You can disable it an the config.json. See the readme.

"sources":[
                  {
                     "source":"QPLAY",
                     "enabled":false
                  }
               ]

Also you can specify the sources individually

"sources":[
                  {
                     "source":"AUX",
                     "account":"AUX1"
                  }
               ]
Nastras commented 5 years ago

@Krocko I did not know that QPlay is a streaming service. Thanks for the hint! Would not the other streaming service have to be selectable then? Amazon Prime Spotify?

@bbriatte The global hiding sources I will test the same, but here it would be more effective synonymous these devices specifically hide the device in the Config. But im not sure, maybe after the test 🤓

@Krocko Does the volume adjustment work for you with unmute?

Nastras commented 5 years ago

I tried it. @Krocko QPlay has now disappeared. Did not see it this morning just in the example config -.- Thank you!

@bbriatte Everything is going great now except for the "unmuteVolume": 40, function. This has no impact on me. Also not in the default setting. I have these removed from my config now. But I do not need this function.

The only real desire that I would have if it is possible via the Config a turn on volume set?

Thank you again for the great plugin. As @Krocko already wrote long waited for such a plugin. I will now take your plugin into my productive environment!

Krocko commented 5 years ago

@Nastras as a workaround you can create a HomeKit rule.

455FDB6A-8EB8-42F8-9ECD-32FA4D7502C6

Nastras commented 5 years ago

Good idea, that's exactly what I've been using for a long time. My goal is to save automations for such simple functions as possible, as I am near the Apple limit of 250 automations.

Therefore, I think it would be a reasonable extension if it is possible to adjust the config.

Krocko commented 5 years ago

Ah ok. I think we can close this issue? It is better to create a new one as a feature request?

Nastras commented 5 years ago

You're right is getting confused. I have opened new issues for the two open points. You have not answered my question about mute / unmute yet?

Krocko commented 5 years ago

I hadn’t it configured. Tested this now and also don’t work.