-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexamples.php
46 lines (31 loc) · 908 Bytes
/
examples.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/*
example file for different php-devoloDHC use cases
https://github.com/KiboOst/php-devoloDHC
*/
//start API and connect to your account:
require($_SERVER['DOCUMENT_ROOT'].'/path/to/phpDevoloAPI.php');
$_DHC = new DevoloDHC($DevoloLogin, $DevoloPass);
if (isset($_DHC->error)) die($_DHC->error);
//function to toggle the state or a rule:
function toggleRule($ruleName)
{
global $_DHC;
$isActive = $_DHC->isRuleActive($ruleName)['result'];
if($isActive=='inactive')
{
$_DHC->turnRuleOnOff($ruleName, 1);
}
else
{
$_DHC->turnRuleOnOff($ruleName, 0);
}
}
//then simply call toggleRule('myRule')!
//Turn a light (wall plug) on:
$_DHC->turnDeviceOnOff('myLight', 1);
//Check if a device is on:
$state = $DHC->isDeviceOn('My Wall Plug')['result'];
//Start a scene:
$_DHC->startScene('We go out');
?>