RPC command to set location variables

Hi there

Im working on an Interface to control my farmbot with an own GUI which is basically built on node-red flows. Therefore i have to use the API which is already working well and the subscribtion of the MQTT topics is also no problem. In order to get the full potential of the new features in Farmbot OS 12 I would like to excecute also sequnces which are configured dynamically and therefore have externally defined variables to use it in a general way.
Which is the RPC command to set those externally defined variables and how can it be done?
So far there is not much to share, but as soon the GUI is properly working I can share it with you if you are interested…

@Nevel This sounds like a fun project. The good news is that the MQTT and REST APIs are all you need to build custom control software. These are the same APIs used by the frontend.

Before you get started, have you read the software developer guide?

Please note that this is a guide rather than a reference. It is intended to be read from start to finish rather than in pieces.

To answer your question, you can assign variables using Celeryscript, an internal AST structure used to control the device.
Normally, a developer does not need to directly touch Celeryscript and they can instead use FarmBotJS. For advanced use cases, it may be required.

If you already have an understanding of CeleryScript, I would be happy to explain more about the parameter_application node. I would be more interested in hearing about your exact use case, though.

Hey Rick
Thanx for this prombt answer. Yes the documentation makes life way easier and I looked up only the pieces I’m intrested in but I just realized that you recently updated the celery script section! So I will definitely read it again from start to finish in order to have the same understanding. :face_with_monocle:
So I see the solution will be to set up an approriate celery script and use the command parameter_application or lets call it node. Correct?
So the use case I’m focusing on, is to have on the GUI a number of predefined commands like (take photo, water plantXYZ and also find home) and therefore gives the operator the possibility to interact with the bot only with a limited number of commands. This will be then public proofed :stuck_out_tongue_winking_eye:

@Nevel

That’s very possible. A good next step is to enable the “View CeleryScript” option in the sequence editor:

This will show you how the sequence editor builds sequences under the hood.

If you have more specific questions, I am happy to answer them.

The new option of “View Celery Script” in the web app is great!
A good point to start is also to study the JS-libary you set-up which gives a good understanding about all the RPC instructions which are available.
So far i could set up RPC commands for running sequences and listening to different channels . But I’m struggling with the additionl location variable at the moment. Is this SeleryScrip correctly set-up in order to applicate the location variable tomato as a PointGroup?
{“kind”:“rpc_request”,“args”:{“label”:“undefined”},“body”:[{“kind”:“execute”,“args”:{“sequence_id”:“43109”},“body”:[{“kind”:“parameter_application”,“args”:{“data_value”:“PointGroup”,“label”:“tomato”}}]}]}

@Nevel

You are very close, but there are two problems.

Problems:

  • You set the label (variable name) needs to be set to parent. parent is the default variable name, so you will need to set the label of a parameter_application to parent 99% of the time.
  • You set the data_value to a string value of "PointGroup". You should instead use a point_group object.

Other tips:

  • You set the label to "undefined". This means that when FarmBot accepts the RPC, it will reply with an rpc_ok message with a label set to "undefined". At FarmBot, we usually set the label value to a long unique string.

Below is an example. I have not tested it, but am fairly certain it will work.

{
  "kind": "rpc_request",
  "args": {
    "label": "anything"
  },
  "body": [
    {
      "kind": "execute",
      "args": {
        "sequence_id": "43109"
      },
      "body": [
        {
          "kind": "parameter_application",
          "args": {
            "data_value": {
              "kind": "point_group",
              "args": {
                "point_group_id": 456 // CHANGE THIS TO A POINT_GROUP ID
                }
            },
            "label": "parent"
          }
        }
      ]
    }
  ]
}
1 Like

"Works on My PC" :tm: Thanks !

Using 1 RPC, my little Express box is currently executing one Sequence over a Point Group with 143 members . . “as we speak” :slight_smile: _ |edit| On FBOS v12.2.1-rc3

1 Like