Error when Impedance sensor has zero value
kaizersoje opened this issue · comments
kaizersoje commented
I have noticed at times the impedance sensor has a state of zero. When this happens, the integration fails to set up with the following error in the log. Also the sensors based on impedance, then get a state of unavailable
.
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 382, in async_setup
result = await component.async_setup_entry(hass, self)
File "/config/custom_components/bodymiscale/__init__.py", line 98, in async_setup_entry
handler = hass.data[DOMAIN][HANDLERS][entry.entry_id] = BodyScaleMetricsHandler(
File "/config/custom_components/bodymiscale/metrics/__init__.py", line 172, in __init__
self._state_changed(entity_id, state)
File "/config/custom_components/bodymiscale/metrics/__init__.py", line 223, in _state_changed
value = float(value)
ValueError: could not convert string to float: ''
Is there a way to check if the impedance sensor is zero and create the sensors only if the impedance has a state of non-zero?