NorthernMan54 / homebridge-cmd-television

20 stars 1 forks source link

Location of Credential File #6

Closed Geezle27 closed 2 years ago

Geezle27 commented 2 years ago

I am not a coder but have generally been able to generally figure this process out from following the readme, @justinmm2 process and the pyatv guides. I have narrowed my issue down to one complication, not knowing where to put the atv.cred file and how to access it properly. I followed @justinmm2 process you put in the read me as I am using Homebridge on Synology Docker. Got a pairing and have created the credential file. I tried putting it in a couple of places and can't figure out where it should go. I think it just goes in the root Homebridge folder. My installation seams to be able to find it but I am getting a permission error.

[12/11/2021, 10:07:00 PM] [AppleTV 2] getPowerState error: Error: Command failed: atvremote -s 192.168.1.3 --companion-credentials `cat ~/atv.cred` power_state
cat: /root/atv.cred: Permission denied
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: the following arguments are required: command

Any help would be appreciated.

justinmm2 commented 2 years ago

HI @Geezle27 - it sounds like you might be using the Homebridge Terminal that you can launch from the UI. Here are some thoughts that might help; I hope they aren't overly detailed.

I'm guessing that the atvremote command is giving a syntax error because the cat ~/atv.cred (sub)command is failing due to the permission denied error. When it does, an empty value ("") is being substituted instead of the credentials. This means your instance is trying to execute a command that looks like this: atvremote -s 192.168.1.3 --companion-credentials power_state This is why atvremote thinks you are giving an incorrect syntax; it thinks "power_state" are the credentials you're passing, and doesn't see a command anywhere.

So that means you need to fix the permissions on ~/atv.cred. Hopefully this is as simple as a chmod. Try this: chmod 644 ~/atv.cred

If your instance is anything like mine, this should square you away: the terminal runs as the root user, so you should be able to give read permission to the atv.cred file. One thing I'll add, though: if you're familiar with the command-line, I'd try moving the credential file to /homebridge/ so that it gets backed up and sits along side the rest of the Homebridge files. And then modifying your config accordingly (i.e, pointing at /homebridge/atv.cred, not ~/atv.cred (=/root/atv.cred)

Ultimately, I ended up mixing and matching things (airplay and companion credentials) last night, because the "turn_off" command acted as a toggle, not an idempotent off switch: when I ran "turn_off" with the TV off, it would turn the TV on.

Geezle27 commented 2 years ago

Sorry to not follow up on this. I didn't get a chance to tinker over the holidays. @justinmm2 I get your instructions but I am still having issues.

One thing I might be doing wrong is creating the credentials file. Is there a specific way to do this? Is it just a text file with the credential pasted into it or is there something else that needs to be done?