项目作者: rkirkels

项目描述 :
A PHP library to connect to the Domoticz Home Automation System
高级语言: PHP
项目地址: git://github.com/rkirkels/domoticz-php.git
创建时间: 2016-10-31T08:48:53Z
项目社区:https://github.com/rkirkels/domoticz-php

开源协议:

下载


domoticz-php

Library for connecting to Domoticz

With this library you can control lights, switches, thermostats and other home automation devices with PHP by connecting to Domoticz, the open-source Home Automation System.

Installation

php composer.phar require rutgerkirkels/domoticz-php

Basic usage

  1. <?php
  2. // Initialize the Domoticz library with the hostname of the Domoticz machine.
  3. // If you didn't set login credentials, you can leave the username and password
  4. // attributes empty.
  5. $domoticz = new \rutgerkirkels\domoticz_php\Domoticz('<hostname>','<username>', '<password>');
  6. /**
  7. * This example reads the temperature from the first temperature sensor that is found
  8. */
  9. // Get all the temperature sensors in Domoticz
  10. $temperatureSensors = $domoticz->getTemperatureDevices();
  11. // Get the temperature from the first sensor
  12. echo $temperatureSensors[0]->Name() . ' temperature is ' . $temperatureSensors[0]->Temp();
  13. ?>

Another example: Read the status of the first light/switch that is found in Domoticz:

  1. <?php
  2. $lightsAndSwitches = $domoticz->getLightsAndSwitches();
  3. echo 'Status of ' . $lightsAndSwitches[0]->Name() . ': ' . $lightsAndSwitches[0]->Status();
  4. ?>

Domoticz-php also offers the ability to pre-define home automation appliances through a YAML-config file, so that you can use appliances that consist of multiple sensors and switches, like a Nest Thermostat.