homebridge-cmdswitch2
homebridge-cmdswitch2 copied to clipboard
Failed to determine Playstation state
ps4-waker doesn't seem to play well with cmdswitch2 on my system. When I invoke it from Terminal, it works properly. However, it disappeared from Home app and homebridge log shows me the following:
[8/12/2017, 12:22:04 PM] [CMD Switch] Failed to determine Playstation state.
[8/12/2017, 12:22:04 PM] [CMD Switch] /bin/sh: grep: command not found
My config:
"platforms": [{
"platform": "cmdSwitch2",
"name": "CMD Switch",
"switches": [{
"name": "Playstation",
"on_cmd": "ps4-waker -c ~/.homebridge/ps4-wake.credentials.json",
"off_cmd": "ps4-waker -c ~/.homebridge/ps4-wake.credentials.json standby",
"state_cmd": "ps4-waker -c ~/.homebridge/ps4-wake.credentials.json search | grep -i '200 Ok'",
"polling": true,
"interval": 5,
"timeout": 2000,
"manufacturer": "Sony Corporation",
"model": "CUH-1001A",
"serial": "XXXXXXXXXXX"
}]
}]
I'm running it on a Mac Mini with macOs 10.12.6 and node.js 8.2.1.
Any help would be greatly appreciated!
What if you run that search command on the terminal directly? Can you see your device?
Yes, it works in terminal every time. Only through cmdswitch2 it pops up these errors every now and then. And I do have grep installed on my system too, so that one is particularly strange.
I ran into this exact issue and it turned out to be a PATH
-related issue. I'm running homebridge with systemd and the system user didn't have a PATH set, therefore when it tried to call ps4-waker
, the bin directory for node it wasn't in the path. By simply specifying the full bin path to the command, I was able to get around this.
PATH issue is a problem as @brandonb927 suggests. I also found that the system user can't access the .ps4-wake.credentials.json file in a users (any) home folder. Setup ps4-waker, then copy the .ps4-wake.credentials.json file to a folder that all users can access.
See example working commands below...
"on_cmd": "node /opt/node/lib/node_modules/ps4-waker/bin/cmd.js -c /var/homebridge/.ps4-wake.credentials.json", "off_cmd": "node /opt/node/lib/node_modules/ps4-waker/bin/cmd.js -c /var/homebridge/.ps4-wake.credentials.json standby", "state_cmd": "node /opt/node/lib/node_modules/ps4-waker/bin/cmd.js -c /var/homebridge/.ps4-wake.credentials.json search | grep -i '200 Ok'",
@nicktones this is exactly how I needed to call mine with a slightly different install path, but nonetheless.
I've tried the approaches mentioned above and I can't tell if my issue is different or the same.
- Running
ps4-waker
on my Mac mini as my user works fine - Running
ps4-waker
as root works fine - I've tried moving the credentials to a place any user can access (
/var/homebridge/
) - I've tried
sudo
in my config.json file - I've tried the full path to
cmd.js
in my config.json file - I've tried the full path to the credentials file in my config.json file
On homebridge load:
[CMD Switch] Initializing platform accessory 'Playstation'...
When switching the device in Home app on iOS:
[CMD Switch] Turning on Playstation took too long [1s], assuming success.
[CMD Switch] Playstation is turned on.
[CMD Switch] Playstation is off.
When the above is happening, the PS4 shows that a device has connected and then it shows it's disconnected. Those interactions match up to the timing of the above "on" and "off" log entries.
My current config
"platform": "cmdSwitch2",
"name": "CMD Switch",
"switches": [{
"name" : "Playstation",
"on_cmd": "ps4-waker",
"off_cmd": "ps4-waker standby",
"state_cmd": "ps4-waker search | grep -i '200Ok'",
"polling": true,
"interval": 5,
"manufacturer": "Sony Corporation",
"model": "CUH-1001A",
"serial": "XXXXXXXXXXX"
}]
Any ideas for me to try?
@ryanschmidt I have had the exact same issues and tried just about everything. With a lot of trial and error today I managed to get this config to work using this path:
"platforms": [{ "platform": "cmdSwitch2", "name": "CMD Switch", "switches": [{ "name": "Playstation 4", "on_cmd": "node /opt/node/bin/ps4-waker -c /var/homebridge/.ps4-wake.credentials.json", "off_cmd": "node /opt/node/bin/ps4-waker -c /var/homebridge/.ps4-wake.credentials.json standby", "state_cmd": "node /opt/node/bin/ps4-waker -c /var/homebridge/.ps4-wake.credentials.json search | grep -i '200 Ok'", "polling": true, "interval": 5, "timeout": 2000, "manufacturer": "Sony Corporation", "model": "CUH-1102A", "serial": "XXXXXXXXXXX" }] }]
Hope this helps. The only problem I have now is the command takes so long to execute that Siri says it is unresponsive; but it does actually end up working.
I'm not able to get this to work... if the ps4 is on and I turn it off, it will just switch back to on and tell me it's on (and vice versa). here's what I get:
[2018-7-5 20:46:46] [CMD Switch] Initializing platform accessory 'PS4'... [2018-7-5 20:46:46] [CMD Switch] PS 4 is removed from HomeBridge. [2018-7-5 20:46:46] Homebridge is running on port 51826. [2018-7-5 20:46:46] [Wink] Refreshing devices... [2018-7-5 20:46:46] [CMD Switch] PS4 is on. [2018-7-5 20:46:46] [Wink] Refreshing access token... [2018-7-5 20:46:47] [Wink] Refreshed access token [2018-7-5 20:46:48] [CMD Switch] PS4 is on. [2018-7-5 20:46:50] [Wink] Devices refreshed [2018-7-5 20:46:50] [Wink] Checking if hub is reachable (MarHub, 192.168.1.26)... [2018-7-5 20:46:50] [Wink] Hub is reachable locally (MarHub, 192.168.1.26) [2018-7-5 20:46:50] [CMD Switch] PS4 is on. [2018-7-5 20:46:50] [Wink] Authenticated with local hub (MarHub, 192.168.1.26) [2018-7-5 20:47:34] [CMD Switch] PS4 is turned off. [2018-7-5 20:47:36] [CMD Switch] PS4 is on. [2018-7-5 20:47:53] [CMD Switch] PS4 is on. [2018-7-5 20:47:58] [CMD Switch] PS4 is turned off. [2018-7-5 20:48:01] [CMD Switch] PS4 is on. [2018-7-5 20:48:07] [CMD Switch] PS4 is turned off. [2018-7-5 20:48:11] [CMD Switch] PS4 is on. [2018-7-5 20:48:17] [CMD Switch] PS4 is turned off. [2018-7-5 20:48:22] [CMD Switch] PS4 is on.
I can turn on/off just fine with the 2nd screen app.
I don't quite understand how I can test this by manually running ps4-waker is there a way? I was able to connect to ps4-waker in the 2nd screen app.
thanks!
got it to work! found the answer here.
It's true! The above worked for me.
{
"platform": "cmdSwitch2",
"name": "CMD Switch",
"switches": [{
"name" : "Playstation",
"on_cmd": "sudo ps4-waker -c /var/homebridge/.ps4-wake.credentials.json",
"off_cmd": "sudo ps4-waker -c /var/homebridge/.ps4-wake.credentials.json standby",
"state_cmd": "sudo ps4-waker -c /var/homebridge/.ps4-wake.credentials.json search | grep -i '200 Ok'",
"polling": true,
"interval": 5,
"manufacturer": "Sony Corporation",
"model": "CUH-1001A",
"serial": "XXXXXXXXXXX"
}]
}
anybody able to get this to work with an xbox?