Sending MQTT commands

Forum Home Forums Communicating with Devices Sending MQTT commands

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #15648
    Jorge
    Participant

    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 this

    I added commands to the MQTT client but further than that I have not been able to send actual commands from a scheme.

    #15651
    Mikhail
    Moderator

    Hi,

    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.

    #15652
    Mikhail
    Moderator

    You don’t need to add commands in the device properties. You can just write data to elements of subscriptions.

    #15654
    Jorge
    Participant

    I 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.
    #15657
    Mikhail
    Moderator

    Please provide screenshots of the settings, and commands sent.

    #15660
    Jorge
    Participant

    no problem.

    this is the line option:
    Line option

    this is the Device 1 properties (works fine, I receive data):
    Device 1 properties

    this is the Device 2 properties (not working, can’t send commands)
    Device 2 Properties

    this is how I send the command:
    command

    #15672
    Mikhail
    Moderator

    1. 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.

    #15674
    Jorge
    Participant

    Hi, 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.

    command output

    now I am working to do this with a button from a scheme.

    #15675
    Jorge
    Participant

    On 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.

    command format

    the payload is this:
    {“devEui”:”a8404152d185b432″,”confirmed”:true,”fPort”:5,”data”:”AwAA”}

    the output of pressing the button is this:
    button output

    output line log:
    output line

    #15678
    Mikhail
    Moderator

    Please 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.

    #15680
    Jorge
    Participant

    here there are

    the correct command when it is sent from the administrator:
    command from the administrator

    the same command when it is sent from the button:
    command 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.
    log line

    #15681
    Jorge
    Participant

    I donĀ“t know if this is helpful.

    Device command history

    the commands sent from the button are the ones without the “Code” value

    #15683
    Jorge
    Participant

    I 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.

    #15687
    manjey73
    Participant

    https://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

    #15690
    Mikhail
    Moderator

    Likely, the channel properties are incorrect. Make sure that the tag code of the channel is set.

Viewing 15 posts - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.