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

Error while setting up huahuacaocao platform #17

Open dnguyen800 opened 4 years ago

dnguyen800 commented 4 years ago

I'm running HA 0.114.4 as a Docker container.

I created an account with the Flower Care app and was successfully able to connect to a MI Flora sensor and read data from it in the app. I also have the Miflora sensor connected to Home Assistant but the data reading is 'unavailable', though it has read data from it in the past. This is what my configuration.yaml and sensors.yaml file looks like:

## from my sensors.yaml file
- platform: miflora
  mac: 'xxxx'
  name: 'Mi Flora 01'
  force_update: true
  median: 3
  monitored_conditions:
    - moisture
    - light
    - temperature
    - conductivity
    - battery

- platform: huahuacaocao
  plant_id: "calathea makoyana"
  name: "Calathea Makoyana"
  sensors:
    moisture: sensor.mi_flora_01_moisture
    battery: sensor.mi_flora_01_battery
    temperature: sensor.mi_flora_01_temperature
    conductivity: sensor.mi_flora_01_conductivity
    brightness: sensor.mi_flora_01_light_intensity

# from my configuration.yaml file
huahuacaocao:
  username: !secret huahuacaocao_user
  password: !secret huahuacaocao_pw
  region: US

I get the following error message in the HA logs. I'm not sure why it is having issues setting the ATTR_INFO attribute.

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 184, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/huahuacaocao/sensor.py", line 188, in setup_platform
    component.add_entities(entities)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 267, in add_entities
    asyncio.run_coroutine_threadsafe(
  File "/usr/local/lib/python3.8/concurrent/futures/_base.py", line 439, in result
    return self.__get_result()
  File "/usr/local/lib/python3.8/concurrent/futures/_base.py", line 388, in __get_result
    raise self._exception
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 301, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 472, in _async_add_entity
    await entity.async_added_to_hass()
  File "/config/custom_components/huahuacaocao/sensor.py", line 351, in async_added_to_hass
    self.state_changed(entity_id, None, state)
  File "/config/custom_components/huahuacaocao/sensor.py", line 292, in state_changed
    self._update_state()
  File "/config/custom_components/huahuacaocao/sensor.py", line 323, in _update_state
    self.async_schedule_update_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 426, in async_schedule_update_ha_state
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 281, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 307, 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'

have you had this issue before?