Native support for Fire TV


#82

I’m getting the same error with HA 0.79.2 when trying to set up firetv for the first time.
I got the adbkey and adbkey.pub in the config/android folder which I have configured in the configuration.yaml file. Everything else seems ok except this error.
Restarting the firetv and my PI3B where HA resides won’t help.
I’m also no programmer so I’m basically copy&pasting from several ressources and hope to get it running with some basic logic thinking :wink:


#83

If you see the line data=rsa_keys[0].GetPublicKey() + b'\0') in your error message, it’s a problem with your key. Please see the section “Issue: Error while setting up platform firetv (with an ADB key)” in the Troubleshooting section of the README.


#84

FYI. I know it’s out of your control but I thought I should give you a heads up. When I upgraded from HA v 0.78.x to v 0.79.2, all firesticks entities disappeared until I physically rebooted each firestick and restarted HA again.


#85

Do you have the corresponding log entries? I know some people have had this issue when upgrading HA, but I don’t know why.


#86

It’s been consistent during the past 4 HA updates. The firetv entities disappear and the log contains what is below. My final cure is just to visit each firestick and do a Settings > Device > Reset and then restart HA. Reboot of PI not required.

File “/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py”, line 128, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File “/usr/local/lib/python3.6/asyncio/tasks.py”, line 358, in wait_for
return fut.result()
File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/media_player/firetv.py”, line 53, in setup_platform
device = FireTVDevice(host, name, adbkey)
File “/config/custom_components/media_player/firetv.py”, line 91, in init
self._firetv = FireTV(host, adbkey)
File “/config/deps/lib/python3.6/site-packages/firetv/init.py”, line 105, in init
self.connect()
File “/config/deps/lib/python3.6/site-packages/firetv/init.py”, line 120, in connect
self._adb = adb_commands.AdbCommands().ConnectDevice(serial=self.host)
File “/config/deps/lib/python3.6/site-packages/adb/adb_commands.py”, line 142, in ConnectDevice
self._Connect(**kwargs)
File “/config/deps/lib/python3.6/site-packages/adb/adb_commands.py”, line 173, in _Connect
conn_str = self.protocol_handler.Connect(self._handle, banner=banner, **kwargs)
File “/config/deps/lib/python3.6/site-packages/adb/adb_protocol.py”, line 314, in Connect
cmd, arg0, arg1, banner = cls.Read(usb, [b’CNXN’, b’AUTH’])
File “/config/deps/lib/python3.6/site-packages/adb/adb_protocol.py”, line 243, in Read
cmd, arg0, arg1, data_length, data_checksum = cls.Unpack(msg)
File “/config/deps/lib/python3.6/site-packages/adb/adb_protocol.py”, line 228, in Unpack
raise ValueError(‘Unable to unpack ADB command.’, cls.format, message, e)
ValueError: (‘Unable to unpack ADB command.’, b’<6I’, b’’, error(‘unpack requires a buffer of 24 bytes’,))


#87

Thanks! It seems as if the adbkey file got corrupted. I regenerated it, copied it again and now it works!


#88

@JeffLIrion Thanks you. It works fine


#89

@JeffLIrion I have the media player working well, thank you. Is it possible for me now to send a pause command to my firetv from a script or automation, perhaps using an http command?


#90

Definitely. This should work:

- service: media_player.media_pause
  entity_id: media_player.<your Fire TV>

#91

Thank you sir. Works perfectly. Very appreciative.


#92

I read that this component also works with Android boxes. Is that true?

And just to clarify, do I need to enable adb on my device? I’m guessing yes?


#93

I don’t have an Android box, so I don’t know.

Yes, you definitely need to enable ADB on the device. Setup info can be found in the README: https://github.com/JeffLIrion/homeassistant_native_firetv/blob/master/README.md


#94

Can you tell me, where to place the ADB-Key ?
Is the “/config/android/adbkey” an folder in the “/custom_components/media_player” ?

Thanks in advance.


#95

First of all, note that there are two files that you need: adbkey and adbkey.pub.

You can place them anywhere in your configuration folder, just make sure you specify the correct path to adbkey in your configuration.


#96

Hey Jeff,

call me stupid, but I’m standing on the hose. I have the two necessary files in a folder “android” in my configuration directory, this is “/home/homeassistant/.homeassistant”.
What must be the definition in the configuration now?
Only “/android/adbkey” ? This won’t work.


#97

use an absolute path: /home/homeassistant/.homeassistant/android/adbkey
/android/adbkey refers to a folder that probably does not exist in your file root.


#98

hi there,
I’m struggling to get this going - followed steps to get the adbkey but getting a file not found error:

FileNotFoundError: [Errno ADB private key %s does not exist] /volume1/docker/homeassistant/config/custom_components/media_player/android/adbkey

is this the file does not exist / the location is incorrect
OR
is the correct key not present in the file

I’ve got the adbkey from my PC and then copied the adbkey over to the custom_components folder. cant figure out what i’m not doing right.
Any help would be greatly appreciated


#99

Did you copy the adbkey file to the custom_components folder or the custom_components/media_player/android folder?


#100

Thanks for the response. Copied to custom_components/media_player/android


#101

Here is what one of mine looks like:

- platform: firetv
  name: firetv_406_livingroom
  host: "192.168.1.193:5555"
  adbkey: "/config/android/adbkey"

the file is just one folder “android” within the “config” folder where all my .yaml’s are.