Skip to content

Commit 1cdd381

Browse files
authored
Merge pull request #3 from strfl89/testing
Update to Version 2.1
2 parents 4306727 + 26faabb commit 1cdd381

File tree

6 files changed

+75
-6
lines changed

6 files changed

+75
-6
lines changed

README.md

+8-5
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,25 @@ This project is a set of PHP Classes working with [libcoap](https://github.com/o
77
* Remote Controls
88
* Motion Sensors
99
* Groups
10-
* Moods / Scenes
1110
* Querying the status of the items
1211
* On/Off
1312
* Brightness
1413
* Battery level
1514
* Names
1615
* Turning lights and groups on and off
17-
* Setting their brightness
18-
* Activating moods
16+
* Gateway Functions
17+
* Querying the Status informations
18+
* Reboot
1919
## Requirements
2020
* IKEA Trådfri Gateway
2121
* PHP7 (with minor adjustments older versions can also be used)
2222
* libcoap (only supports Linux unfortunately)
2323
## Installation
2424
1. Install coap-client with DTLS support. Preferrably, debug output from [tinydtls](https://projects.eclipse.org/projects/iot.tinydtls) should be disabled (otherwise adjustments in the scripts are required, see inside list.php for details on this). The script [install-coap-client.sh](https://github.com/ggravlingen/pytradfri/blob/master/script/install-coap-client.sh) from the [pytradfri](https://github.com/ggravlingen/pytradfri) repository automates this.
2525
2. Place the scripts in a web server directory accessible to web browsers. Ensure executing processes on the command line is allowed in your PHP installation.
26-
3. Provide a configuration file with IP address of the gateway, identity and key ("username and password") to use when communicating with the gateway.
2726
## Configuration
28-
Configure Tradfri Gateway IP, User, Key in general.php
27+
While creating an object in your code, you must provide the parameters for user, secretkey and IP Address
28+
Example:
29+
```
30+
$groups = new tradfrigroups("<user>", "<secret>", "<ip>");
31+
```

Release-Notes.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# phpTradfri - Version History
2+
## Version 2.1
3+
* Add Subclass for Trådfri Gateway
4+
* defines.php
5+
+ defines for gateway
6+
* general.php
7+
* extend function action() for Gateway Class (reboot command has no payload to transmit)
8+
* include.php
9+
+ add gateway.php for including gateway Sublcass
10+
* ReadMe
11+
+ Gateway functions
12+
* Release Notes
13+
* create Release Notes
14+
## Version 2.0 - 11th Sep 2019
15+
* general.php
16+
* Move from Constants to Parameters for Gateway Config
17+
* to initialize new object parameters User, Secret and Gateway IP must enterd. Example:
18+
```
19+
$groups = new tradfrigroups("<user>", "<secret>", "<ip>");
20+
```
21+
* cleaning up file
22+
* Update ReadMe File
23+
## Version 1.1 - 09th Sep 2019
24+
* devices
25+
+ Output of Firmware Version at statusremotecontrol()
26+
+ Add Motion Sensor to statusremotecontrol()
27+
## Version 1.0 - 30th Aug 2019
28+
* Initial Commit

defines.php

+5
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,10 @@
2121
define('TYPE_MOTION_SENSOR', 4); //5750 = 4 => Motion Sensor
2222
define('GATEWAY', 15011);
2323
define('GATEWAY_NTP', 9023);
24+
define('GATEWAY_FIRMWARE', 9029);
25+
define('GATEWAY_ALEXA_STATUS', 9093)
26+
define('GATEWAY_GOOGLE_STATUS', 9105);
27+
define('GATEWAY_TIME_UNIX', 9059);
28+
define('GATEWAY_SETUP_TIME', 9069)
2429

2530
?>

gateway.php

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
require_once('general.php');
4+
5+
class tradfrigateway extends tradfri
6+
{
7+
8+
function reboot(){
9+
10+
$this->action("post", "", "15011/9030");
11+
12+
// Response
13+
// v:1 t:CON c:POST i:3bb9 {} [ ]
14+
// decrypt_verify(): found 24 bytes cleartext
15+
// decrypt_verify(): found 4 bytes cleartext
16+
17+
}
18+
19+
function statusgateway(){
20+
21+
$details = $this->getDetails(GATEWAY."/15012");
22+
23+
$output = array('setup' => $details[GATEWAY_SETUP_TIME], 'ntp' => $details['GATEWAY_NTP'], 'time' => $details[GATEWAY_TIME_UNIX], 'firmware' => $details[GATEWAY_FIRMWARE], 'alexa' => $details[GATEWAY_ALEXA_STATUS], 'google' => $details[GATEWAY_GOOGLE_STATUS]);
24+
}
25+
26+
}
27+
28+
?>

general.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ function query($path){
3838
}
3939

4040
function action($method, $payload, $path){
41-
$cmd = "coap-client -m {$method} -u '{$this->gateway['user']}' -k '{$this->gateway['secretkey']}' -e '{$payload}' 'coaps://{$this->gateway['ip']}:5684/{$path}'";
41+
if($payload != "")
42+
$cmd = "coap-client -m {$method} -u '{$this->gateway['user']}' -k '{$this->gateway['secretkey']}' -e '{$payload}' 'coaps://{$this->gateway['ip']}:5684/{$path}'";
43+
else
44+
$cmd = "coap-client -m {$method} -u '{$this->gateway['user']}' -k '{$this->gateway['secretkey']}' 'coaps://{$this->gateway['ip']}:5684/{$path}'";
45+
4246
exec($cmd);
4347

4448
}

include.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
require_once('devices.php');
4+
require_once('gateway.php');
45
require_once('groups.php');
56

67
?>

0 commit comments

Comments
 (0)