diff --git a/README.md b/README.md index 032689d..e9f4353 100755 --- a/README.md +++ b/README.md @@ -7,15 +7,15 @@ This project is a set of PHP Classes working with [libcoap](https://github.com/o * Remote Controls * Motion Sensors * Groups - * Moods / Scenes * Querying the status of the items * On/Off * Brightness * Battery level * Names * Turning lights and groups on and off -* Setting their brightness -* Activating moods +* Gateway Functions + * Querying the Status informations + * Reboot ## Requirements * IKEA Trådfri Gateway * PHP7 (with minor adjustments older versions can also be used) @@ -23,6 +23,9 @@ This project is a set of PHP Classes working with [libcoap](https://github.com/o ## Installation 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. 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. -3. Provide a configuration file with IP address of the gateway, identity and key ("username and password") to use when communicating with the gateway. ## Configuration -Configure Tradfri Gateway IP, User, Key in general.php +While creating an object in your code, you must provide the parameters for user, secretkey and IP Address +Example: +``` +$groups = new tradfrigroups("", "", ""); +``` diff --git a/Release-Notes.md b/Release-Notes.md new file mode 100644 index 0000000..84c82bc --- /dev/null +++ b/Release-Notes.md @@ -0,0 +1,28 @@ +# phpTradfri - Version History +## Version 2.1 +* Add Subclass for Trådfri Gateway +* defines.php + + defines for gateway +* general.php + * extend function action() for Gateway Class (reboot command has no payload to transmit) +* include.php + + add gateway.php for including gateway Sublcass +* ReadMe + + Gateway functions +* Release Notes + * create Release Notes +## Version 2.0 - 11th Sep 2019 +* general.php + * Move from Constants to Parameters for Gateway Config + * to initialize new object parameters User, Secret and Gateway IP must enterd. Example: +``` +$groups = new tradfrigroups("", "", ""); +``` + * cleaning up file +* Update ReadMe File +## Version 1.1 - 09th Sep 2019 +* devices + + Output of Firmware Version at statusremotecontrol() + + Add Motion Sensor to statusremotecontrol() +## Version 1.0 - 30th Aug 2019 +* Initial Commit \ No newline at end of file diff --git a/defines.php b/defines.php index 4c2813c..2911327 100755 --- a/defines.php +++ b/defines.php @@ -21,5 +21,10 @@ define('TYPE_MOTION_SENSOR', 4); //5750 = 4 => Motion Sensor define('GATEWAY', 15011); define('GATEWAY_NTP', 9023); +define('GATEWAY_FIRMWARE', 9029); +define('GATEWAY_ALEXA_STATUS', 9093) +define('GATEWAY_GOOGLE_STATUS', 9105); +define('GATEWAY_TIME_UNIX', 9059); +define('GATEWAY_SETUP_TIME', 9069) ?> diff --git a/gateway.php b/gateway.php new file mode 100644 index 0000000..5bcf22e --- /dev/null +++ b/gateway.php @@ -0,0 +1,28 @@ +action("post", "", "15011/9030"); + + // Response + // v:1 t:CON c:POST i:3bb9 {} [ ] + // decrypt_verify(): found 24 bytes cleartext + // decrypt_verify(): found 4 bytes cleartext + + } + + function statusgateway(){ + + $details = $this->getDetails(GATEWAY."/15012"); + + $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]); + } + + } + +?> \ No newline at end of file diff --git a/general.php b/general.php index 7982b1e..323a843 100644 --- a/general.php +++ b/general.php @@ -38,7 +38,11 @@ function query($path){ } function action($method, $payload, $path){ - $cmd = "coap-client -m {$method} -u '{$this->gateway['user']}' -k '{$this->gateway['secretkey']}' -e '{$payload}' 'coaps://{$this->gateway['ip']}:5684/{$path}'"; + if($payload != "") + $cmd = "coap-client -m {$method} -u '{$this->gateway['user']}' -k '{$this->gateway['secretkey']}' -e '{$payload}' 'coaps://{$this->gateway['ip']}:5684/{$path}'"; + else + $cmd = "coap-client -m {$method} -u '{$this->gateway['user']}' -k '{$this->gateway['secretkey']}' 'coaps://{$this->gateway['ip']}:5684/{$path}'"; + exec($cmd); } diff --git a/include.php b/include.php index 9f0f04f..371c45a 100644 --- a/include.php +++ b/include.php @@ -1,6 +1,7 @@