r-renato / hass-xiaomi-mi-flora-and-flower-care

The Home Assistant custom component uses Flower Care™ Smart Monitor to retrieve flower information (http://www.huahuacaocao.com/product).
MIT License
33 stars 14 forks source link

KeyError: 'basic' when seting up huahuacaocao component #8

Closed elaiel closed 4 years ago

elaiel commented 4 years ago

When trying to setup the componenten, it seems not possible to connect. When the component is initiated I recive a KeyError: 'basic' Any ideas?

Logger: homeassistant.core Source: custom_components/huahuacaocao/sensor.py:419 First occurred: 6:35:47 (1 occurrences) Last logged: 6:35:47

Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 434, in _async_add_entity await entity.async_update_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 284, in async_update_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 327, in _async_write_ha_state attr.update(self.state_attributes or {}) File "/config/custom_components/huahuacaocao/sensor.py", line 419, in state_attributes ATTR_INFO: self._config[ATTR_BASIC], KeyError: 'basic'

r-renato commented 4 years ago

Hi, do you can put the component in debug mode and share the component log here? You have to collect the only rows that contain [custom_components.huahuacaocao].

To put the component in debug mode you must add the following and restart HA: custom_components.huahuacaocao: debug

Example:

# Logging
logger:
  logs:
    custom_components.huahuacaocao: debug

Thank you, Renato

elaiel commented 4 years ago

Hi Renato Here you go (Looks like a login error (?) I used my email to log in, as I do within the app. ):

2020-03-27 12:48:02 INFO (MainThread) [custom_components.huahuacaocao] init async_setup start for domain huahuacaocao. 2020-03-27 12:48:02 INFO (MainThread) [custom_components.huahuacaocao] init async_setup load_platform for component: 'huahuacaocao' in domain 'sensor'. 2020-03-27 12:48:02 INFO (MainThread) [custom_components.huahuacaocao] init async_setup done for domain huahuacaocao.

2020-03-27 12:48:09 INFO (SyncWorker_5) [custom_components.huahuacaocao.sensor] init setup_platform 'sensor' start for huahuacaocao with config OrderedDict([('platform', 'huahuacaocao'), ('plant_id', 'allium sativum'), ('name', 'Knoblauch'), ('sensors', OrderedDict([('moisture', 'sensor.allium_sativum_moisture'), ('battery', 'sensor.allium_sativum_battery'), ('temperature', 'sensor.allium_sativum_temperature'), ('conductivity', 'sensor.allium_sativum_conductivity'), ('brightness', 'sensor.allium_sativum_light_intensity')]))]).

2020-03-27 12:48:09 DEBUG (SyncWorker_5) [custom_components.huahuacaocao] ServiceAPI retrieve_authorization_token headers: {'Content-Type': 'application/json; charset=utf-8', 'X-Hhcc-Region': 'EU', 'X-Hhcc-Token': '', 'X-Real-Ip': '227.90.122.222'}

2020-03-27 12:48:09 DEBUG (SyncWorker_5) [custom_components.huahuacaocao] ServiceAPI retrieve_authorization_token payload: {'data': {'email': 'xxxxxxx.xxxxxxx@gmx.com', 'password': 'xxxxxx'}, 'extra': {'app_channel': 'google', 'country': 'IT', 'lang': 'it', 'model': '', 'phone': 'samsung_SM-G955F_26', 'position': [], 'version': 'AS_3044_5.4.6', 'zone': 1}, 'method': 'GET', 'path': '/token/email', 'service': 'auth'}

2020-03-27 12:48:11 DEBUG (SyncWorker_5) [custom_components.huahuacaocao] ServiceAPI retrieve_authorization_token response data: {"status":301,"description":"login error","data":null} 2020-03-27 12:48:11 DEBUG (SyncWorker_5) [custom_components.huahuacaocao.sensor] init setup_platform 'sensor' start for huahuacaocao. Retrieved Flower: None

2020-03-27 12:48:13 DEBUG (SyncWorker_5) [custom_components.huahuacaocao.sensor] init setup_platform 'sensor' Knoblauch in platform huahuacaocao. Component added with {'sensors': OrderedDict([('moisture', 'sensor.allium_sativum_moisture'), ('battery', 'sensor.allium_sativum_battery'), ('temperature', 'sensor.allium_sativum_temperature'), ('conductivity', 'sensor.allium_sativum_conductivity'), ('brightness', 'sensor.allium_sativum_light_intensity')])}.

2020-03-27 12:48:13 INFO (SyncWorker_5) [custom_components.huahuacaocao.sensor] init setup_platform 'sensor' done for huahuacaocao.

2020-03-27 12:48:17 INFO (SyncWorker_12) [custom_components.huahuacaocao.sensor] init setup_platform 'sensor' start for huahuacaocao with config {}.

Best regards Michael

r-renato commented 4 years ago

Hi, Michael, the provided credentials are probably wrong. See the following error: 2020-03-27 12:48:11 DEBUG (SyncWorker_5) [custom_components.huahuacaocao] ServiceAPI retrieve_authorization_token response data: {"status":301,"description":"login error","data":null}

For this reason the component is not able to retrieve the plant information. See the following log row: 2020-03-27 12:48:11 DEBUG (SyncWorker_5) [custom_components.huahuacaocao.sensor] init setup_platform 'sensor' start for huahuacaocao. Retrieved Flower: None

I suggest to you to try to check the credentials provided. Thanks, bye. Renato

elaiel commented 4 years ago

Hi Renato I had a line commented out between the login data and the region, when I deleted that, it worked :-). Thanks

r-renato commented 4 years ago

Nada, enjoy. :)