lukasroegner / homebridge-apple-tv-remote

Plugin for controlling Apple TVs in homebridge.
MIT License
132 stars 13 forks source link

API Documentation #8

Closed BrandonHacks closed 4 years ago

BrandonHacks commented 4 years ago

Hey there. I'm so glad to have a working plugin for powering on/off my apple tv's. Regarding the API... I am not too educated with this code. How do I execute the commands? I'm assuming it's not within homekit?

lukasroegner commented 4 years ago

Hi @BrandonHacks,

The API can be used in HomeKit shortcuts or Siri shortcuts. Originally, I used the "Get content from URL" action in the shortcuts. Thanks to Apple's strict "one more bug per update" policy, those are not working in the latest iOS/tvOS version 13.3.1.

Currently, you can use the API with the "Run SSH script" action. Enter the credentials of your homebridge host (IP address, user name, password). Then, build a script that does the HTTP call using cURL or wget, e.g.

curl -X POST 'http://localhost:40304/<NAME-OF-APPLE-TV>' -H 'Content-Type: application/json' -H 'Authorization: <YOUR-API-TOKEN>' --data-raw '{"commands":[{"key":"topmenu"}]}'

to press the top menu button.