TassSinclair / zte-zxhn-h268a-presence-detection

Home Assistant presence detection module for ZTE ZXHN h268a
2 stars 5 forks source link

Error setting up platform zte #1

Open vlasov01 opened 4 years ago

vlasov01 commented 4 years ago

Hi,

Thank you for taking on this project!

I've followed your configuration procedure. But got the following error after restart of my Home Assistant:

2020-04-11 00:42:44 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform zte
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/device_tracker/__init__.py", line 170, in async_setup_platform
    platform.get_scanner, hass, {DOMAIN: p_config})
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/zte/device_tracker.py", line 32, in get_scanner
    tracked_devices, excluded_devices)
  File "/config/custom_components/zte/device_tracker.py", line 40, in __init__
    from zte_client import ZteClient
ModuleNotFoundError: No module named 'zte_client'

Home Assistant Version 0.92.2

My ZTE H268A device info: Hardware Version V1.0.4 Software Version V1.0.2_CA1T7 Boot Version V1.0.0

Could you please help?

vlasov01 commented 4 years ago

I've created setup.py to resolve error "ModuleNotFoundError: No module named 'zte_client'":

from setuptools import setup

setup(
   name='zte_client',
   version='1.0',
   description='A useful module to read ZTE info',
   author='Man Foo',
   author_email='foomail@foo.com',
   packages=['zte_client'],  #same as name
   install_requires=['ZteClient', 'argparse', 'requests', 'logging', 'hashlib', 'collections', 'xml' ], #external packages as dependencies
)

and run installation

bash-4.4# python setup.py install
running install
running bdist_egg
running egg_info
creating zte_client.egg-info
writing zte_client.egg-info/PKG-INFO
writing dependency_links to zte_client.egg-info/dependency_links.txt
writing requirements to zte_client.egg-info/requires.txt
writing top-level names to zte_client.egg-info/top_level.txt
writing manifest file 'zte_client.egg-info/SOURCES.txt'
reading manifest file 'zte_client.egg-info/SOURCES.txt'
writing manifest file 'zte_client.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-armv7l/egg
running install_lib
running build_py
creating build
creating build/lib
creating build/lib/zte_client
copying zte_client/__main__.py -> build/lib/zte_client
copying zte_client/__init__.py -> build/lib/zte_client
creating build/bdist.linux-armv7l
creating build/bdist.linux-armv7l/egg
creating build/bdist.linux-armv7l/egg/zte_client
copying build/lib/zte_client/__main__.py -> build/bdist.linux-armv7l/egg/zte_client
copying build/lib/zte_client/__init__.py -> build/bdist.linux-armv7l/egg/zte_client
byte-compiling build/bdist.linux-armv7l/egg/zte_client/__main__.py to __main__.cpython-37.pyc
byte-compiling build/bdist.linux-armv7l/egg/zte_client/__init__.py to __init__.cpython-37.pyc
creating build/bdist.linux-armv7l/egg/EGG-INFO
copying zte_client.egg-info/PKG-INFO -> build/bdist.linux-armv7l/egg/EGG-INFO
copying zte_client.egg-info/SOURCES.txt -> build/bdist.linux-armv7l/egg/EGG-INFO
copying zte_client.egg-info/dependency_links.txt -> build/bdist.linux-armv7l/egg/EGG-INFO
copying zte_client.egg-info/requires.txt -> build/bdist.linux-armv7l/egg/EGG-INFO
copying zte_client.egg-info/top_level.txt -> build/bdist.linux-armv7l/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/zte_client-1.0-py3.7.egg' and adding 'build/bdist.linux-armv7l/egg' to it
removing 'build/bdist.linux-armv7l/egg' (and everything under it)
Processing zte_client-1.0-py3.7.egg
Copying zte_client-1.0-py3.7.egg to /usr/local/lib/python3.7/site-packages
Adding zte-client 1.0 to easy-install.pth file

Installed /usr/local/lib/python3.7/site-packages/zte_client-1.0-py3.7.egg
Processing dependencies for zte-client==1.0
Searching for ZteClient
Reading https://pypi.org/simple/ZteClient/
Couldn't find index page for 'ZteClient' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.org/simple/
No local packages or working download links found for ZteClient
error: Could not find suitable distribution for Requirement.parse('ZteClient')

Where I can get ZteClient ?

vlasov01 commented 4 years ago

I've revised setup.py to:

from setuptools import setup

setup(
   name='zte_client',
   version='1.0',
   description='A useful module to read ZTE info',
   author='Man Foo',
   author_email='foomail@foo.com',
   packages=['zte_client'],  #same as name
   install_requires=['argparse', 'requests' ], #external packages as dependencies
)

And than I've got the following error:

