JeffLIrion / homeassistant_native_firetv

43 stars 16 forks source link

Couldn't connect to host: IP:5555, error: No such file or directory #12

Closed BnMcG closed 6 years ago

BnMcG commented 6 years ago

Hi,

I'm trying to set this up on Hassbian, using the latest version of native_firetv pulled from the repo's master branch today, and HA 0.79.3.

Here's my config:

media_player:
  - platform: firetv
    name: Fire TV 1
    host: 192.168.0.11
    adbkey: "/home/homeassistant/.homeassistant/android/adbkey"

I can ping the Fire TV on this IP fine, ADB is enabled on the TV, and I've pre-authorized the key by generating from my laptop and then copying adbkey to the path above. I've confirmed that the key should be allowed on the Fire TV, and checked the "Always" box.

Permissions on the key file:

-rw-r--r--  1 homeassistant homeassistant 1704 Oct  6 21:46 adbkey

Log messages:

Oct 06 22:22:39 assistant hass[8345]: 2018-10-06 22:22:39 WARNING (Thread-11) [root] Couldn't connect to host: 192.168.0.11:5555, error: No such file or directory
Oct 06 22:22:39 assistant hass[8345]: 2018-10-06 22:22:39 WARNING (Thread-11) [custom_components.media_player.firetv] Could not connect to Fire TV at 192.168.0.11:5555 using adbkey='/home/homeassistant/.homeassistant/android/adbkey'

And this in the UI, as well:

Found malformed XML at http://192.168.0.11:9080: status=ok

Anything I can do to help fix this? I've tried restarting the Fire TV and HA several times.

BnMcG commented 6 years ago

I added a little bit of logging and can confirm it's at least parsing the ADB path correctly: Using ADB key at /home/homeassistant/.homeassistant/android/adbkey.

I've also chmodded this file to 777 temporarily, so there shouldn't be a permissions issue either.

Some more digging, and the error seems to stem from this method in the python-firetv package: https://github.com/happyleavesaoc/python-firetv/blob/master/firetv/__init__.py#L107

JeffLIrion commented 6 years ago

That's a strange error. I did a quick search about the "malformed XML" error and it seems like that's just something that happens occasionally in Home Assistant and doesn't necessarily cause problems.

Did you copy both the "adbkey" and "adbkey.pub" files to that directory?

Please try this version of the code and let me know what the log says: https://github.com/JeffLIrion/homeassistant_native_firetv/blob/fix-issue12/media_player/firetv.py

BnMcG commented 6 years ago

@JeffLIrion You're completely right, I only copied adbkey, I forgot the public key. It seems the only thing at fault here is my reading comprehension.

I think my only saving grace here is that the error message isn't terribly explicit. If you'd accept such a PR, I'd be happy to code something up that tests that the path provided in the config provides both a public and private key, and if not throw a more specific error.

I figured this out in the end by running the ADB code that python-firetv is using through a REPL, and found that it specifically complained it couldn't sign messages as the public key was missing.

I appreciate that a more thorough reading of the README would've avoided this issue though, so if you're happy to leave as-is I won't be offended!

JeffLIrion commented 6 years ago

I think my only saving grace here is that the error message isn't terribly explicit. If you'd accept such a PR, I'd be happy to code something up that tests that the path provided in the config provides both a public and private key, and if not throw a more specific error.

That would be helpful, thanks!