Sending MQTT message to blynk

Hi!
I am using local blynk server (server-0.41.15.jar). I was able to send mqtt message to blynk: mosquitto_pub -h <IP> -p 8440 -t “hardware” -u <UID> -P <TOKEN> -m “dx 2 0”. It update the relevant pin on the app side (in this case digital_pin_2 will be 0 on app side), but does not update on the device side. It is possible to send the relevant message also to the device?
Thank, Tamás

This is interesting!

I use MQTT for my home automation devices, but use Node-Red with the Blynk websockets plugin to enable MQTT to Blynk to MQTT communication.

How did you come up with this method/syntax for direct Blynk server communication?

Pete.

I had 3 source: How does the built-in MQTT endpoint work?
Blynk message format: https://github.com/blynkkk/blynk-server/tree/master/client
And some debuging

In the source code I see 3 function, which may be interesting
i, reportingDao.process(state.user, dash, deviceId, pin, pinType, value, now);
this is may be for database handling
ii, session.sendToApps(HARDWARE, msg.variableHeader().packetId(), dashId, deviceId, body);
This is for app update
iii, state.user.profile.update(dash, 0, pin, pinType, value, now);
This I could not follow up, yet.

Hi,

I also try to connect to the embedded MQTT server but I had no success.
I tried to connect to the server using “MQTT Explorer” but each time he returns me the error “Connection refused: Bad username or password”.

I use the same username and password as for the Android application.

Thanks for sharing your experience.

Steve

I just tried this and it works using MQTT explorer.

image

The password is the auth token for the project that you want to write to.

I added a Labelled Value widget attached to pin V1 and publishing vx 1 Hello to the hardware topic displays “Hello” in that widget on the app.

I still don’t have a use for this piece of “functionality” though!

Pete.

Hi!
For me this could be an easy integration with other tools using MQTT.
I am playing with OpenHAB, and Arduino is only the “switch at the end”. But I try not to throw away thing working in Blynk.
But now I can only update app side, not the hardware side, so it is not good enough, yet.

Password is the token for the relevant projekt, not the password to the Android app.

To be honest, Node-Red with the Blynk ws contrib plug-in is so easy and reliable that it’s just not worth using anything else, unless Blynk eventually release a fully functional and fully supported two-way MQTT solution.

I’ve been using the Node-Red and Blynk this way for almost 4 years and it’s extremely reliable. I don’t run any Blynk code on my endpoint devices, they are simply ESP8266’s with relays or sensors attached and communicate entirely via MQTT.

Node-Red is also great for managing other integrations such as Amazon Alexa.

Pete.

I didn’t expect to use authentication token as a password.
Furthermore, I have the impression that the embedded MQTT server is very light and does not respect the MQTT philosophy very much. In fact, I was unable to subscribe to a topic.

Steve

Hi,

I believe that the embedded MQTT server is not implemented as the MQTT philosophy requires.

Steve

Pete told me but it was quite unexpected for me even though I think it’s a relatively elegant solution.

Steve

Yes, it is a very easy implementation. It is only a POC. There is only one topic, hardware. And I think, you can only sent info into the server. Subscription is not implemented. But I am not shure.

the clue was here…

Pete.

Currently, I do not use Node-Red. I will take a look later.

I love Node-Red!

There’s a bit of an introduction included in this topic…

Pete.

I think you are unfortunately right.

Pete

I will take a look later.

Steve