2020-04-11 04:05:39 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform zte
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/device_tracker/__init__.py", line 170, in async_setup_platform
    platform.get_scanner, hass, {DOMAIN: p_config})
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/zte/device_tracker.py", line 32, in get_scanner
    tracked_devices, excluded_devices)
  File "/config/custom_components/zte/device_tracker.py", line 46, in __init__
    self.perform_device_scan()
  File "/config/custom_components/zte/device_tracker.py", line 53, in perform_device_scan
    self.results = self.zte_client.get_connected_devices()
  File "/usr/local/lib/python3.7/site-packages/zte_client-1.0-py3.7.egg/zte_client/__init__.py", line 51, in get_connected_devices
    devices = self.__get_connected_devices("wlanDevice") + \
  File "/usr/local/lib/python3.7/site-packages/zte_client-1.0-py3.7.egg/zte_client/__init__.py", line 62, in __get_connected_devices
    instances = root.find('OBJ_ACCESSDEV_ID').findall('Instance')
AttributeError: 'NoneType' object has no attribute 'findall'

Is it possible that this error is a result that I'm using ZTE "user" and not "admin"?

Please let me know how to resolve this error.

vlasov01 commented 4 years ago

I was able to configure logger. I've added extra log entries too. Here is the log output:

2020-04-11 12:05:51,588 - ZTE Logger - DEBUG - got login token 68572752
2020-04-11 12:05:51,809 - ZTE Logger - DEBUG - got login cookie: [('SID', 'e79ba1df192ba93a40a2b1b520755756')]
2020-04-11 12:05:52,190 - ZTE Logger - DEBUG - Response <html>
<head><title>404 Not Found</title></head>
<body bgcolor="#FFFFFF" text="#000000" link="#2020ff" vlink="#4040cc">
<h2>404 Not Found</h2>
<span>The requested URL was not found on this server.</span>
<div style="display:none">
<ajax_response_xml_root>
<IF_ERRORSTR>SessionTimeout</IF_ERRORSTR>
<IF_ERRORPARAM>SUCC</IF_ERRORPARAM>
<IF_ERRORTYPE>SUCC</IF_ERRORTYPE>
</ajax_response_xml_root>
<span>Padding so that MSIE deigns to show this error instead of its own canned one.</span>
<span>Padding so that MSIE deigns to show this error instead of its own canned one.</span>
<span>Padding so that MSIE deigns to show this error instead of its own canned one.</span>
<span>Padding so that MSIE deigns to show this error instead of its own canned one.</span>
<span>Padding so that MSIE deigns to show this error instead of its own canned one.</span>
<span>Padding so that MSIE deigns to show this error instead of its own canned one.</span>
</div>
<hr />
</body>
</html>
2020-04-11 12:05:52,194 - ZTE Logger - DEBUG - devices not found <Element 'html' at 0x71eb2780>
2020-04-11 12:05:52,306 - ZTE Logger - DEBUG - Response <html>
<head><title>404 Not Found</title></head>
<body bgcolor="#FFFFFF" text="#000000" link="#2020ff" vlink="#4040cc">
<h2>404 Not Found</h2>
<span>The requested URL was not found on this server.</span>
<div style="display:none">
<ajax_response_xml_root>
<IF_ERRORSTR>SessionTimeout</IF_ERRORSTR>
<IF_ERRORPARAM>SUCC</IF_ERRORPARAM>
<IF_ERRORTYPE>SUCC</IF_ERRORTYPE>
</ajax_response_xml_root>
<span>Padding so that MSIE deigns to show this error instead of its own canned one.</span>
<span>Padding so that MSIE deigns to show this error instead of its own canned one.</span>
<span>Padding so that MSIE deigns to show this error instead of its own canned one.</span>
<span>Padding so that MSIE deigns to show this error instead of its own canned one.</span>
<span>Padding so that MSIE deigns to show this error instead of its own canned one.</span>
<span>Padding so that MSIE deigns to show this error instead of its own canned one.</span>
</div>
<hr />
</body>
</html>
2020-04-11 12:05:52,313 - ZTE Logger - DEBUG - devices not found <Element 'html' at 0x71ec3660>

Probably there are some differences in firmware version of my ZTE H268A, so screen scrapping fails.

vlasov01 commented 4 years ago

I've forked the project to https://github.com/vlasov01/zte-zxhn-h268a-presence-detection/ and committed my changes there.

kankadev commented 2 years ago

Hi @vlasov01, did you fix the errors and is everything running fine now?

lucumon commented 2 years ago

Getting same issue... Any news?

kankadev commented 2 years ago

I'm interested in this, too. But found no solution with this module.

So, until this isn't working, I recommend to install the Home Assistant App on your phone and use geofence (zone) to detect presence.