January 24, 2016

First steps with pilight

So I started to experiment with home automation, especially with pilight. Install went easily, but making it detect my devices was a bit harder (since I could not find any description on that). So I will write my experiences:
  1. The main config file is in /etc/pilight/config.json
  2. Connect your 433 MHz receiver and sender to the pins mentioned in the config file (default: sender - pin0, receiver - pin1). I have an extension board, so maybe the numbering will be different for you. Here is the mapping between the two numbering:

  3. pilight-receive - run it from command line, then press the button on your remote
  4. It will display a lot of possible decoding of your protocol. Try to find one, which you think is correct.
  5. Go to https://wiki.pilight.org/doku.php and search for your protocol to find an implementation with sample code. 
  6.  sudo service pilight stop; sudo nano config.json  - stop pilight and open config.json
  7. Copy the sample code to config.json and change according to the received values (usually change the id, unit etc.).
  8. Test it with: sudo service pilight start; sudo service pilight status
  9. If it says: "pilight failed to start" check the debug messages with sudo pilight-daemon -D   Probably there is an error in config.json. Fix it, and try again. 
  10. If it works, access the web interface under the port written in config.json.
  11. Try to change the value, or just see if it is changed by pressing the buttons on the remote
  12. If not, try an other result of pilight-receive
 And finally here is my config.json file with only a few entry (since plugA_old does not have a gui entry, it will not show up on the web interface):

{
        "devices": {
                "openDoor": {
                        "uuid": "0000-b8-27-eb-fd662e",
                        "protocol": [ "kaku_switch_old" ],
                        "id": [{
                                "id": 20,
                                "unit": 2
                        }],
                        "state": "off"
                },
                "plugA": {
                        "protocol": [ "kaku_switch" ],
                        "id": [{
                                "id": 2683906,
                                "unit": 0
                        }],
                        "state": "on"
                },
                "plugA_old": {
                        "protocol": [ "kaku_switch_old" ],
                        "id": [{
                                "id": 8,
                                "unit": 2
                        }],
                        "state": "off"
                }
        },
        "rules": {},
        "gui": {
                "openDoor": {
                        "name": "Door open sensor",
                        "group": [ "Living" ]
                },
                "plugA": {
                        "name": "Plug A - desk lamp",
                        "group": [ "Living" ]
                }
        },
        "settings": {
                "log-level": 6,
                "pid-file": "/var/run/pilight.pid",
                "log-file": "/var/log/pilight.log",
                "webserver-enable": 1,
                "webserver-root": "/usr/local/share/pilight/",
                "webserver-http-port": 5001,
                "webserver-cache": 1
        },
        "hardware": {
                "433gpio": {
                        "sender": 0,
                        "receiver": 1
                }
        },
        "registry": {
                 "pilight": {
                        "version": {
                                "current": "7.0"
                        }
                }
        }
}

No comments:

Post a Comment