Closed JimMeldrum closed 6 years ago
What do you mean "crashes out", could you please attach the zipped log file?
You are running on macOS, right? Do you see iTunes being started when homebridge starts? Or was iTunes already open? Using applescript is a bit flaky, if there's a popup dialog, iTunes might be unresponsive, causing the timeout.
Wow, thanks for quick response. Adding parameters to the music platform element of the config.json resolved the errors above. I then got an 'osascript' error in the homebridge error log which I resolved by amending my PATH in my plist file.
Everything now loads and I can see Music and Computer in HomeKit on my iPhone however the homebridge error log contains the following errors. It's maybe I'm just missing the manual :-) Hey, thanks for your work :-) :-)
[2018-9-1 13:38:18] [Music] applescript: set lib to (load script "/usr/local/lib/node_modules/homebridge-music/scripts/iTunes.scpt") tell lib to setPlayerOn(true, "Gold Digger") [2018-9-1 13:38:18] [Music] Music: could not set on to true [2018-9-1 13:38:43] [Music] Computer: could not set volume to 28 HAP Warning: Characteristic 00000119-0000-1000-8000-0026BB765291 not in required or optional characteristics for service 00000043-0000-1000-8000-0026BB765291. Adding anyway. HAP Warning: Characteristic 00000119-0000-1000-8000-0026BB765291 not in required or optional characteristics for service 00000043-0000-1000-8000-0026BB765291. Adding anyway. [2018-9-1 13:38:44] [Music] applescript error execution error: iTunes got an error: Parameter error. (-50)
[2018-9-1 13:38:44] [Music] applescript: set lib to (load script "/usr/local/lib/node_modules/homebridge-music/scripts/iTunes.scpt") tell lib to setSpeakerOn("Computer", true) [2018-9-1 13:38:44] [Music] Computer: could not set on to true [2018-9-1 13:38:44] [Music] Computer: could not set volume to 45 [2018-9-1 13:38:44] [Music] Computer: could not set volume to 59 [2018-9-1 13:38:44] [Music] Computer: could not set volume to 65 [2018-9-1 13:38:58] [Music] Computer: could not set volume to 16 [2018-9-1 13:38:59] [Music] applescript error execution error: iTunes got an error: Parameter error. (-50)
[2018-9-1 13:38:18] [Music] applescript: set lib to (load script "/usr/local/lib/node_modules/homebridge-music/scripts/iTunes.scpt")
tell lib to setPlayerOn(true, "Gold Digger")
[2018-9-1 13:38:18] [Music] Music: could not set on to true
Make sure to set "track"
to a valid iTunes track (song), otherwise you'll get an error trying to play when iTunes doesn't have a current track. Check in iTunes with Controls | Go to Current Song.
[2018-9-1 13:38:43] [Music] Computer: could not set volume to 28
The Computer speaker doesn't make sense, if you have no Airplay speakers. Even if you do it's flaky. Best suppress it by setting "speakername": "^[^C].*"
in config.json (or some other value that doesn't match "Computer"
).
HAP Warning: Characteristic 00000119-0000-1000-8000-0026BB765291 not in required or optional characteristics for service 00000043-0000-1000-8000-0026BB765291. Adding anyway.
HAP Warning: Characteristic 00000119-0000-1000-8000-0026BB765291 not in required or optional characteristics for service 00000043-0000-1000-8000-0026BB765291. Adding anyway.
This is a genuine bug, causing the volume (brightness) in HomeKit not to be updated when changed from iTunes.
Bug fixed in v0.1.10.
I'm back to the module crashing out again with v01.1.10. Tried changing different parameters in config.json and no config but no matter what I tried I get the below.
TBH all I would like to achieve is to be able to play a specific song to a specific speaker. I want to tee this up with a motion sensor to scare off a heron!
[2018-9-1 15:38:04] [Music] applescript timeout [2018-9-1 15:38:04] [Music] applescript: set lib to (load script "/usr/local/lib/node_modules/homebridge-music/scripts/iTunes.scpt") tell lib to getState()
Or enter this code with your HomeKit app on your iOS device to pair with Homebridge:
┌────────────┐
│ 999-99-999 │
└────────────┘
events.js:183 throw er; // Unhandled 'error' event ^
Error: listen EADDRINUSE :::51826
at Object._errnoException (util.js:992:11)
at _exceptionWithHostPort (util.js:1014:20)
at Server.setupListenHandle [as _listen2] (net.js:1355:14)
at listenInCluster (net.js:1396:12)
at Server.listen (net.js:1480:7)
at EventedHTTPServer.listen (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/util/eventedhttp.js:60:19)
at HAPServer.listen (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:158:20)
at Bridge.Accessory.publish (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:607:16)
at Server._publish (/usr/local/lib/node_modules/homebridge/lib/server.js:127:16)
at Server.
Error: listen EADDRINUSE :::51826
You have another instance of homebridge running.
doh, you are quite right! the timeouts go away once iTunes has loaded which is something the module instigates.
I can't work out how to play a specific track to a specific speaker at a specific volume however. I guess I need to invest some time putting together an apple script for that.
thanks for your support
Hi
I’m still struggling. home bridge runs with no errors logged but the music plugin platform is not showing up in HomeKit and not are any speakers.
Anything I’m missing?
I tried the pattern you suggested and my config.json looks like this:-
{ "platform" : "Music", "service" : "light", "script" : "iTunes", "speakername": "^[^C].*", "heart rate" : 5 }
And the homebridge log looks like this:-
[2018-9-1 16:49:28] Loaded config.json with 0 accessories and 4 platforms. [2018-9-1 16:49:28] --- [2018-9-1 16:49:28] Loaded plugin: homebridge-music [2018-9-1 16:49:28] Registering platform 'homebridge-music.Music' [2018-9-1 16:49:32] --- [2018-9-1 16:49:32] [Music] Initializing Music platform... [2018-9-1 16:49:32] [Music] homebridge-music v0.1.10, node v8.11.4, homebridge v0.4.44 [2018-9-1 16:49:32] Loading 0 accessories...
X-HM://0023ISYXGCPJH Scan this code with your HomeKit app on your iOS device to pair with Homebridge:
Or enter this code with your HomeKit app on your iOS device to pair with Homebridge:
┌────────────┐
│ 999-99-999 │
└────────────┘
[2018-9-1 16:49:37] Homebridge is running on port 99999.
Many thanks
"heartrate"
is without a space, but 5 is the default anyways. The Loading 0 accessories... message is from homebridge, indicating that no accessory plugins were mentioned in config.json. I need to see all the homebridge-music messages to know what's happening. Could you please capture a debug log file and attach that? See https://github.com/ebaauw/homebridge-hue#debug-log-file.
I suspect homebridge-music times out when trying to get the state from iTunes for the very first time (starting iTunes might take too long) and, consequently, doesn't expose anything. This is a very old plugin (my first actually) and it seems I hardcoded the timeout to 5 seconds, see: https://github.com/ebaauw/homebridge-music/blob/9eaf1f18e02bb508d2246712bc09737b5886b20d/lib/Script.js#L77-L82
I'll add a "timeout"
config.json setting, but it might take some time before I get to that. Until then, you might try to start iTunes manually before starting homebridge, or patch the code, changing 5000
(milliseconds) on line 82 to 10000
or 15000
.
I can't work out how to play a specific track to a specific speaker at a specific volume however. I guess I need to invest some time putting together an apple script for that.
There's no characteristic to select a particular track. You can set a default track in config.json, in case iTunes doesn't have a current track, otherwise the plugin just plays the current track. You could create a HomeKit scene, with the On and Brightness attributes to start playing the current track at a particular volume. I'm not sure if a writeable Track Name characteristic could be included in a such a scene. It would make a nice enhancement if it could, also for my Sonos plugin.
I wrote this plugin (and the Sonos plugin) to have my music follow me through my home, turning on or off the appropriate Airplay speakers as I enter or leave the room, and to provide some very basic control (Play/Stop, Volume, Next/Previous track). For more elaborate control, I'd use Apple's Remote app.
Hi, you are absolutely right about the timeout. The script does not wait long enough for iTunes to load and discover all the Airplay speakers so it just returns nothing.
If I launch iTunes first and wait 10-15 seconds before initiating homebridge then the script discovers all the AirPlay speakers.
Unfortunately changing the timeout entry in the java script as you suggest does not result in the script waiting any longer :-(
Perhaps the scripts could activate iTunes then wait before calling the function to query the current state?
Unfortunately changing the timeout entry in the java script as you suggest does not result in the script waiting any longer
That doesn't make sense to me. Could you please attach a full debug log?
I'm really puzzled. I captured a debug log and this time it all worked: the AppleScript picked up the list of AirPlay speakers!
Everytime I repeat the process and regardless of whether or not iTunes is or is not loaded prior to initiating homebridge all speakers are picked up.
So I have everything working now :-)
Hi, when homebridge initiates the music plug in it throws the following errors and then crashes out: -
[Music] applescript timeout [Music] applescript: set lib to (load script "/usr/local/lib/node_modules/homebridge-music/scripts/iTunes.scpt") tell lib to getState()
any idea why please? many thanks