Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NameError: name 'DeviceException' is not defined #4

Open
RavenKong opened this issue Nov 29, 2018 · 6 comments
Open

NameError: name 'DeviceException' is not defined #4

RavenKong opened this issue Nov 29, 2018 · 6 comments

Comments

@RavenKong
Copy link

I'm using hass.io version 0.82.1
My device model is Xiaomi water purifier 1A.
It seems the setup of the platform failed due to a "name error" which could possibly be caused by mismatching versions of the python dependencies.
Below is the error logs:

`018-11-25 00:18:42 ERROR (SyncWorker_7) [miio.protocol] unable to parse json '{"result":[net],"id":1}': Expecting value: line 1 column 12 (char 11)
2018-11-25 00:18:42 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform mi_water_purifier
Traceback (most recent call last):
File "/config/custom_components/sensor/mi_water_purifier.py", line 159, in parse_data
status = self._device.send('get_prop', [])
File "/usr/local/lib/python3.6/site-packages/miio/device.py", line 263, in send
self.__id = m.data.value["id"]
TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
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/sensor/mi_water_purifier.py", line 34, in setup_platform
waterPurifier = XiaomiWaterPurifier(device, name)
File "/config/custom_components/sensor/mi_water_purifier.py", line 116, in init
self.parse_data()
File "/config/custom_components/sensor/mi_water_purifier.py", line 177, in parse_data
except DeviceException:
NameError: name 'DeviceException' is not defined`

@RavenKong
Copy link
Author

Sorry to raise this issue with the duplicated title. The previous one does not provide logs.

@bluefoxlee
Copy link

Also wonder if components support 1A as well? If not, any possible to update it? Or if you need any data to support it.

Thank you.
BTW it has been work great with my gen 1. Thanks for the great work.

@ptlinzx
Copy link

ptlinzx commented Dec 3, 2018

1A error 1A

Sun Dec 02 2018 16:10:20 GMT+0800 (CST)

Error while setting up platform mi_water_purifier
Traceback (most recent call last):
File "/config/custom_components/sensor/mi_water_purifier.py", line 159, in parse_data
status = self._device.send('get_prop', [])
File "/usr/local/lib/python3.6/site-packages/miio/device.py", line 263, in send
self.__id = m.data.value["id"]
TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/src/app/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/sensor/mi_water_purifier.py", line 34, in setup_platform
waterPurifier = XiaomiWaterPurifier(device, name)
File "/config/custom_components/sensor/mi_water_purifier.py", line 116, in init
self.parse_data()
File "/config/custom_components/sensor/mi_water_purifier.py", line 177, in parse_data
except DeviceException:
NameError: name 'DeviceException' is not defined

Sun Dec 02 2018 16:10:20 GMT+0800 (CST)

unable to parse json '{"result":[net],"id":1}': Expecting value: line 1 column 12 (char 11)

@bit3725
Copy link
Owner

bit3725 commented Jan 24, 2019

@RavenKong @bluefoxlee @ptlinzx

name 'DeviceException' is not defined

This is a weird error message since I saw it sometimes when the component can't get data from device and try to raise an exception. I also confused why we saw this error message since DeviceException is already imported in code.

But I think the main problem of the logs you pasted is the miio library which this component uses to fetch data from xiaomi IOT devices can't get data from water purifier.
I guess there are two possible reasons:

  1. the water purifier isn't reachable at that time for some reasons(network or device can't respond command). I encountered it before and just restarted home assistant to let it reconnect water purifier. It means the code isn't stable enough to handle this exception. Hope someone can help since I'm not familiar python and home assistant also :(
  2. The 1A model doesn't support the command I used for gen 1. As I know there are only three filters in 1A model, the command for getting data and the data format should be different from gen 1. Since I don't have 1A model, I can't test with miio command line tool to see which command and data format should be used for 1A. If someone can try with miio command line tool by himself and find correct command and data format, I can try to add code to support 1A model.

@bit3725
Copy link
Owner

bit3725 commented Jan 24, 2019

I just updated code and try to solve the weird issue that raised "name 'DeviceException' is not defined" when device isn't reachable.
If you are using 1A model, you should just see the error message raised from miio library.

@bluefoxlee
Copy link

bluefoxlee commented Jan 29, 2019

@bit3725 I will download the updated one and report here.

Update: Still got "TypeError: 'NoneType' object is not subscriptable."
Will check miio tool to see if I can get more info from there.
Still thanks,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants