Mqtt mariadb function query

Good trades, I have a wemos d1 with espeasy that now only has a switch that sends status to domoticz open or closed.
What I want is for node to connect to the mqtt broker, receive status and do an INSERT INTO event with a function, I've tried many different ways and it fails to insert the data to the db.
the data it reads is {"idx":181,"RSSI":10,"Battery":41,"command":"switchlight","switchcmd":"On"}
I am only interested in entering 2 valkores into the database since the rest would have to be null and automatically enter the values ​​that interest me are:
On the other hand, I have a concern. There is no way to tell me from which esp8266 the data comes?
I also notice that the logo is generated payload.switchcmd on every few seconds why is this? For me this is wrong, I would only have to inform myself when the state changes, otherwise it will fill the database with garbage information.
Well I attach the images with all the configurations.

I'm new to node and I don't have much knowledge with queries in mariadb.

Thank you ladies


Nahuel, welcome to the forum.

In ESPEasy, add an id of the esp8266 to the mqtt topic. Assuming you have more than one, do it to all of them. Then you can subscribe to a topic using wildcards. if you don't know about wildcards see the reference(1) at the end of this post

I'm not sure what you mean by 'logo' but if you are saying that you are receiving an mqtt-in message every few seconds, that must be caused by the ESPEasy device set to sent it that often. If that is not what you mean, you will have to explain yourself a bit more.

(1) If you want to learn more about MQTT then see this tutorial MQTT Essentials - All Core Concepts explained - Part 5 talks about topics.

Ok thanks for your suggestions I will read more about MQTT I send you more information.
Actually the layout is as follows:
wemosd1 with esp-easy mqtt sends data to domoticz about the status of a domotic door I have a virtual sensor that shows me when the door is open or closed without problems.
The idea is to connect node-red to the mqqtt broker that reads domotic and take that data to enter it into a database. I am testing with a switch but the idea is to put an rfid reader to each wemos in different settings.
So I need the data that arrives at node-red to tell me which port that data belongs to.
I attach images of my wemos and the domoticz

Thank you ladies


'Current Client ID' is not the topic. The topic is what is in 'Controller Publish' so add something to that to identify the device.

The LWT (Last Will and Testament) items are the Topic and messages sent when the device connects to the MQTT broker and when the device fails to send a message after a defined amount of time. See Part 9 of the MQTT Essentials for details.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.