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.14k stars 121 forks source link

Country should be a required field #380

Closed ymatsiuk closed 1 year ago

ymatsiuk commented 1 year ago

Checklist

The problem

Using recommended configuration doesn't work anymore:

dec 22 18:20:58 nixpi4 hass[48556]: 2022-12-22 18:20:58.965 DEBUG (SyncWorker_3) [custom_components.xiaomi_cloud_map_extractor.camera] Retrieving map name from device
dec 22 18:21:02 nixpi4 hass[48556]: 2022-12-22 18:21:02.964 ERROR (SyncWorker_3) [custom_components.xiaomi_cloud_map_extractor.camera] Got OSError while fetching the state: [Errno -2] Name or service not known

Digging deeper I suspect this is the root cause since the country is missing from either "Basic" or "Recommended" examples. Documentation states country is optional field, that apparently defaults to None here. That leads to API URL rendered to something like https://.api.io.mi.com/app

What version of an integration has described problem?

master (b4ae1d4bdd8268087cd269c7aeb2207a6dbefb2e)

What was the last working version of an integration?

No response

What vacuum model do you have problems with?

roborock.vacuum.s5e

What version of Home Assistant do you use?

core-2022.12.6

What type of installation are you running?

Home Assistant Core

Camera's configuration

Basic

camera:
  - platform: xiaomi_cloud_map_extractor
    host: !secret xiaomi_vacuum_host
    token: !secret xiaomi_vacuum_token
    username: !secret xiaomi_cloud_username
    password: !secret xiaomi_cloud_password

Recommended

camera:
  - platform: xiaomi_cloud_map_extractor
    host: !secret xiaomi_vacuum_host
    token: !secret xiaomi_vacuum_token
    username: !secret xiaomi_cloud_username
    password: !secret xiaomi_cloud_password
    draw: ['all']
    attributes:
      - calibration_points

Errors shown in the HA logs (if applicable)

dec 22 18:20:49 nixpi4 hass[48556]: 2022-12-22 18:20:49.131 DEBUG (SyncWorker_3) [custom_components.xiaomi_cloud_map_extractor.camera] Logged in
dec 22 18:20:49 nixpi4 hass[48556]: 2022-12-22 18:20:49.132 DEBUG (SyncWorker_3) [custom_components.xiaomi_cloud_map_extractor.camera] Retrieving device info, country: None
dec 22 18:20:50 nixpi4 hass[48556]: 2022-12-22 18:20:50.970 DEBUG (SyncWorker_3) [custom_components.xiaomi_cloud_map_extractor.camera] Retrieved device model: roborock.vacuum.s5e
dec 22 18:20:50 nixpi4 hass[48556]: 2022-12-22 18:20:50.971 DEBUG (SyncWorker_3) [custom_components.xiaomi_cloud_map_extractor.camera] Created device, used api: xiaomi
dec 22 18:20:50 nixpi4 hass[48556]: 2022-12-22 18:20:50.971 DEBUG (SyncWorker_3) [custom_components.xiaomi_cloud_map_extractor.camera] Retrieving map name from device
dec 22 18:20:54 nixpi4 hass[48556]: 2022-12-22 18:20:54.964 ERROR (SyncWorker_3) [custom_components.xiaomi_cloud_map_extractor.camera] Got OSError while fetching the state: [Errno -2] Name or service not known

Additional information

No response

PiotrMachowski commented 1 year ago

Actually not providing the country in config doesn't result in country being None. It is automatically discovered here.

Is there anything more in your logs?

ymatsiuk commented 1 year ago

Actually not providing the country in config doesn't result in country being None. It is automatically discovered here.

Could you point me out to exact place in the function you refer to where it sets the country? As per my understanding if we pass country as None to this function it returns None. I might be wrong though, since I'm not familiar with the code and spent like 5min to read it through (just quickly searched for country in the code πŸ™‚)

Is there anything more in your logs?

What do you mean? Could you be more specific about your expectations? πŸ™‚ Some context: I noticed the error in the custom component and set logging to DEBUG for only one component, so now instead of just one error line I see 5 additional DEBUG statements and ERROR in the end. If you wanted to suggest exact logging settings, I could set those up if that helps you understand the nature of the issue.

PiotrMachowski commented 1 year ago

Could you point me out to exact place in the function you refer to where it sets the country?

It is retrieved here, if it is None error is returned here (it's not possible for model to be not None and country to be None).

What do you mean? Could you be more specific about your expectations? πŸ™‚

Well, you haven't specified any specific problem. Is map still available? Or is it available only when you provide country? Or have it stopped working at all?

ymatsiuk commented 1 year ago

Well, you haven't specified any specific problem. Is map still available? Or is it available only when you provide country? Or have it stopped working at all?

Apologies for not making it clear. I've just recently discovered this customization. The map was not working until I added country into the config. I'm trying to reproduce the issue again with some additional debug. Will keep you posted.

ymatsiuk commented 1 year ago

It works now πŸ€” I'll do a clean install to understand what actually happened and why I can't re-produce it now. Meanwhile I'm closing this. Apologies for the inconvenience and thanks for the help! Have a great day!