Skip to content

Commit

Permalink
Version 2.2
Browse files Browse the repository at this point in the history
Add Dimmer Functions for Devices
  • Loading branch information
strfl89 committed Sep 16, 2019
1 parent 564bf23 commit efb0f5b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 14 deletions.
12 changes: 7 additions & 5 deletions Release-Notes.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# phpTradfri - Version History
## Version 2.1.1
## Version 2.2 - 16th Sep 2019
+ getDimmer() and setDimmer() added to devices.php
## Version 2.1.1 - 14th Sep 2019
* Fix missing return in Function statusgateway()
## Version 2.1
## Version 2.1 - 14th Sep 2019
* Add Subclass for Trådfri Gateway
* defines.php
+ defines for gateway
Expand All @@ -17,9 +19,9 @@
* 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("<user>", "<secret>", "<ip>");
```
```
$groups = new tradfrigroups("<user>", "<secret>", "<ip>");
```
* cleaning up file
* Update ReadMe File
## Version 1.1 - 09th Sep 2019
Expand Down
33 changes: 31 additions & 2 deletions devices.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
class tradfridevices extends tradfri
{

function getDimmer($Id){

$dimid = $this->getDetails("15001/$Id");

return $dimid['3311']['0'][DIMMER];

}

function getIds(){

return explode(",", trim(str_replace(['[',']'], "" ,strstr($this->query("15001"), '[65'))));
Expand Down Expand Up @@ -58,7 +66,7 @@ function poweroff($path){
}

else
return "Gerät kann nicht ausgeschalet werden, da es keine Lampe ist";
return $this->getName("15001/$device")." konnte nicht ausgeschaltet werden, da es keine Lampe ist";

}

Expand All @@ -75,7 +83,28 @@ function poweron($path){
}

else
return "Gerät konnte nicht eingeschaltet werden, da es keine Lampe ist";
return $this->getName("15001/$device")." konnte nicht eingeschaltet werden, da es keine Lampe ist";

}

function setDimmer($path, $dimmer, $transition = NULL){

if($this->getTypeId($path) == TYPE_LIGHT){

$dim = round(254 * (int)str_replace("%", "", trim($dimmer)) / 100, 0);

$payload = is_null($transition) ? '{ "3311": [{ "5851" : '.$dim.' }] }" : "{ "3311": [{ "5851": '.$dim.', "5712": '.$transition.' }] }';
$this->action("put", $payload, "15001/$path");

if($this->getDimmer($path) == $dim)
return $this->getName("15001/$path")." wurde auf {$dimmer} gedimmt";
else
return $this->getName("15001/$path")." konnte nicht auf {$dimmer} gedimmt werden";

}

else
return $this->getName("15001/$device")." konnte nicht gedimmt werden, da es keine Lampe ist";

}

Expand Down
12 changes: 5 additions & 7 deletions general.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

require_once('defines.php');

class tradfri
{
class tradfri {

private $gateway;

function __construct($user, $secret, $gwip){

$this->gateway['user'] = $user;
$this->gateway['secretkey'] = $secret;
$this->gateway['ip'] = $gwip;
$this->gateway['user'] = $user;
$this->gateway['secretkey'] = $secret;
$this->gateway['ip'] = $gwip;

}

Expand Down Expand Up @@ -67,7 +66,6 @@ function getName($path){

}

}
//End of Class tradfri
} //End of Class tradfri

?>

0 comments on commit efb0f5b

Please sign in to comment.