luisiam / homebridge-cmdswitch2

CMD Plugin for HomeBridge (API 2.0): https://github.com/nfarina/homebridge
Apache License 2.0
176 stars 29 forks source link

Failing to shutdown xbox one #53

Closed Garulf closed 4 years ago

Garulf commented 4 years ago

I'm currently using the python package: https://github.com/OpenXbox/xbox-smartglass-core-python to control my xbox one.

While the off command runs as it should in manual testing, homebridge fails.

Config:

              {
                "name": "Xbox One",
                "on_cmd": "/usr/bin/xbox-poweron XXXXX",
                "off_cmd": "/usr/bin/xbox-poweroff --liveid XXXXX",
                "state_cmd": "xbox-discover | grep -iq 'no consoles discovered!'; test $? -eq 1",
                "polling": true,
                "interval": 5,
                "timeout": 200,
                "manufacturer": "Microsoft",
                "model": "XXXXX",
                "serial": "XXXXXXXXXXXX"
              }

Log: [12/30/2019, 10:24:14 AM] [CMD Switch] Failed to turn off Xbox One [12/30/2019, 10:24:14 AM] [CMD Switch] INFO:authentication:Loaded token <class 'xbox.webapi.authentication.token.AccessToken'> from file INFO:authentication:Loaded token <class 'xbox.webapi.authentication.token.RefreshToken'> from file INFO:authentication:Loaded token <class 'xbox.webapi.authentication.token.UserToken'> from file INFO:authentication:Loaded token <class 'xbox.webapi.authentication.token.XSTSToken'> from file

I'm at a loss as to what could be the issue, as the command works fine when run manually.

Garulf commented 4 years ago

Had to pipe stdout to stderr to get anything meaningful from log.

[12/30/2019, 6:57:37 PM] [CMD Switch] Failed to turn off Xbox One [12/30/2019, 6:57:37 PM] [CMD Switch] INFO:authentication:Loaded token <class 'xbox.webapi.authentication.token.AccessToken'> from file INFO:authentication:Loaded token <class 'xbox.webapi.authentication.token.RefreshToken'> from file INFO:authentication:Loaded token <class 'xbox.webapi.authentication.token.UserToken'> from file INFO:authentication:Loaded token <class 'xbox.webapi.authentication.token.XSTSToken'> from file Failed to authenticate with provided tokens, Error: [Errno 13] Permission denied: '/root/.local/share/xbox/tokens.json' Please re-run xbox-authenticate to get a fresh set

Simply made a copy, changed permissions and changed command to: "off_cmd": "/usr/bin/xbox-poweroff -t '~/tokens.json' --liveid 'FD00B7497FDFD20A' 1>&2",