MrAsterisco / homebridge-hisense-tv

A Homebridge plugin to control RemoteNow-compatible HiSense TVs.
MIT License
21 stars 8 forks source link

Error unknown network interface #32

Closed coralienyr closed 4 months ago

coralienyr commented 2 years ago

Hi, I need help to install this plugin on my homebridge on macOS (I would like to try this on my Mac before to buy a Raspberry)

When I do python3.8 hisensetv.py <TV_IP_ADDRESS> --authorize --ifname <NETWORK_INTERFACE_NAME> I get this error : Unknown network interface: en0

I'm on Mac so ip a doesn't work but I do a route -n get "MyIP" | awk '/interface: / {print $2}' this getting me "en0"

how to do this please ?

MrAsterisco commented 2 years ago

Hi @coralienyr ! Thanks for opening this issue!

In order to list the network interface names on macOS, you can run the following command:

networksetup -listallhardwareports

You should see something like this as output:

Hardware Port: USB 10/100/1000 LAN
Device: en7
Ethernet Address: <redacted>

Hardware Port: Wi-Fi
Device: en0
Ethernet Address: <redacted>

Hardware Port: Bluetooth PAN
Device: en6
Ethernet Address: <redacted>

Hardware Port: Thunderbolt 1
Device: en1
Ethernet Address: 82:2b:b7:e2:50:01

Hardware Port: Thunderbolt 2
Device: en2
Ethernet Address: <redacted>

Hardware Port: Thunderbolt 3
Device: en3
Ethernet Address: <redacted>

Hardware Port: Thunderbolt 4
Device: en4
Ethernet Address: <redacted>

Hardware Port: Thunderbolt Bridge
Device: bridge0
Ethernet Address: <redacted>

What you're looking for is the Device name.

I will add this command to the README, so that it makes it easier for macOS users.

Please let me know if this solved your problem by closing the issue once you're done.

coralienyr commented 2 years ago

Yes so it's Hardware Port : Wi-Fi so Device is en0 but I have error Unknown network interface: en0

MrAsterisco commented 2 years ago

So, @coralienyr you might have uncovered a bigger issue with running this on macOS. I ran the same command here and this is the full output I got:

[2022-01-25 11:39:40,840] [INFO    ] Unverified SSL context created.
Traceback (most recent call last):
  File "/Users/alessio/Downloads/homebridge-hisense-tv-master/bin/hisensetv/__init__.py", line 64, in get_mac_address
    info = fcntl.ioctl(s.fileno(), 0x8927, struct.pack('256s', bytes(ifname, 'utf-8')[:15]))
OSError: [Errno 6] Device not configured

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/alessio/Downloads/homebridge-hisense-tv-master/bin/hisensetv.py", line 6, in <module>
    __main__.main()
  File "/Users/alessio/Downloads/homebridge-hisense-tv-master/bin/hisensetv/__main__.py", line 125, in main
    tv = HisenseTv(
  File "/Users/alessio/Downloads/homebridge-hisense-tv-master/bin/hisensetv/__init__.py", line 119, in __init__
    self._mac = get_mac_address(network_interface)
  File "/Users/alessio/Downloads/homebridge-hisense-tv-master/bin/hisensetv/__init__.py", line 67, in get_mac_address
    raise HisenseTvError("Unknown network interface: " + ifname)
hisensetv.HisenseTvError: Unknown network interface: en0

The interesting bit is here:

OSError: [Errno 6] Device not configured

I then found this StackOverflow question where they seem to acknowledge that this is a common macOS issue when using low-level network commands (also see https://github.com/Jahaja/psdash/issues/5).

They suggest using this module, but that would add a dependency to the script, making it harder to install and use.

This then brought me back to https://github.com/MrAsterisco/hisensetv/issues/1, which has the same output as you. So, unfortunately macOS is not supported as of right now. I'll update the README to clearly state so, because this is not clear right now.

As a suggestion: you can run VMs on your Mac using VMWare Fusion for free with a personal license. You can then install a Ubuntu VM to try this plugin out before buying additional hardware.

coralienyr commented 2 years ago

Okay so to try, I have a computer with Debian 11 (it's not mine but I want to try before to buy a Raspberry)

I configured all the plugin and my TV show me a code, then Homebridge show me the code to add my tv to Home

After I add this code to my Home App and I saw my TV on my home but now, I have this error on homebridge : [HiSenseTV] An error occurred while fetching inputs: TypeError: Cannot read property 'join' of null and the accessory on the home app say "without response"

MrAsterisco commented 2 years ago

@coralienyr This error usually means that you haven't completed the authorization process. The code that your TV is showing should be input in the script: did you do that (it's not clear from the steps you're mentioning)?

MrAsterisco commented 2 years ago

@coralienyr as a side note, I just released version 2 of the plugin (including a new version of the Python script) and we now have full compatibility with macOS! 🎉 Please refer to the release documentation on how to upgrade, or to the README on how to install.

coralienyr commented 2 years ago

@MrAsterisco thank you it's working But on inputs I only have "unknown"

MrAsterisco commented 2 years ago

@coralienyr if this is the first time, you may need to turn on the TV, then force quit the Home app and open it again in order to see the inputs.

coralienyr commented 2 years ago

@MrAsterisco Nope does'nt work and now when I tried to turn off the tv from the Home app, the app said me the accessory doesn't respond

MrAsterisco commented 2 years ago

@coralienyr are you able to run the Python script again with the following command?

python3 <path/to/bin/hisense.py> --get sources <TV IP Address> --ifname <ifname>

If so, what is the output?

LeLunZ commented 4 months ago

Issue will be closed as the main issue is done. @coralienyr if you still use the TV and want to try the plugin again give it a go :) New issues are welcome