Configuring the web interface


Original article (german) from sweetpi.de

pilight doesn't only allow you to control 433mhz devices from the command-line. It also includes a webserver with a nice web interface. This article explains how to add devices to the pilight config so that they show up in the web interface.

Structure of the config.json file

All devices must be added to the config.json. You can read about the format of the config.json here. A short example:

{
    "room1": {
        "name": "living",
        "device1": {
            "name": "TV",
            "protocol": [ "intertechno_switch" ],
            "id": [{
                    "id": 1234,
                    "unit": 0
            }],
            "state": "off"
        }
    },
    "room2": {
        "name": "working room",
        "device2": {
            ...
        }
    }
}

In the first level are your definitions for your rooms. room1 and room2 are arbitrarily choosen identifiers. Every room definition then contains a property for its name and several devices.

All devices have a name property, which is the display name used in the web interface. Other properties are protocol dependend and can be found in the wiki. or can be discovered like described in the previous post.

Create a config.json file

Before you create or edit pilight files you should stop the pilight-daemon process, because pilight otherwise could overwrite your changes.

pi@pilight:~# sudo killall pilight-daemon

The file can be placed at /etc/pilight:

pi@pilight:~# sudo nano /etc/pilight/config.json

Then insert your config like explained above. Another example:

{
    "living": {
        "name": "living",
        "tv": {
            "name": "TV",
            "protocol": [ "intertechno_switch" ],
            "id": [{
                    "id": 1234,
                    "unit": 0
            }],
            "state": "off"
        }
    },
    "work": {
        "name": "work room",
        "light": {
            "name": "desk light",
            "protocol": [ "intertechno_switch" ],
            "id": [{
                    "id": 1234,
                    "unit": 1
            }],
            "state": "off"
        }
    }
}

Set the config-file property in the settings.json file

As a last step, the path to the config.json must be inserted in the settings.json:

pi@pilight:~# sudo nano /etc/pilight/settings.json

Add the entry (if it isn't already there):

"config-file": "/etc/pilight/config.json"

and be sure that the following entry exists:

"webserver-enable": 1

Testing

Start the piligt-daemon with the following command:

pi@pilight:~# sudo pilight-daemon -D

If no error message appear, the webinterface can be accessed with your web browser:
https://ip-of-your-raspberry-pi:5001

Published on