Skip to content

Dev Tips Jeedom Plugin

Pifou25 edited this page Dec 11, 2022 · 7 revisions

[FR] [How-To: Développement d'un Plugin Jeedom]

Technical help for plugin development

Let's say the **root **directory for a new Jeedom plugin is into

plugins/{name} that means for us plugins/lgthinq and every files and paths on this page are relative to this 'plugin root dir'.

the absolute path should be something like /var/www/html/plugins/{name}/

Entry point PHP

The main class that is the entry point for jeedom is, from the plugin root dir:

./core/class/{name}.class.php

./core/class/lgthinq.class.php

This class contains both the lgthinq extends eqLogic for each object, and also the lgthinqCmd extends cmd for each commands of the object.

Configuration of the plugin

The HTML Form commands for configuration are into the template in ./desktop/modal/include.php

Ajax responses

The HTML Form call ajax action located in the ./core/ajax/lgthinq.ajax.php, may include also core class if required.

Main page of the plugin

The main page is the first one you get when opening the plugin, it usually contains the list of every configured objects, and also one - or more - link(s) to the Configuration Form.

This page also contains the tabs for editing / configuring any object, the first panel for activate / rename / change the parent relationship, and so on... The second panel for adding / deleting / editing any command and information.

Main page is /desktop/{name}.php

Visual Studio Configuration for Auto-Copy

Using both Visual Studio Code extensions : multi command (from @ryuta46) and command runner (from @edonet) I can add a 'multi-command' triggered on 'Ctrl+s' shortkey (when saving file) that copy the file to another directory:

Add into settings.json

Create a new 'multi command' named copyFile : adjust the destination as needed. This command save the file, wait 2 seconds, and copy to another location.

    "multiCommand.commands": [

        {
            "command": "multiCommand.copyFile",
            "label": "Copy file to another location",
            "description": "copy the current $file to another root hard-coded destination, require 'command-runner' plugin.",
            "interval": 2,
            "sequence": [
                "workbench.action.files.save",
                {
                    "command": "command-runner.run",
                    "args": { "command": "cp \"${file}\" \"x:/${relativeFile}\"" }
                }
            ]
        }
    ]

Add into keybindings.json

Trigger the previously defined copyFile multicommand on 'Ctrl+s'

[
    {
        "key": "ctrl+s",
        "command": "extension.multiCommand.execute",
        "args": { 
            "command": "multiCommand.copyFile"
        },
        "when": "editorTextFocus"
    }
]