LINT fixes
This commit is contained in:
parent
1bb22d818a
commit
43ef4bccdf
1 changed files with 11 additions and 4 deletions
|
@ -42,6 +42,7 @@ class AdafruitIoBackend(Backend):
|
||||||
if not plugin:
|
if not plugin:
|
||||||
raise RuntimeError('Adafruit IO plugin not configured')
|
raise RuntimeError('Adafruit IO plugin not configured')
|
||||||
|
|
||||||
|
# noinspection PyProtectedMember
|
||||||
self._client = MQTTClient(plugin._username, plugin._key)
|
self._client = MQTTClient(plugin._username, plugin._key)
|
||||||
self._client.on_connect = self.on_connect()
|
self._client.on_connect = self.on_connect()
|
||||||
self._client.on_disconnect = self.on_disconnect()
|
self._client.on_disconnect = self.on_disconnect()
|
||||||
|
@ -52,18 +53,25 @@ class AdafruitIoBackend(Backend):
|
||||||
for feed in self.feeds:
|
for feed in self.feeds:
|
||||||
client.subscribe(feed)
|
client.subscribe(feed)
|
||||||
self.bus.post(ConnectedEvent())
|
self.bus.post(ConnectedEvent())
|
||||||
|
|
||||||
return _handler
|
return _handler
|
||||||
|
|
||||||
def on_disconnect(self):
|
def on_disconnect(self):
|
||||||
def _handler(client):
|
def _handler(client):
|
||||||
self.bus.post(DisconnectedEvent())
|
self.bus.post(DisconnectedEvent())
|
||||||
|
|
||||||
return _handler
|
return _handler
|
||||||
|
|
||||||
def on_message(self):
|
def on_message(self, msg):
|
||||||
|
# noinspection PyUnusedLocal
|
||||||
def _handler(client, feed, data):
|
def _handler(client, feed, data):
|
||||||
try: data = float(data)
|
# noinspection PyBroadException
|
||||||
except: pass
|
try:
|
||||||
|
data = float(data)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
self.bus.post(FeedUpdateEvent(feed=feed, data=data))
|
self.bus.post(FeedUpdateEvent(feed=feed, data=data))
|
||||||
|
|
||||||
return _handler
|
return _handler
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
@ -81,5 +89,4 @@ class AdafruitIoBackend(Backend):
|
||||||
self.logger.exception(e)
|
self.logger.exception(e)
|
||||||
self._client = None
|
self._client = None
|
||||||
|
|
||||||
|
|
||||||
# vim:sw=4:ts=4:et:
|
# vim:sw=4:ts=4:et:
|
||||||
|
|
Loading…
Reference in a new issue