Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data reading float conversion exception #15

Closed
lucagiove opened this issue Jan 6, 2020 · 3 comments · Fixed by #16
Closed

Data reading float conversion exception #15

lucagiove opened this issue Jan 6, 2020 · 3 comments · Fixed by #16

Comments

@lucagiove
Copy link
Contributor

Sensor data collection stops after the following traceback.
Probably there is another bug that prevents data to be collected after an exception not sure if in this repository or in the component code, for sure there are many people affected by this problem:
home-assistant/core#24313

I'll try to work on a PR at least for the parsing exception.

Update for sensor.salotto_temperature fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 281, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 461, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/mitemp_bt/sensor.py", line 156, in update
    data = self.poller.parameter_value(self.parameter)
  File "/usr/local/lib/python3.7/site-packages/mitemp_bt/mitemp_bt_poller.py", line 126, in parameter_value
    self.fill_cache()
  File "/usr/local/lib/python3.7/site-packages/mitemp_bt/mitemp_bt_poller.py", line 69, in fill_cache
    self.ble_timeout)  # pylint: disable=no-member
  File "/usr/local/lib/python3.7/site-packages/btlewrap/bluepy.py", line 27, in _func_wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/btlewrap/bluepy.py", line 93, in wait_for_notification
    return self._peripheral.waitForNotifications(notification_timeout)
  File "/usr/local/lib/python3.7/site-packages/bluepy/btle.py", line 560, in waitForNotifications
    resp = self._getResp(['ntfy','ind'], timeout)
  File "/usr/local/lib/python3.7/site-packages/bluepy/btle.py", line 416, in _getResp
    self.delegate.handleNotification(hnd, data)
  File "/usr/local/lib/python3.7/site-packages/mitemp_bt/mitemp_bt_poller.py", line 198, in handleNotification
    self._check_data()
  File "/usr/local/lib/python3.7/site-packages/mitemp_bt/mitemp_bt_poller.py", line 145, in _check_data
    parsed = self._parse_data()
  File "/usr/local/lib/python3.7/site-packages/mitemp_bt/mitemp_bt_poller.py", line 181, in _parse_data
    res[MI_HUMIDITY] = float(dataparts[1])
ValueError: could not convert string to float: '53.0\x02'
lucagiove added a commit to lucagiove/mitemp that referenced this issue Jan 6, 2020
Sometimes data has spurious binary data non properly decoded from utf-8
Example:
ValueError: could not convert string to float: '53.0\x02'

This fix removes not printable characters to reduce the chances of exceptions.
@lucagiove
Copy link
Contributor Author

The fix works for the exception, I don't have the float error anymore but the polling crashed anyway with this error:
Polling error [Errno 32] Broken pipe

@lucagiove lucagiove changed the title Data reading crash after float conversion exception Data reading float conversion exception Jan 6, 2020
ratcashdev added a commit that referenced this issue Mar 31, 2020
Fix Issue #15 float conversion exception
@ratcashdev
Copy link
Owner

Closing, since #16 is merged. Feel free to file a new issue/pr if you discover the reason behind the Broken Pipe message.

@ratcashdev
Copy link
Owner

Edit: Crash already reported in #14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants