MrAsterisco / homebridge-hisense-tv

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

SyntaxError #39

Closed dhanzseros closed 2 years ago

dhanzseros commented 2 years ago

Hey!

I am trying for a day to work this plugin, but I can not pair my TV with Debian. When I run this: python3.5 hisensetv.py 192.168.10.99 --authorize --ifname enp30s0 --no-ssl

TV type: Hisense 55a7gq

I always get this syntax error:

Logs:

Traceback (most recent call last): File "hisensetv.py", line 3, in from hisensetv import main File "/usr/lib/node_modules/homebridge-hisense-tv-remotenow/bin/hisensetv/init.py", line 52 f"you must be connected to call {func.name}" ^ SyntaxError: invalid syntax

Environment:

ryanshand commented 2 years ago

You need to update your python to 3.8

dhanzseros commented 2 years ago

Hey!

I have updated it. But it does not work. The log says:

2022-05-10 23:20:52,451] [INFO ] No SSL context specified. [2022-05-10 23:20:52,451] [INFO ] Network interface MAC Address: 78:e3:b5:fc:0a:51 Traceback (most recent call last): File "hisensetv.py", line 6, in main.main() File "/usr/lib/node_modules/homebridge-hisense-tv-remotenow/bin/hisensetv/main.py", line 128, in main with tv: File "/usr/lib/node_modules/homebridge-hisense-tv-remotenow/bin/hisensetv/init.py", line 144, in enter raise HisenseTvTimeoutError(f"failed to connect in {self.timeout:.3f}s") hisensetv.HisenseTvTimeoutError: failed to connect in 10.000s

Can you help me? I tried with SSL but it drops another error:

[2022-05-10 23:21:52,506] [INFO ] Unverified SSL context created. [2022-05-10 23:21:52,506] [INFO ] Network interface MAC Address: 78:e3:b5:fc:0a:51 Traceback (most recent call last): File "hisensetv.py", line 6, in main.main() File "/usr/lib/node_modules/homebridge-hisense-tv-remotenow/bin/hisensetv/main.py", line 128, in main with tv: File "/usr/lib/node_modules/homebridge-hisense-tv-remotenow/bin/hisensetv/init.py", line 136, in enter self._mqtt_client.connect(self.hostname, self.port) File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 914, in connect return self.reconnect() File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 1073, in reconnect sock.do_handshake() File "/usr/local/lib/python3.8/ssl.py", line 1309, in do_handshake self._sslobj.do_handshake() ssl.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:1108)

ryanshand commented 2 years ago

If your TV is new(ish) within the last 24 months it likely needs the SSL config enabled. However you need to ensure you have downloaded the certificates from herehttps://github.com/MrAsterisco/hisensetv/tree/master/cert and uploaded them to your homebridge device and then reference the path. More than likely your ssl handshake failure is due to not referencing the certificate paths, although I can't confirm that without seeing your config.

there was a bit of discussion about it in Issue #3 that we solved that might help, or given you have the same issue as Issue #28 perhaps you should start there.

dhanzseros commented 2 years ago

Hey,

Thank you for your reply! Yes I am using cert files and enabled the SSL in the config before. I am going to read the issues you showed my above, one of them I have read already.

By the way this TV is a 2022 model. I have paired with my mobile app. And it works with Node red/MQTT connection/Homekit bridge :)

The config for this plugin: { "ifname": "enp30s0", "devices": [ { "id": "Nappali", "name": "HiSense", "ipaddress": "192.168.10.99", "macaddress": "A0:62:FB:E5:7B:44", "sslmode": "custom", "sslcertificate": "/home/hdavid/hi_keys/rcm_certchain_pem.cer", "sslprivatekey": "/home/hdavid/hi_keys/rcm_pem_privkey.pkcs8" } ], "platform": "HiSenseTV" }

Thanks!

ryanshand commented 2 years ago

Before you use the plugin, you’ll need to get the pin code by running this from command line

python3.8 hisensetv.py <TV_IP_ADDRESS> --authorize --ifname <NETWORK_INTERFACE_NAME> --certfile /pathtoFile --keyfile /pathtoFile

If this fails, can you change authorize to get state (two words) and post a screenshot or output from command line?

dhanzseros commented 2 years ago

Hey,

I tried this command and it worked, the TV showed the 4 digit number, I wrote it into the plugin and no error. After that I tried to add into homekit, I have added but it does not work, it does not answer. The get state this shows:

Képernyőfotó 2022-05-12 - 8 46 51
dhanzseros commented 2 years ago

Is it a problem the Hisense setup code is the same as my hombridge code?

And in homebridge log there is only one error line all the time: [HiSenseTV] An error occurred while fetching inputs: TypeError: Cannot read property 'join' of null

ryanshand commented 2 years ago

can you enable debug logging in homebridge? from settings, tick this box and restart the service image

can you also confirm you've installed paho-mqtt and netifaces? pip3 install paho-mqtt pip3 install netifaces

dhanzseros commented 2 years ago

I have installed this but it shows python3.5 instead of 3.8. Requirement already satisfied: paho-mqtt in /usr/local/lib/python3.5/dist-packages

So after that I have installed with this: pip3.8 install paho-mqtt and so on... Here you can find the command lines:

root@Debian:/home/hdavid# pip3 install paho-mqtt Requirement already satisfied: paho-mqtt in /usr/local/lib/python3.5/dist-packages root@Debian:/home/hdavid# pip3.8 install paho-mqtt Requirement already satisfied: paho-mqtt in /usr/local/lib/python3.8/site-packages (1.6.1) WARNING: You are using pip version 19.2.3, however version 22.0.4 is available. You should consider upgrading via the 'pip install --upgrade pip' command. root@Debian:/home/hdavid# pip install --upgrade pip DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality. Requirement already up-to-date: pip in /usr/local/lib/python2.7/dist-packages (20.3.4) root@Debian:/home/hdavid# pip3.8 install paho-mqtt Requirement already satisfied: paho-mqtt in /usr/local/lib/python3.8/site-packages (1.6.1) WARNING: You are using pip version 19.2.3, however version 22.0.4 is available. You should consider upgrading via the 'pip install --upgrade pip' command. root@Debian:/home/hdavid# python3 -V Python 3.5.3 root@Debian:/home/hdavid# python3.8 -V Python 3.8.2 root@Debian:/home/hdavid#

So maybe the python causes the problem?

dhanzseros commented 2 years ago

In debug mode theres an error what it looks like: "An error occurred while connecting to TV: Error: connect EHOSTUNREACH 192.168.10.99:36669" But I can telnet into the tv without any problem...

MrAsterisco commented 2 years ago

@dhanzseros have you tried to telnet from the same machine that's running Homebridge? Also, is Homebridge running on a different user, by any chance? Do you have a firewall turned on?

Anyway, this is not an issue of the plugin itself: for some reason, your Homebridge instance is unable to reach your TV.