-
Notifications
You must be signed in to change notification settings - Fork 4
/
example2.php
45 lines (30 loc) · 1.03 KB
/
example2.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
<?php
declare(strict_types = 1);
require("../vendor/autoload.php");
use \JanKnipper\FritzboxAHA\FritzboxAHA;
$aha = new FritzboxAHA();
$aha->login("fritz.box", "", "password");
echo "Session id: " . $aha->getSid() . "\n\n";
$switches = $aha->getAllSwitches();
foreach ($switches as $switch) {
echo "Switch AIN: " . $switch . "\n";
echo "Switch name: " . $aha->getSwitchName($switch) . "\n";
echo "Switch is present: " . $aha->isSwitchPresent($switch) . "\n";
echo "Switch state: " . $aha->getSwitchState($switch) . "\n";
echo "Current power consumption: " . $aha->getSwitchPower($switch) . " mW\n";
echo "Total power consumption: " . $aha->getSwitchEnergy($switch) . " Wh\n";
echo "Turn on.\n";
$aha->setSwitchOn($switch);
sleep(2);
echo "Turn off.\n";
$aha->setSwitchOff($switch);
sleep(2);
echo "Toggle switch.\n\n";
$aha->setSwitchToggle($switch);
sleep(2);
}
$devs = $aha->getAllDevices();
foreach ($devs as $dev) {
$ain = $dev["aid"];
echo "AIN: " . $ain . "\n";
}