Brain packages development

Note

If you think something is not clear or is missing in this documentation, please send an email to our developers mailing list : domogik-developers@lists.labs.libre-entreprise.org and explain us clearly what is not clear or what could be added.

General informations

Some parts of this documentation will refer to the plugins development documentation as there are a lot of things in common :

  • the workflow
  • the way to create a repository, to write the doc, to submit the package

Differences between a plugin and a brain package

A brain package is not something that is executed directly : the butler component will load each brain package it will find on the current host.

A brain package does not need to create any device, so all the related informations in the json file will be empty.

A brain can contain several translations : you can find all the available languages in the rs/ folder. Example :

./rs

./rs/nl_BE
./rs/nl_BE/DT_Temp.rive
./rs/nl_BE/...
./rs/nl_BE/DT_Humidity.rive

./rs/fr_FR
./rs/fr_FR/DT_Temp.rive
./rs/fr_FR/...
./rs/fr_FR/DT_Humidity.rive

./rs/en_US
./rs/en_US/DT_Temp.rive
./rs/en_US/...
./rs/en_US/DT_Humidity.rive

The RiveScript code is used as a basis. You can find more informations on the official website : http://www.rivescript.com/docs/tutorial

First, create a repository and write some specifications

See the plugin development documentation.

Branches management

See the plugin development documentation.

Brain package name

There is no restriction in the length of the brain package name (for plugins, you have a 8 characters limitation due to xPL).

Prepare the plugin

See the plugin development documentation.

Specific parts :

Before coding : branching to ‘develop’

See the plugin development documentation.

Json file

See the plugin development documentation.

To sum up, for a brain, you need only to fill 3 parts. You have to let the others empty :

  • identity
  • configuration
  • json_version

Example:

{
    "identity": {
        "author": "Fritz",
        "author_email": "fritz.smh at gmail.com",
        "tags": ["butler"],
        "dependencies": [],
        "description": "Butler package to use Wolfram Alpha",
        "domogik_min_version": "0.4.1",
        "name": "wolfram",
        "type": "brain",
        "version": "1.0"
    },
    "configuration": [
        {
            "default": "",
            "description": "To get a Wolfram Alpha API key, you need to register (freely) on https://developer.wolframalpha.com/portal/signin.html",
            "key": "api_key",
            "name" : "Wolfram alpha API key",
            "required": true,
            "type": "string"
        }
    ],
    "products": [],
    "commands": {},
    "xpl_commands": {},
    "sensors": {},
    "xpl_stats": {},
    "device_types": {},
    "json_version": 2
}

Python part

Some brain parts may need a library file to interact with some internet services (for example). You can create a python library in the lib/ folder.

See the Rivescript rules for more informations.

Dedicated administration page

See the plugin development documentation.

Icon

See the plugin development documentation.

Documentation

See the plugin development documentation.

Tests

Note

This part is to complete. There is currently no test framework.

Your brain is ready ? Make some users test it

See the plugin development documentation.

Release a version of your brain

See the plugin development documentation.