Insigna FireTV working and paired with ADB... The power command is unfortunately a toggle. But did figure out how to "sense" if on or off. Work to do: additional command which runs the following command and then handles the command properly rather than toggle based on current state.
Identify whether or not TV is on or off (probably want to put this into a status variable?):
adb shell dumpsys display | grep "mScreenState"
mScreenState=OFF
or
mScreenState=ON
pi@Allonis:~ $ adb shell dumpsys display | grep "mScreenState"
mScreenState=OFF
pi@Allonis:~ $ adb shell dumpsys display | grep "mScreenState"
mScreenState=ON
pi@Allonis:~ $
would be nice if myServer would run the following command to track what is currently running and put data into a variable. That way we can use the automation engine and launch a different app if home screen is current focus or whatever:
adb shell dumpsys activity activities | grep mFocusedActivity
pi@Allonis:~ $ adb shell dumpsys activity activities | grep mFocusedActivity
mFocusedActivity: ActivityRecord{720cf0e u0 com.amazon.tv.launcher/.ui.HomeActivity_vNext t158}
Appears that sendkey SLEEP powers off always and not toggle. POWER turns back on, but still toggles unfortunately.
If desired state is to be OFF then send keycode SLEEP. If desired state is to be ON and if queried state is returns OFF then send keycode POWER, otherwise ignore.
We have also succesfully controlled some Insignia TVs via a video matrix CEC command. As another control alternative to AndroidADB.