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

Xiaomi_miio: Error on device update (Vacuum) #43836

Closed
faaafo opened this issue Dec 1, 2020 · 26 comments
Closed

Xiaomi_miio: Error on device update (Vacuum) #43836

faaafo opened this issue Dec 1, 2020 · 26 comments

Comments

@faaafo
Copy link

faaafo commented Dec 1, 2020

The problem

I can’t tell since when I got this error. Updating the raspi host nor hassio(docker) didn’t help.

Environment

Supervisor > Homeassistant Core 0.113.2 
Docker Variant

Problem-relevant configuration.yaml

    vacuum:
      - platform: xiaomi_miio
        host: 192.168.178.21
        token: mytoken

Traceback/Error logs

    Traceback (most recent call last):
      File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 320, in _async_add_entity
        await entity.async_device_update(warning=False)
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 465, in async_device_update
        await self.hass.async_add_executor_job(
      File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
        result = self.fn(*self.args, **self.kwargs)
      File "/usr/src/homeassistant/homeassistant/components/xiaomi_miio/vacuum.py", line 481, in update
        self._timers = self._vacuum.timer()
      File "/usr/local/lib/python3.8/site-packages/miio/vacuum.py", line 377, in timer
        timezone = self.timezone()
      File "/usr/local/lib/python3.8/site-packages/miio/vacuum.py", line 552, in timezone
        res = self.send("get_timezone")[0]
    TypeError: 'int' object is not subscriptable

Additional information

Running mirobo on the raspi or docker instance works as well:

mirobo --ip 192.168.178.21 --token mytoken

State: Charging
Battery: 100 %
@probot-home-assistant
Copy link

Hey there @rytilahti, @syssi, @starkillerOG, mind taking a look at this issue as its been labeled with an integration (xiaomi_miio) you are listed as a codeowner for? Thanks!
(message by CodeOwnersMention)

@rytilahti
Copy link
Member

Could you please try mirobo -d timezone? Here's what it's returning to me:

DEBUG:miio.miioprotocol:192.168.xx:54321 >>: {'id': 281, 'method': 'get_timezone', 'params': []}
DEBUG:miio.miioprotocol:192.168.xx:54321 (ts: 1970-01-01 20:32:17, id: 281) << {'result': ['Europe/Berlin'], 'id': 281}

@faaafo
Copy link
Author

faaafo commented Dec 2, 2020

root@raspberrypi:~# docker exec -it homeassistant bash

bash-5.0# mirobo --ip 192.168.178.21 --token mytoken -d timezone

INFO:miio.vacuum_cli:Debug mode active
DEBUG:miio.vacuum_cli:Read stored sequence ids: {'seq': 23, 'manual_seq': 0}
DEBUG:miio.vacuum_cli:Connecting to 192.168.178.21 with token mytoken
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
DEBUG:miio.miioprotocol:Got a response: Container: 
    data = Container: 
        data = b'' (total 0)
        value = b'' (total 0)
        offset1 = 32
        offset2 = 32
        length = 0
    header = Container: 
        data = b'!1\x00 \x00\x00\x00\x00\x03L\x83x\x00\x00\xa7\xd5' (total 16)
        value = Container: 
            length = 32
            unknown = 0
            device_id = b'\x03L\x83x' (total 4)
            ts = 1970-01-01 11:56:05
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' (total 16)
DEBUG:miio.miioprotocol:Discovered 034c8378 with ts: 1970-01-01 11:56:05, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.miioprotocol:192.168.178.21:54321 >>: {'id': 24, 'method': 'get_timezone', 'params': []}
DEBUG:miio.miioprotocol:192.168.178.21:54321 (ts: 1970-01-01 11:56:06, id: 24) << {'result': 0, 'id': 24}
Traceback (most recent call last):
  File "/usr/local/bin/mirobo", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.8/site-packages/miio/click_common.py", line 59, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/click/decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/miio/vacuum_cli.py", line 537, in timezone
    click.echo("Timezone: %s" % vac.timezone())
  File "/usr/local/lib/python3.8/site-packages/miio/vacuum.py", line 552, in timezone
    res = self.send("get_timezone")[0]
TypeError: 'int' object is not subscriptable
bash-5.0# 

@ldobransky
Copy link

same issue on my side

@XRedShark
Copy link

My Xiaomi Vacuum Mop v2 is "unavailable"

@ShifuEst
Copy link

I have same problem.
My Xiaomi Vacuum Mop v2 is "unavailable"
https://imgur.com/EvKVkJB

@gerben-van-eck
Copy link

Same issue.

On first attempt, I got
Error: Unable to discover the device 192.168.178.235

After that, I pinged that IP, it only responded after a few seconds.

On my second attempt, I got the same log as faaafo.

@rytilahti
Copy link
Member

@faaafo for the timezone problem, please create an upstream issue at https://github.com/rytilahti/python-miio/ . For some reason the device is not reporting the timezone information correctly, which is required for the timer functionality.

However, the missing timer information should not cause a verbose exception since #41330 (merged already in October) so you should simply try to update to a newer homeassistant version to see if it fixes it, with the caveat of not having timer information available for homeassistant.

@ShifuEst
Copy link

ShifuEst commented Jan 3, 2021

I Have :)

