I downloaded 6 days ago and component says 9days ago, is there a newer version then this one 9 days ago?
pygatt version 403 was installed in deps/lib/python3.7/site-packages/pygatt.
I changed this to:
Code
def run(self):
"""Thread that keeps connection alive."""
# pylint: disable=import-error
import pygatt
from pygatt.exceptions import (
BLEError, NotConnectedError, NotificationTimeout)
adapter = pygatt.backends.GATTToolBackend()
while self.keep_going:
try:
_LOGGER.debug("Connecting to %s", self.name)
# We need concurrent connect, so lets not reset the device
adapter.start(reset_on_start=False)
device = adapter.connect(self.mac, CONNECT_TIMEOUT)
# Give the adaptor a breather
self.event.wait(1)
for s in sensors:
val = struct.unpack(
s.format_type,
device.char_read(
s.uuid, timeout=CONNECT_TIMEOUT))
_LOGGER.debug("Sensor %s: %s", s.name, val)
if s.name == 'date_time':
val = str(datetime(val[0], val[1], val[2], val[3],
val[4], val[5]).isoformat())
self.data[s.name] = val
elif s.name == 'illuminance_accelerometer':
self.data['illuminance'] = str(val[0] * s.scale)
self.data['accelerometer'] = str(val[1] * s.scale)
else:
self.data[s.name] = str(round(val[0] * s.scale, 1))
except (BLEError, NotConnectedError, NotificationTimeout) as ex:
_LOGGER.error("Exception: %s ", str(ex))
finally:
adapter.stop()
self.event.wait(self.scan_interval.total_seconds())
Now i get 1-2 connection timeouts/day in log so far. Now it don’t stop on error and just continues…