basnijholt / miflora

☘️🌡🌼🥀🏡 Mi Flora Plant sensor Python package
MIT License
362 stars 99 forks source link

Exception in Home Assistant #79

Closed Redferne closed 6 years ago

Redferne commented 6 years ago

Hi,

Some of my MiFloras are slow to respond or out of range. Getting many of these in the log:

2018-01-18 22:39:24 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.stripe_conductivity fails
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 199, in async_update_ha_state
    yield from self.async_device_update()
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 306, in async_device_update
    yield from self.hass.async_add_job(self.update)
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 332, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup
    future.result()
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 245, in result
    raise self._exception
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/sensor/miflora.py", line 135, in update
    data = self.poller.parameter_value(self.parameter)
  File "/srv/homeassistant/lib/python3.6/site-packages/miflora/miflora_poller.py", line 128, in parameter_value
    self.fill_cache()
  File "/srv/homeassistant/lib/python3.6/site-packages/miflora/miflora_poller.py", line 60, in fill_cache
    firmware_version = self.firmware_version()
  File "/srv/homeassistant/lib/python3.6/site-packages/miflora/miflora_poller.py", line 102, in firmware_version
    _HANDLE_READ_VERSION_BATTERY, self._format_bytes(res))
  File "/srv/homeassistant/lib/python3.6/site-packages/miflora/miflora_poller.py", line 170, in _format_bytes
    return ' '.join([format(c, "02x") for c in raw_data]).upper()
TypeError: 'NoneType' object is not iterable

Are there some way of handling these?

ChristianKuehnel commented 6 years ago

Hi @Redferne,

thank you for the hint. I'm not checking for None as input data. This is fixed in https://github.com/open-homeautomation/miflora/pull/80