#asyncio & MQTT
1 messages Β· Page 1 of 1 (latest)
It has to be something with MQTT - this code works. I poll AIO every 30 seconds for the last value and then updates and scrolls the message. So at least I have a backup plan for my project. π
had some IRL things, and since I have the ye olde schoole M4 MatrixPortal, switched over the code to ESP32SPI, waiting for song change π
can you change song again? I had to reload
done, had to take the dog out of course
had to fix the payload_data vs. json_data, reloaded
updated
I gotta get my own feed, this is gonna get redonk
sorry :/
not your fault, I just hate to keep bugging you everytime I have a syntax error o_O I'm stumped by this one, and don't want to be
I don't mind, I'm the one getting help. π
Though if you want, I could give you a 30 second audio sample or two and use this: https://github.com/prcutler/songmatrix/blob/main/identify.py
if this keeps going, I'll figure out something... any frequently-changing MQTT feed ought to do
can you change song again?
yup, I wish I it would notifiy me in a thread
I'm trying to publish from another async def to feed myself data π
gotcha
I've missed a bit of this, but you're having issues with MQTT?
Does your MQTT-based code call the loop() method?
MQTT has keepalive messages that the client has to send the broker periodically (default varies by client but generally a few seconds) or the broker will close the connection.
The loop() method makes sure that they're sent often enough.
So any sleeping or other delays that don't give the loop() method a chance to run will cause the connection to get closed.
Sorry if this is ground you've already covered or not relevant to the issue you're seeing
No, appreciate the insight, thanks!
how often does .loop() have to be called?
the connection isn't dying,, it some other weird interplay between async and mqtt
if you're trying to receive data, .loop() handles that as well
a variable assignment isn't sticking
well, I have a simplified version working, not sure what's different except I'm creating my own feed data... publishing then callback to message()
I did increase the interval and used force
let me see if I can narrow down the differences
awesome, thank you
i broke something, always times out now (not sure if socket_timeout works right on esp32spi)
no problem, appreciate all the help
oh, wow, had accidentally copied an old lib with the cert problem
(after CIRCUITPY crashed and wiped itself)
doh
OK, I'll post what I have... structure is a mess and it's ESP2SPI, but the async part is the key I think
awesome, thanks. I need to head upstairs to make dinner for the family, I'll take a look tonight.
I'll repost if I clean it up more or get it more like what you have
some tweaking probably needed... the color changes don't sync exactly to a text update, and sometimes the update seems to jump a bunch of pixels
but maybe we can figure out the nuance of difference between the code files that makes it stop working
I'm struggling to put it back together - straight copy / paste works though! So now I know it's just me. π
I can't find why yours doesn't work, there's something subtle to it
I added a second line of text, but I'm still not doing JSON, can't imagine that would matter, but anything goes at this point
well, that's the weird thing. I have it working, except as soon as I put my message code in to parse and display the json, it shows Loading again, but then doesn't show the updated text, it's the old artist
I don't have to do JSON, that might be the next part is ripping that out and just sending a string and splitting it
It's the JSON - I passed the payload, made sure it was a string and split it, and it works!
And I very much like your exception handling, thank you for that and everything else
glad you figured it out, I never would have guessed JSON vs. string could explain the behavior
if you hadn't done all that work I would have never guessed - thanks so much
youβre welcome, i learned a lot tooβ¦ maybe Iβll do an MQTT project now π
publishing and receiving JSON working OK, key pieces are in publish and message, still not sure what nuance of difference between what works and what doesn't