Forum Home › Forums › Communicating with Devices › Sending MQTT commands
- This topic has 14 replies, 3 voices, and was last updated 1 day, 11 hours ago by Mikhail.
-
AuthorPosts
-
November 25, 2024 at 7:29 pm #15648JorgeParticipant
Hi, I have a question.
I have been working with rapidscada with mqtt communication, receiving data with no problem but now I want to send commands, for now, I want to do this with a button in a scheme, but I have not found any documentation about thisI added commands to the MQTT client but further than that I have not been able to send actual commands from a scheme.
November 26, 2024 at 10:54 am #15651MikhailModeratorHi,
In the Administrator app, right-click the device, choose Send command. Type the tag code as a command code and send. Does it work? If not, check a communication line log.
November 26, 2024 at 10:55 am #15652MikhailModeratorYou don’t need to add commands in the device properties. You can just write data to elements of subscriptions.
November 26, 2024 at 1:53 pm #15654JorgeParticipantI created another device for sending commands because I am working with 2 different devices(one to subscribe (works) and the other one to send commands (doesn’t work)). Also, this is deployed on a Linux machine, while the administrator runs on Windows.
For the new device, I added a subscription with the topic where I want to send commands then I right-clicked the devices, selected “send command…” and typed the command in the command code, the command I need to send is JSON formatted
{"devEui":"a8404152d185b432","confirmed":true,"fPort":5,"data":"AwAA"}
In the Line Log when I send a command, it says:
2024-11-26 10:47:17 Command '{"devEui":"a8404152d185b432","confirmed":true,"fPort":5,"data":"AwAA"}' to the device [3] MQTT LT-22222-L Error: invalid command
if i enter the linux machine via ssh and send this command via mosquittoMQTT it works:
mosquitto_pub -h localhost -p 1883 -t 'application/861cbd58-9d39-4046-a074-b6d47e40dec7/device/a8404152d185b432/command/down' -m '{"devEui":"a8404152d185b432","confirmed":true,"fPort":5,"data":"AwAA"}'
thanks for your time
- This reply was modified 1 week ago by Jorge.
November 27, 2024 at 8:48 am #15657MikhailModeratorPlease provide screenshots of the settings, and commands sent.
November 27, 2024 at 3:24 pm #15660JorgeParticipantno problem.
this is the line option:
this is the Device 1 properties (works fine, I receive data):
this is the Device 2 properties (not working, can’t send commands)
this is how I send the command:
November 28, 2024 at 9:32 am #15672MikhailModerator1. I recommend to use short Tag codes for your convenience.
2. When you send a command, specify the tag code in the Command code field.
Command value is data to send, just a number.November 28, 2024 at 3:30 pm #15674JorgeParticipantHi, I managed to send commands, I created a communication line for each topic, and then in the communication line for sending commands, I made an MQTT client device, added a subscription to the topic I wanted to send commands then added 2 commands to switch a relay, while adding the commands, in the command code a had to put the actual command I want to send and if not, does not work, and finally to send the command, right click on the devices, select “Send Command…” put the command I want to send in the command code and the string data.
now I am working to do this with a button from a scheme.
November 28, 2024 at 7:55 pm #15675JorgeParticipantOn the same line of questions, I want to send the JSON payload through a button, but I can’t get the format. In the channel device configuration, I select String as the Command format, but the output of pressing the button is in hex, and with this method, I get an error: invalid command.
the payload is this:
{“devEui”:”a8404152d185b432″,”confirmed”:true,”fPort”:5,”data”:”AwAA”}the output of pressing the button is this:
output line log:
November 29, 2024 at 10:36 am #15678MikhailModeratorPlease send screenshots:
1. A screenshot of the correct command when you send it from the Administrator app.
2. Screenshot of a command when you send it with a button.November 29, 2024 at 1:09 pm #15680JorgeParticipanthere there are
the correct command when it is sent from the administrator:
the same command when it is sent from the button:
Also, the log line shows the error when the command is sent from the button and OK when it is sent from the administrator.
November 29, 2024 at 1:55 pm #15681JorgeParticipantI donĀ“t know if this is helpful.
the commands sent from the button are the ones without the “Code” value
November 29, 2024 at 6:22 pm #15683JorgeParticipantI notice that when I send the command with the button, there is no command code, but when it is sent from the administrator, the command code needs to be the same as the command code from the device properties. If not, I get an error when I send the command from the administrator.
December 1, 2024 at 7:41 am #15687manjey73Participanthttps://postimg.cc/cKqCQpCn – Here you send a command with the numeric code 0, in the Code line you have the command text, not the channel tag code with the command
December 2, 2024 at 9:33 am #15690MikhailModeratorLikely, the channel properties are incorrect. Make sure that the tag code of the channel is set.
-
AuthorPosts
- You must be logged in to reply to this topic.