farmbot v6.0.1-alpha Farmbot.Farmware View Source
Farmware is Farmbot’s plugin system. Developing a farmware is simple. You will need 3 things:
- A
manifest.json
hosted on the internet somewhere. - A zip package of your farmware.
Farmware Manifest
The manifest.json
file should contain a number of required fields.
package
- the name of your package. Should be CamelCase by convention.version
- The version of your package. Semver is required here.min_os_version_major
- A version requirement for Farmbot OS.url
- A url that points to this file.zip
- A url to the zip package to be downloaded and installed.executable
- the binary file that will be executed.args
- An array of strings that will be passed to theexecutable
.config
- A set of default values to be passed to the Farmware. see Configuration for more details
There are also a number of metadata fields that are not required, but are highly suggested.
author
- The author of this package.description
- A brief description of the package.language
- The language that this plugin was developed in.
The zip package
The zip package is simply a zip file that contains all your assets. This will usually contain a executable of some sort, and anything required to enable the execution of your package.
Repositories
If you have more than one Farmware, and you would like to install all of them
at one time, it might be worth it to put them in a repository
. You will need
to host a special manifest.json
file that simply contains a list of objects.
the objects should contain the following keys:
manifest
- This should be a url that points to the package manifest.name
- the name of the package to install.
Developing a Farmware
Farmwares should be simple script-like programs. They block other access to the bot for their lifetime, so they should also be short lived.
Communication
Since Farmbot can not have two way communication with a Farmware, If you Farmware needs to communicate with Farmbot, you will need to use one of:
HTTP - Docs
- Easy to work with.
- Allows call/response type functionality.
- Requires polling for state updates.
- No access to logs.
Raw Websockets - Docs
- More difficult to work with.
- Not exactly call/response.
- No pollinig for state updates.
- Logs come in real time.
Configuration
Since Farmbot and the Farmware can not talk directly, all configuration data is sent via Unix Environment Variables.
NOTE: All values denoted by a $
mean they are a environment variable, the
actual variable name will not contain the $
.
There are two of default configuration’s that can not be changed.
$API_TOKEN
- An encoded binary that can be used to communicate with Farmbot and it’s configured cloud server.$IMAGES_DIR
- A local directory that will be scanned. Photos left in this directory will be uploaded and visable from the web app.
Additional configuration can be supplied via the manifest. This is handy for
configurating default values for a Farmware. the config
field on the manifest
should be an array of objects with these keys:
name
- The name of the config.label
- The label that will show up on the web app.value
- The default value.
When your Farmware executes you will have these keys available, but they will
be namespaced to your Farmware package
name in snake case.
For Example, if you have a farmware called “HelloFarmware”, and it has a config:
{"name": "first_config", "label": "a config field", "value": 100}
, when your
Farmware executes, it will have a key by the name of $hello_farmware_first_config
that will have the value 100
.
Config values can however be overwrote by the Farmbot App.
Link to this section Summary
Link to this section Functions
Lookup a farmware by it’s name.
Creates a new Farmware Struct