Client to control Android TV.
Create the client:
AndroidTVPairingClient tvPairingClient = new AndroidTVPairingClient("192.168.1.90");
Initiate the pairing process:
await tvPairingClient.InitiatePairingAsync();
TV should display a 6 letter pairing code on the screen. Pass it to the pairing client and the pairing client will return a certificate that you should store somewhere safe:
string certificate = await tvPairingClient.CompletePairingAsync("1234AB");
To turn on the TV if you know the MAC address:
await AndroidTVClient.TurnOnAsync("192.168.1.90", "FF:FF:FF:FF:FF:FF");
If you don't know the MAC address, but you are running on Windows/MacOS/Linux where your process can access the terminal, run:
await AndroidTVClient.TurnOnAsync("192.168.1.90");
This will attempt to use ARP to resolve the MAC address from the IP address.
To control the TV, create the client and pass the certificate from the AndroidTVPairingClient
:
AndroidTVClient tvClient = new AndroidTVClient("192.168.1.90", certificate);
Send a volume up key:
await tvClient.PressKeyAsync(KeyCodes.KEYCODE_VOLUME_UP, KeyAction.Down);
await tvClient.PressKeyAsync(KeyCodes.KEYCODE_VOLUME_UP, KeyAction.Up);
Open Netflix:
tvClient.StartApplication("https://www.netflix.com/title.*");
Get current TV configuration:
var configuration = tvClient.GetConfiguration();
This project is based upon the research from here: https://github.com/Aymkdn/assistant-freebox-cloud/wiki/Google-TV-(aka-Android-TV)-Remote-Control-(v2)