PiotrMachowski / Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor

This custom integration provides a way to present a live view of a map for Xiaomi (Roborock/Viomi/Roidmi/Dreame) vacuums without a need for rooting.
MIT License
1.13k stars 122 forks source link

Error setting up integration with 1 gen Xiaomi vacuum #434

Closed cioppz closed 1 year ago

cioppz commented 1 year ago

Checklist

The problem

Due to other compatibilities, I’m stuck on this version of home assistant, so I’d like to find if that’s the problem. The entity isn’t even created after this error. First time trying this integration, so I can’t describe a previous situation in which it worked.

What version of an integration has described problem?

V2.2.0

What was the last working version of an integration?

No response

What vacuum model do you have problems with?

Rockrobo.vacuum.v1

What version of Home Assistant do you use?

Core-2022.12.8

What type of installation are you running?

Home Assistant OS

Camera's configuration

camera:
  - platform: xiaomi_cloud_map_extractor
    host: 192.168.1.***
    token: 44476с73764е3****************
    username: ****60@me.com
    password: *********   
    draw: ['all']
    attributes:
      - calibration_points

Errors shown in the HA logs (if applicable)

Logger: homeassistant.components.camera
Source: custom_components/xiaomi_cloud_map_extractor/camera.py:162 
Integration: Telecamera (documentation, issues) 
First occurred: 10:01:49 (1 occurrences) 
Last logged: 10:01:49

Error while setting up xiaomi_cloud_map_extractor platform for camera
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 281, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/xiaomi_cloud_map_extractor/camera.py", line 149, in async_setup_platform
    async_add_entities([VacuumCamera(entity_id, host, token, username, password, country, name, should_poll,
  File "/config/custom_components/xiaomi_cloud_map_extractor/camera.py", line 162, in __init__
    self._vacuum = RoborockVacuum(host, token)
  File "/usr/local/lib/python3.10/site-packages/miio/integrations/vacuum/roborock/vacuum.py", line 215, in __init__
    super().__init__(ip, token, start_id, debug, model=model)
  File "/usr/local/lib/python3.10/site-packages/miio/device.py", line 79, in __init__
    self._protocol = MiIOProtocol(
  File "/usr/local/lib/python3.10/site-packages/miio/miioprotocol.py", line 42, in __init__
    self.token = bytes.fromhex(token)
ValueError: non-hexadecimal number found in fromhex() arg at position 5

Additional information

No response

PiotrMachowski commented 1 year ago

Are you sure that your token is correct?

cioppz commented 1 year ago

Got it from the extractor for windows

cioppz commented 1 year ago

@PiotrMachowski also the error comes from miioprotocol.py, so i thought the problem wasn’t coming from your integration, instead from the Xiaomi one

PiotrMachowski commented 1 year ago

Yes, it complains about token

cioppz commented 1 year ago

Do u have any idea on how to try and fix it?

PiotrMachowski commented 1 year ago

You can try to reset your vacuum and extract a new token.

Related issue in python miio

cioppz commented 1 year ago

I reset the vacuum, got another token, but i’m getting the same error with a different “position” at the last Line (now i get position 13 instead of 5). I also did some test: Setting up the vacuum automatically with Miio integration works just fine. Doing it manually entering ip and token gives me the same error as trying to use the map extractor. That’s with the new token obv.

PiotrMachowski commented 1 year ago

Ok, another idea:

You can try to configure the vacuum using Miio integration and check the token in /config/.storage/core.config_entries file

cioppz commented 1 year ago

It’s the same. So let me clear out the situation after the rest: I got the new token, which is the same i can see in /config/.storage/core.config_entries. Using this token in manual config gives me the same error as your addon. Automatic setup, the integration appears in the device section, but now i’m getting ‘entity not ready yet’ or time out errors for the vacuum. In another attempt yesterday i got those errors after the reset, but they fixed by themselves during the night.

cioppz commented 1 year ago

Quick update, just trying few resets got it working.

PiotrMachowski commented 1 year ago

I was about to suggest to try resetting until it works. 👍 I'm glad you got it working. Xiaomi Miio integration should work now as well, right?