sineverba / domoticz-php-api-wrapper
This package is abandoned and no longer maintained.
No replacement package was suggested.
Simple PHP wrapper for the Domoticz API
v2.1.0
2019-03-12 16:55 UTC
Requires
- php: ^7.1
- ext-json: *
- guzzlehttp/guzzle: ^6.3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.14
- phpunit/phpunit: ^7.0
README
V. 2.1.0 - Last update: 12/03/2019
Simple PHP wrapper for the Domoticz API.
Thank you to Domoticz for wonderful work.
With this library, you will can connect to your Domoticz server via API.
Check with compatibility table if you need V1 or V2.
V1 is not anymore mantained. V2 under development.
Version compatibility table
Domoticz API V 2
Domoticz Version | Stable / Beta | Compatible / Working |
---|---|---|
4.9700 | STABLE | YES |
4.9788 | Beta | YES |
3.9501 not tested anymore, I did revert to 3.8153 after that issue.
Domoticz API V 1
Domoticz Version | Stable / Beta | Compatible / Working |
---|---|---|
3.8153 | STABLE | YES |
3.9453 | Beta | YES |
3.9458 | Beta | YES |
3.9501 | Beta | NO See issues |
3.9639 | Beta | YES |
4.9700 | STABLE | YES |
4.9732 | Beta | YES |
4.9763 | Beta | YES |
4.9764 | Beta | YES |
3.9501 not tested anymore, I did revert to 3.8153 after that issue.
Install
Version 2.X
$ composer require sineverba/domoticz-php-api-wrapper "^2"
Version 1.7.1
$ composer require sineverba/domoticz-api "^1"
Usage
Version 2
<?php require_once ('vendor/autoload.php'); use \sineverba\domoticzapi\Auth\Auth; use \sineverba\domoticzapi\Adapter\Adapter; use \sineverba\domoticzapi\Client\Client; use \sineverba\domoticzapi\Exceptions\AuthException; // Required params $data = [ 'username'=>'username', 'password'=>'password' ]; $uri = 'http://www.example.com:8080'; // Uri of Domoticz server // Initialize $auth = new Auth($data); $adapter = new Adapter($auth,$uri); $client = new Client($adapter); try { // Get Domoticz Version $domoticz_version = $client->getDomoticzVersion(); // Get Devices $devices = $client->getDevices(); } catch (AuthException $e) { echo $e->getMessage(); }
Version 1
<?php
use \sineverba\domoticzapi;
//Instantiate an api Client to Domoticz
$api = new \sineverba\domoticzapi\Client( 'username' , 'password' );
//Default host is 127.0.0.1:8080, you can change it
$api = new \sineverba\domotizapi\Client ( 'username' , 'password' , 'http://www.example.com:1234' );
//Get list of devices
$devices = $api->getDevice();
//Get list of devices type filtered
$devices = $api->getDevice(null , 'temp');
//Get single device by idx
$device = $api->getDevice($idx);
// Get a single device by name
$device = $api->getDeviceByName($name);
// Get list of user variables
$user_variable = $api->getUserVariable();
// Power on a device. If the device is password-protected, set password as second parameter
$on = $api->powerOn($device , $pin = null);
// Power off a device. If the device is password-protected, set password as second parameter
$off = $api->powerOff($device , $pin = null);
// Toggle a device. If the device is password-protected, set password as second parameter
$toggle = $api->toggle($device , $pin = null);
// Write log
$log = $api->writeLog(string $log);
// Set a user variable
$api->setUserVariable ( $name , $value );
// Delete an user variable
$api->deleteUserVariable ( $idx );
// Set a reading for a counter
$api->setCounterReading($idx,$reading);
// Write text on sensors text
$api->writeText($idx,$text);