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

Broken timezone call (dictionary instead of string) breaks HASS integration #759

Closed
lpfann opened this issue Jul 14, 2020 · 2 comments · Fixed by #760
Closed

Broken timezone call (dictionary instead of string) breaks HASS integration #759

lpfann opened this issue Jul 14, 2020 · 2 comments · Fixed by #760
Labels

Comments

@lpfann
Copy link

lpfann commented Jul 14, 2020

The changes in #712 apparently broke the vacuum integration in HomeAssistant for me and others.
home-assistant/core#37610

The changes were introduced in home-assistant/core#35417

Initialising the miio component used in HomeAssistant leads to the following error:


Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 186, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 292, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 451, in _async_add_entity
    entity.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 290, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 317, in _async_write_ha_state
    attr.update(self.device_state_attributes or {})
  File "/usr/src/homeassistant/homeassistant/components/xiaomi_miio/vacuum.py", line 333, in device_state_attributes
    if self.timers:
  File "/usr/src/homeassistant/homeassistant/components/xiaomi_miio/vacuum.py", line 284, in timers
    for timer in self._timers
  File "/usr/src/homeassistant/homeassistant/components/xiaomi_miio/vacuum.py", line 284, in <listcomp>
    for timer in self._timers
  File "/usr/local/lib/python3.7/site-packages/miio/vacuumcontainers.py", line 444, in next_schedule
    local_tz = timezone(self.timezone)
  File "/usr/local/lib/python3.7/site-packages/pytz/__init__.py", line 163, in timezone
    if zone.upper() == 'UTC':
AttributeError: 'dict' object has no attribute 'upper'

Apparently the call to pytz here

local_tz = timezone(self.timezone)

expects a String while it gets passed an dictionary.

When I run a timezone command on my Vacuum (Xiaowa E25) I get this dictionary but I am not sure if that is the identical call output used in the code.
{'olson': 'Europe/Berlin', 'posix': 'CET-1CEST,M3.5.0,M10.5.0/3'}
Because of that I am not sure if its a problem in python-miio or in the implementation in HASS.

@rytilahti
Copy link
Owner

Looks like that vacuum responds differently, here's what my gen1 returns:

>>: {'id': 254, 'method': 'get_timezone', 'params': []}
<< {'result': ['Europe/Berlin'], 'id': 254}

@rytilahti
Copy link
Owner

The linked PR should fix this, you could try the PR using mirobo timer or mirobo timezone.

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

Successfully merging a pull request may close this issue.

2 participants