dckiller51 / bodymiscale

Custom_components Body Metrics for Xiaomi Miscale 1 and 2 (esphome or BLE monitor for Homeassistant)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error reported when sensors not ready

borpin opened this issue · comments

It looks like the integration does not handle the situation where one sensor has updated and the other has not at startup.

It needs to wait until HA reports it has finished setting up.

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 273, in _async_state_change_dispatcher
    hass.async_run_hass_job(job, event)
  File "/usr/src/homeassistant/homeassistant/core.py", line 526, in async_run_hass_job
    cast(Callable[..., _R], hassjob.target)(*args)
  File "/config/custom_components/bodymiscale/__init__.py", line 170, in _state_changed_event
    self.state_changed(event.data.get("entity_id"), event.data.get("new_state"))
  File "/config/custom_components/bodymiscale/__init__.py", line 195, in state_changed
    self._update_state()
  File "/config/custom_components/bodymiscale/__init__.py", line 221, in _update_state
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 539, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 574, in _async_write_ha_state
    attr.update(self.state_attributes or {})
  File "/config/custom_components/bodymiscale/__init__.py", line 300, in state_attributes
    lib = body_metrics.bodyMetrics(weight, height, age, gender, 0)
  File "/config/custom_components/bodymiscale/body_metrics.py", line 17, in __init__
    raise Exception("Weight is either too low or too high (limits: <10kg and >200kg)")
Exception: Weight is either too low or too high (limits: <10kg and >200kg)
2022-03-04 11:20:50 ERROR (MainThread) [homeassistant.helpers.event] Error while processing state change for sensor.impedance_karen
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 273, in _async_state_change_dispatcher
    hass.async_run_hass_job(job, event)
  File "/usr/src/homeassistant/homeassistant/core.py", line 526, in async_run_hass_job
    cast(Callable[..., _R], hassjob.target)(*args)
  File "/config/custom_components/bodymiscale/__init__.py", line 170, in _state_changed_event
    self.state_changed(event.data.get("entity_id"), event.data.get("new_state"))
  File "/config/custom_components/bodymiscale/__init__.py", line 189, in state_changed
    value = int(float(value))
ValueError: could not convert string to float: ''

On startup, it needs to wait until it processes data and handle this smoothly.

Is this still happening with v2.1.1?
I can't reproduce it

Closing as author was not responding