Can't subscribe to MQTT topic
-
Can anyone demonstrate the example for subscribing to certain MQTT topic? All I'm getting is an error: "'NoneType' object has no attribute 'subscribe'". Meanwhile publishing to MQTT works as it should.
-
What hardware and software are you using as that’s a hardware base error
-
Hardware used is Atom S3, software - UiFlow2.
My UiFlow2 code:
Without "MQTT subscribe" block all else works.
Error when running on device:
Python code generated by UiFlow:
import os, sys, io
import M5
from M5 import *
from umqtt import *circle0 = None
mqtt_client = Nonedef mqtt_mqttDebugIncoming_event(data):
global circle0, mqtt_client
circle0.setColor(color=0x009900, fill_c=0x009900)def setup():
global circle0, mqtt_client
mqtt_client.subscribe('mqttDebugIncoming', mqtt_mqttDebugIncoming_event, qos=0)M5.begin()
circle0 = Widgets.Circle(62, 62, 50, 0xffffff, 0xffffff)mqtt_client = MQTTClient('mqttDebug', 'homeassistant.local', port=1883, user='mqttdebug', password='mqttdebug', keepalive=300)
mqtt_client.connect(clean_session=True)
mqtt_client.publish('mqttDebugOutgoing', 'This works, broker receives message!', qos=0)
circle0.setColor(color=0x3333ff, fill_c=0x3333ff)def loop():
global circle0, mqtt_client
M5.update()if name == 'main': # Forum message formatter messes this up
try:
setup()
while True:
loop()
except (Exception, KeyboardInterrupt) as e:
try:
from utility import print_error_msg
print_error_msg(e)
except ImportError:
print("please update to latest firmware")
-
Well that explains it. MQTT in UIFlow is a bit broken as UIFlow2 is for testing only
-
@ajb2k3In that case, is there an option to use UIFlow with S3 while UIFlow2 is "for testing only"? I did not see any warnings saying "things will not work" while buying it. Is there any timeframe when the already enabled functionality might work? I'm currently not asking about new features or support for more hardware, just for the things that already are available in UI.
-
Hello @Oskars
FWIW: global variable
mqtt_client
is used in setup to subscribe before it is initialized. Unfortunately in UIFlow2 the Python tab is non functional yet, so the sequence cannot be fixed on the fly.Thanks
Felix
-
@felmue Thank You, after I changed the code via Thonny and moved mqtt_client.subscribe after initialization the error disappeared. However the device still does not react to MQTT topics it has subscribed. So the bug is not only in UIFlow2 (incorrectly placed subscribe call) but also in MQTT library or firmware?
-
Any news here?
-
Hello guys
just tested again. MQTT subscribe is still broken for me in alpha 14. Please fix.
Thanks
Felix
-
@felmue Somewhat annoying that so much seems to be broken at the moment. We have no buttons and I cannot work out how to do anything with the microsd card. Would like to play a wav alarm file when specific MQTT message is received. Neither seems possible yet.
-
Its is still alpha so not the finale item and ma have code changed.
-
@ajb2k3 It would be good if M5stack had some sort of chart or spreadsheet that stated what currently worked and what didn't. Also an eta for things coming etc. Compared with the number of M5stack youtube "how to" videos that appeared for previous "Core" products, the CoreS3 is suffering. Maybe I got on the Core2/Fire bandwagon after most teething troubles were fixed and most features were no longer "Alpha"!