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

AttributeError: 'AirDehumidifier' object has no attribute 'model' #1149

Closed
nielsfaber opened this issue Sep 28, 2021 · 2 comments
Closed

AttributeError: 'AirDehumidifier' object has no attribute 'model' #1149

nielsfaber opened this issue Sep 28, 2021 · 2 comments
Labels

Comments

@nielsfaber
Copy link

Describe the bug
Code error.

Related to PR #1146 and syssi/xiaomi_airpurifier#206.
I tried to apply your PR locally to fix the broken integration.

Line 184 refers to self.model, but I guess this should be self._model as defined in Device.py.
Additionally, since the model is considered optional, a fallback is needed (was in the constructor which is removed by your changes).

Could you please take a look at this before releasing your changes?

Console output

  File "/usr/local/lib/python3.9/site-packages/miio/airdehumidifier.py", line 184, in status,
AttributeError: 'AirDehumidifier' object has no attribute 'model',
    self.model, AVAILABLE_PROPERTIES[MODEL_DEHUMIDIFIER_V1],
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run,
    result = self.fn(*self.args, **self.kwargs),
  File "/config/custom_components/xiaomi_miio_airpurifier/climate.py", line 435, in async_update,
    state = await self.hass.async_add_executor_job(self._device.status),
    await task,
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 618, in async_device_update,
    await entity.async_device_update(warning=False),
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 431, in _async_add_entity,
Traceback (most recent call last):,
2021-09-28 19:47:36 ERROR (MainThread) [homeassistant.components.climate] xiaomi_miio_airpurifier: Error on device update!
@nielsfaber nielsfaber added the bug label Sep 28, 2021
@rytilahti
Copy link
Owner

Hi and thanks for testing! I'm not currently sure why that's happening considering that the model property is definitely defined in the parent class:

python-miio/miio/device.py

Lines 175 to 181 in ea67e3f

@property
def model(self) -> str:
"""Return device model."""
if self._model is not None:
return self._model
return self.info().model

The _model is an internal variable to allow model detection override, so the line in the file trying to access model is correct. Line 184 also does fallback (to use AVAILABLE_PROPERTIES[MODEL_DEHUMIDIFIER_V1]), but it's failing here due to that exception.

@nielsfaber
Copy link
Author

Thanks for your quick response!
pip show python-miio tells me 0.5.8 was installed locally.
The model property does not exist for this version in device.py.
I'm seeing now that I didn't make local changes of PR #1038 which are in the 'next' branch.

I guess my bug report is not really a bug, sorry for the confusion, this issue can be closed.
Hopefully your changes can be released soon and integrated into HA and the xiaomi_airpurifier integration, cause things are a bit broken now (as described in syssi/xiaomi_airpurifier#206).
In the meantime I managed to fix things on my setup, I will not update HA until things are settled.

Thanks for your work on this 👍

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

No branches or pull requests

2 participants