Version 2021.1.0b1
Installation Type Home Assistant OS
Development false
Supervisor true
Docker true
Virtual Environment false
Python Version 3.8.6
Operating System Family Linux
Operating System Version 5.4.79-v7l
CPU Architecture armv7l
Timezone Europe/Tallinn
Host Operating System Home Assistant OS 5.10
Update Channel beta
Supervisor Version 2020.12.7
Docker Version 19.03.13
Disk Total 13.9 GB
Disk Used 4.8 GB
Healthy true
Supported true
Board rpi4
Supervisor API ok
Version API ok
Installed Add-ons Samba share (9.3.0), OpenZWave (0.7.1), Mosquitto broker (5.1), File editor (5.2.0), Terminal & SSH (8.10.0), Traccar (0.9.2), MariaDB (2.2.1)

@faaafo
Copy link
Author

faaafo commented Jan 3, 2021

@rytilahti Thank you for chiming in.

Updated the underlying host and homeassistant (2020.12.1) as well. Alas to no avail.

Will gladly follow your suggestion, open an issue on python-miio and keep you/this issue posted

@rytilahti
Copy link
Member

rytilahti commented Jan 3, 2021

@faaafo thanks for chiming in back, too! Okay, that's a bit odd. Does the stacktrace in the logs still look similar, i.e., crashing inside timezone request handling?

@ShifuEst
Copy link

ShifuEst commented Jan 3, 2021

i use - platform: miio2 and it's work but / - platform: xiaomi_miio it's not work.

error miio2 but it's work

Got exception while fetching the state: Unable to discover the device 192.168.2.129
12:18:01 AM – miio2 (WARNING) - message first occurred at January 3, 2021, 10:04:28 PM and shows up 56 times
Update of vacuum.robottolmuimeja is taking over 10 seconds
12:18:01 AM – helpers/entity.py (WARNING) - message first occurred at January 3, 2021, 10:05:39 PM and shows up 29 times
Choked at offset 12 while unpacking b"@.UO\x0f\x18\x19+\x11X(?\x0fF\x16\x0b#hV#\x1a[0\x19\x00\x13\x0fV%hNe!$40<N[M&\x03\r6I#Am\x0c\x17\x10&rA?rTNHy6\x17^W;\x13\x07wabD\x07fQ=/u~\x1c\x01\x15-'\x08nfzB4C<jZ\x1aA\x15-r\xad"
January 3, 2021, 11:31:45 PM – /usr/local/lib/python3.8/site-packages/zeroconf/init.py (WARNING)
DeviceException during setup of xiaomi gateway with host 192.168.2.129
January 3, 2021, 10:05:28 PM – Xiaomi Miio (ERROR)
Waiting on integrations to complete setup: upnp, xiaomi_miio
January 3, 2021, 10:05:05 PM – bootstrap.py (WARNING)
Error while setting up samsungtv platform for media_player
January 3, 2021, 10:05:02 PM – Media player (ERROR)
You are using a custom integration for miio2 which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant.
January 3, 2021, 10:04:58 PM – loader.py (WARNING) - message first occurred at January 3, 2021, 10:03:10 PM and shows up 2 times

@ShifuEst
Copy link

ShifuEst commented Jan 3, 2021

miio2 it work pic

https://ibb.co/Gx6vRNL

