Aqara M2 hub connected via LAN cable
- door/window sensor
Created IFTTT applet so that when sensor is open/close it sends this to the appropriate AdafruitIO feed.
Have a MatrixPortal M4 and wrote CircuitPython code to subscribe to MQTT feed and get updates. Initially, all seems well. After executing the code, if I manually "open" the sensor, my AdafruitIO Feed receives "open" and my code registers this. Then if I manually "close" the sensor, again the AdafruitIO Feed receives "close" and my code also registers this. So far so good.
But after 2-5 minutes of run time, my M4 no longer seems to register any changes. The AdafruitIO Feed still updates appropriately based on the state of the sensor. The AdafruitIO Monitor page also shows the correct status of the sensor and lists "0 live errors"
REPL doesn't display any errors however, and my code still seems to be running. Here's a snippet of the code I wrote:
Code: Select all
from adafruit_matrixportal.matrixportal import MatrixPortal
from adafruit_matrixportal.network import Network
import adafruit_minimqtt.adafruit_minimqtt as MQTT
import adafruit_esp32spi.adafruit_esp32spi_socket as socket
while True:
try:
mqtt.is_connected()
mqtt.loop()
except (MQTT.MMQTTException, RuntimeError):
print("MQTT is disconnected ... re-connecting")
network.connect()
mqtt.reconnect()