homebridge-cmd-television icon indicating copy to clipboard operation
homebridge-cmd-television copied to clipboard

powerstate error

Open iogitio opened this issue 2 years ago • 6 comments

[4/21/2022, 10:50:48] [cmd-television] getPowerState error: Error: Command failed: atvremote --id AA:AA:AA:AA:AA --airplay-credentials `cat /homebridge/atv_airplay.cred` --companion-credentials `cat /homebridge/atv_companion.cred` power_state
usage: atvremote [-h] [-i ID] [-n NAME] [--address ADDRESS]
                 [--protocol PROTOCOL] [--port PORT] [-t TIMEOUT]
                 [-s SCAN_HOSTS] [--scan-protocols SCAN_PROTOCOLS] [--version]
                 [--remote-name REMOTE_NAME] [-p PIN]
                 [--pairing-guid PAIRING_GUID] [-m]
                 [--raop-password RAOP_PASSWORD]
                 [--dmap-credentials DMAP_CREDENTIALS]
                 [--mrp-credentials MRP_CREDENTIALS]
                 [--airplay-credentials AIRPLAY_CREDENTIALS]
                 [--companion-credentials COMPANION_CREDENTIALS]
                 [--raop-credentials RAOP_CREDENTIALS] [-v] [--debug]
                 [--mdns-debug]
                 command [command ...]
atvremote: error: unrecognized arguments: PIN on screen: Pairing seems to have succeeded, yey! You may now use these credentials: 1234567883a80b24b0b7bfdc572f6af683c4ad70c8efd24:36ce6b64a89ed21b59426d66e42ff1a2cc12a59fac05bcaded9ff1d3be1562e2:37304338314535412d323446342d344338382d424430452d354244303245363442354633:38336439613431652d323466352d346634342d396232302d363231621238491231236666 power_state

I'm getting the error above and the Home app shows the Apple TV as not connected... any advice on this, stumped? :(

iogitio avatar Apr 29 '22 06:04 iogitio

Looks like a typo of some sort in your config.json, or the credential file. The atvremote command is failing

NorthernMan54 avatar Apr 29 '22 13:04 NorthernMan54

    {
        "accessory": "cmd-television",
        "name": "cmd-television",
        "oncmd": "atvremote --id AA:AA:11:11:BB:BB --airplay-credentials `cat /homebridge/atv_airplay.cred` --companion-credentials `cat /homebridge/atv_companion.cred` turn_on",
        "offcmd": "atvremote --id AA:AA:11:11:BB:BB --airplay-credentials `cat /homebridge/atv_airplay.cred` --companion-credentials `cat /homebridge/atv_companion.cred` turn_off",
        "pausecmd": "atvremote --id AA:AA:11:11:BB:BB --airplay-credentials `cat /homebridge/atv_airplay.cred` --companion-credentials `cat /homebridge/atv_companion.cred` pause",
        "playcmd": "atvremote --id AA:AA:11:11:BB:BB --airplay-credentials `cat /homebridge/atv_airplay.cred` --companion-credentials `cat /homebridge/atv_companion.cred` play",
        "powerstatecmd": "atvremote --id AA:AA:11:11:BB:BB --airplay-credentials `cat /homebridge/atv_airplay.cred` --companion-credentials `cat /homebridge/atv_companion.cred` power_state"
    }

I used the config sample (and edited in my MAC ID and cred location ... nothing obvious that looks wrong? :/

iogitio avatar Apr 30 '22 01:04 iogitio

If your cred files have a space or a blank line it could cause this.

NorthernMan54 avatar May 02 '22 22:05 NorthernMan54

the cred files were spit out from the command, but I did double-check and there's no blank lines :/

And just in case my cred file is the issue, the file itself looks something like this:

Enter PIN on screen: Pairing seems to have succeeded, yey! You may now use these credentials: 4cfe812345678901238172389172389712383c4ad70c8efd24:bb213123123f60d02271a7ae14ef4bf66c4197990ced72effd9feb:37304338312312312992d344338382d424430452d3542443032451231231234633:63666233363962322d353961302d343963372d393035632d643763396212736182736

iogitio avatar May 02 '22 23:05 iogitio

The contents of the file should be a single line with just the credential ie

4cfe812345678901238172389172389712383c4ad70c8efd24:bb213123123f60d02271a7ae14ef4bf66c4197990ced72effd9feb:37304338312312312992d344338382d424430452d3542443032451231231234633:63666233363962322d353961302d343963372d393035632d643763396212736182736

NorthernMan54 avatar May 02 '22 23:05 NorthernMan54

@NorthernMan54 thank you!!!! THAT fixed my issue!!!!!!! Thanks for helping + for getting this plugin to the finish line for us to use!!!

For others: pretty sure my problem was using the Homebridge terminal to enter the Apple TV 4-digit PIN code. There's no visual cue as to what's happening when the cred files are being created. It added the first two unnecessary lines to the file, removing them fixed it! :)

iogitio avatar May 03 '22 08:05 iogitio