MQTT node connecting to Thingspeak?

#1

I am struggling to do something simple with the MQTT node: Get the cheerlights feed directly from Thingspeak. I can get it without problem from iot.eclipse.org but cannot seem to find the correct setup of the Thingspeak broker node.
The server is mqtt.thingspeak.com, port 1883.
Security is a random username and my API key.
The messages tab is left blank (I think).
The Topic is "channels/1417/subscribe/fields/field1" with QoS = 0.
It's probably something simple, but I'm just not seeing it. The result is always "disconnected" which, according the the Thingspeak MQTT documentation is the consequence of "Invalid subscription details such as API Key, channel number, or MQTT User API Key result in the client being disconnected."
Where am going wrong?
Thanks.

#2

Hi - you made it here :slight_smile:
This is my MQTT Node

image

image

image

Does that match up with yours?

Simon

#3

Yes, it does. But it works now that I replaced my User API key with my MQTT API key. Doh. Like I said, it had to be something simple!
Thanks for taking the time!
--Jeff

1 Like
#4

No problem - glad to help out :slight_smile:

On a separate note, I've had reliability issues in the past with this MQTT feed, which is why I've don't use it as my main source of cheerlights info

I parse the main http://api.thingspeak.com/channels/1417/feed.json instead and update my cheerlights feed based on changes in it

AFAIK the Thingspeak mqtt broker only supports QOS 0 so I think its inherently not reliable as it doesn't have to deliver all msgs to all listening clients.

I am probably going to switch over to using AndySCs feed at iot.eclipse.org (now that he's removed the non-standard black :slight_smile: ) but just need to run a few tests to see if it follows the main cheerlights feed.json

Simon

#5

it does... it's fed off an official web hook notification feed directly from ThingSpeak :wink:

1 Like
#6

The things you gods can do :slight_smile:

I think tomorrow I be mainly removing 30 nodes from my cheerlights flows :slight_smile:

#7

Well then, I will follow the crowd of experienced people over to eclipse. I only went digging for the Thingspeak info because of the black, which AndySC has so kindly removed. So we're all good here and I learned something (and continue to do so). My ESP Cheerlight is now based off of Dr Lucy's code (because she programs waaaay better than I will ever) and I don't need to filter the stream or poll Thingspeak for anything. Simplify, simplify, simplify.
And I just thought of an interesting project: use a Raspberry Pi to send DMX commands to a mini-DMX LED floodlight using Node Red...

But I should really go back to paying attention to my day job :grimacing: .

#8

@andysc While your here - could I talk about the iot.eclipse.com vs main Thingspeak API output (http://api.thingspeak.com/channels/1417/feed.xml or http://api.thingspeak.com/channels/1417/feed.json)

If I do a triple tweet e.g @cheerlights red green blue - somethimes Thingspeak API will sometimes not output one of the colours - but your feed catches them all and outputs them in correct sequence 30 secs apart

How does your webhook get colours that Thingspeak misses?

It's not a real practical issue obviously as the next single colour tweet will sort it out but I've always been interested in why the difference

Simon

#9

Do you mean it doesn't appear in the feed at all, or you don't catch it by polling and looking at the last item on the feed?
They come through quickly, so you'd be hard pushed to poll fast enough to catch them all.

That's why we have MQTT :wink:

I get three callbacks on the web-hook (one for each colour) and then queue them up with a delay node for nicely-paced delivery to MQTT devices.

If you mean the history feed omits some of the entries, that's a question for @scharler :slight_smile:

#10

And also - thingspeak does not necessarily output the coluors in the order they appear in the tweet - whereas your feed does.[edit] subsequent tests prove that neither feeds follow the colour order all of the time![/edit]

Which makes me think you are doing your own twitter parsing (or something) and not outputting the One True Cheerlight Colour :slight_smile: xkcd/927 again :slight_smile:

#11

I posted that at same time as your post!

#12

I'm not asking all this on behalf of myself BTW - I'm asking for a Martian friend who wonders why some of the cheerlights they can see thru their telescopes are not the same as the others :slight_smile:

1 Like
#13

Double output from Twitter node... deleted -- off topic. Will re-post as a new topic.

#14

I only pass through what I receive from the web-hook callback from ThingSpeak. I do not parse the twitter feed myself.

I have to say, I've never seen the colours coming through out of order, and I have spent a LOT of time watching them :wink:

#15

welll.........and it might be me but........

Sent this tweet

image

and your feed sent out

red
green
blue
yellow
pink
magenta
purple
orange
cyan

and the main cheerlight api sent out

image

At least you got them all :slight_smile:

Now, in practical terms , for 99.9% use cases, getting the wrong order (or missing some out) doesn't matter

But the [edit]possible[/edit]difference in the final colour does cause my OCD to kick in :slight_smile:
[edit] noticed that in this test you both agree on final colour but I don't think that is not always true)[/edit]

Now although both feeds have differences, I believe that the Cheerlights API is right because it is the Cheerlights API.

Rule 1 of cheerlights is that Cheerlights API is right :slight_smile:

Like I say, it only effects people up on the ISS and my Martian friends :slight_smile:

But it could spoil the look of a street come Christmas (if a lot of geeks live in it) :slight_smile:

Simon :slight_smile:

1 Like
#16

Just did another one (that shows that difference in last cheerlight)

image

yours (perfect this time BTW :slight_smile: )

white
orange
purple
pink
magenta
cyan
yellow
blue
green
red

Cheerlight API

image

#17

And yes - I need to get out more :slight_smile:

#18

Andy forwarded me this thread. CheerLights has some unique handling at ThingSpeak. We will make changes in September that will fix this issue.

2 Likes
#19

And we will thank you for it (I'd wager).
Like cymplecy, I need to get out more often too. I have spent way too much time on this in the last week. But I have some more ideas I want to try out...

As they say, When the Student is Ready, the Teacher[s] will Appear.