pilight
, (*1)
Library to call pilight (currently via pilight-send) from php., (*2)
Dev branch is master branch.
, (*3)
Table of Contents
- Installation
-
Usage
, (*4)
Installation
The recommended way to install is through Composer., (*5)
{
"require": {
"se/pilight": "dev-master"
}
}
Basic usage
Require the composer autload file and import the namespace., (*6)
require_once __DIR__.'/vendor/autoload.php';
use \SE\Component\Pilight;
Send
$sender = new Pilight\Sender();
// or set a custom ip and port
$sender = new Pilight\Sender($host = '129.168.2.1', $port = 6535);
$protocol = 'elro';
$arguments = array(
's' => 31,
'u' => 1,
);
$device = new Pilight\Device($protocol, $arguments);
// or add the arguments later via setArguments
$device->setArguments($arguments);
// turn it on
$device->addArgument('t');
// send it!
$sender->send($device);
If you need root permissions to call pilight-send, call setSudo(true) on $sender., (*7)
$sender->setSudo(true);
$sender->send($device);
You can add the pilight-send executable to your sudoers configuration to make it callable via sudo without the need to enter a password. This is in case your pilight-send needs to be called via sudo rights you can get some unexpected output during runtime if setting it not., (*8)
$ sudo nano /etc/sudoers.d/pilight
Contents:, (*9)
www-data ALL= NOPASSWD: /usr/local/sbin/pilight-send
pi ALL= NOPASSWD: /usr/local/sbin/pilight-send
<REPLACE YOU USER> ALL= NOPASSWD: /usr/local/sbin/pilight-send