@faaafo
Copy link
Author

faaafo commented Jan 3, 2021

Current log

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 359, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 466, in async_device_update
    await task
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/xiaomi_miio/vacuum.py", line 495, in update
    self._timers = self._vacuum.timer()
  File "/usr/local/lib/python3.8/site-packages/miio/vacuum.py", line 398, in timer
    timezone = pytz.timezone(self.timezone())
  File "/usr/local/lib/python3.8/site-packages/miio/vacuum.py", line 576, in timezone
    res = self.send("get_timezone")[0]
TypeError: 'int' object is not subscriptable

@faaafo
Copy link
Author

faaafo commented Jan 3, 2021

@ShifuEst What is miio2?

@rytilahti
Copy link
Member

@faaafo ah, indeed, the PR I linked fixes only the cases where a DeviceException is raised (so this typeerror won't be caught).

miio2 is a custom fork of the integration for some non-rockrobo (viomi) devices. Issues with that should be reported to its developer and not in this repository.

@ShifuEst
Copy link

ShifuEst commented Jan 3, 2021

https://github.com/nqkdev/home-assistant-vacuum-styj02ym

this is miio2 and it's work

@ShifuEst
Copy link

ShifuEst commented Jan 3, 2021

if I use vacuum:

@ShifuEst
Copy link

ShifuEst commented Jan 3, 2021

Update of vacuum.robottolmuimeja is taking over 10 seconds
1:25:57 AM – helpers/entity.py (WARNING) - message first occurred at 1:23:57 AM and shows up 3 times
Got error when receiving: timed out
1:25:27 AM – /usr/local/lib/python3.8/site-packages/miio/miioprotocol.py (ERROR) - message first occurred at 1:22:46 AM and shows up 7 times
Updating xiaomi_miio vacuum took longer than the scheduled update interval 0:00:20
1:25:27 AM – Vacuum (WARNING) - message first occurred at 1:24:07 AM and shows up 4 times
Setup of vacuum platform xiaomi_miio is taking over 10 seconds.
1:22:56 AM – Vacuum (WARNING)
DeviceException during setup of xiaomi gateway with host 192.168.2.129
1:22:46 AM – Xiaomi Miio (ERROR)

@ShifuEst
Copy link

ShifuEst commented Jan 3, 2021

if I use miio2 then is ok :)

@ShifuEst
Copy link

ShifuEst commented Jan 3, 2021

#                                                  #
####################################################  

vacuum:

  • platform: miio2
    host: 192.168.2.129
    token: is same
    name: Robottolmuimeja

@ShifuEst
Copy link

ShifuEst commented Jan 3, 2021

look miio2 platform work. :)

https://ibb.co/DMHDNZH

@ShifuEst
Copy link

ShifuEst commented Jan 3, 2021

Moi.
Puhun myös vähän suomea :)

@vukisz
Copy link

vukisz commented Mar 25, 2021

Same error for the no roborock S7:

Logger: homeassistant.components.vacuum
Source: components/xiaomi_miio/vacuum.py:499
Integration: Vacuum (documentation, issues)
First occurred: 11:54:56 AM (1 occurrences)
Last logged: 11:54:56 AM

xiaomi_miio: Error on device update!
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 360, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 465, in async_device_update
    await task
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/xiaomi_miio/vacuum.py", line 499, in update
    self.last_clean = self._device.last_clean_details()
  File "/usr/local/lib/python3.8/site-packages/miio/vacuum.py", line 352, in last_clean_details
    if not history.ids:
  File "/usr/local/lib/python3.8/site-packages/miio/vacuumcontainers.py", line 219, in ids
    return list(self.data[3])
KeyError: 3

@rytilahti
Copy link
Member

@vukisz that looks like a completely different problem (protocol incompatibility) than the ones mentioned earlier.

Could you please activate debug logger for miio and observe the responses from the device (get_clean_summary and get_clean_record are relevant method calls), and create a new issue at https://github.com/rytilahti/python-miio/ ?

@ShifuEst moi moi :-)

@rytilahti
Copy link
Member

The timezone issue should have been fixed for a long time ago already (0.5.5, rytilahti/python-miio#949), and a fix to the s7 issue got fixed in 0.5.6 which is used by 2021.5.1, so I'm closing this now.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants