Skip to content

Commit

Permalink
Merge pull request #84 from adafruit/fix_isconnected
Browse files Browse the repository at this point in the history
the property did not work before. now it does what you expect - return true or false
  • Loading branch information
brentru committed Mar 23, 2022
2 parents 41c8ec5 + 2cee8b9 commit d1280ff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion adafruit_io/adafruit_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import json
import re

from adafruit_minimqtt.adafruit_minimqtt import MMQTTException
from adafruit_io.adafruit_io_errors import (
AdafruitIO_RequestError,
AdafruitIO_ThrottleError,
Expand Down Expand Up @@ -117,7 +118,10 @@ def disconnect(self):
@property
def is_connected(self):
"""Returns if connected to Adafruit IO MQTT Broker."""
return self._client.is_connected
try:
return self._client.is_connected()
except MMQTTException:
return False

# pylint: disable=not-callable, unused-argument
def _on_connect_mqtt(self, client, userdata, flags, return_code):
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@

Adafruit-Blinka
Adafruit_CircuitPython_ESP32SPI
Adafruit_CircuitPython_MiniMQTT

0 comments on commit d1280ff

Please sign in to comment.