|
@@ 92-103 (lines=12) @@
|
| 89 |
|
* @param float $duration (Optional) Fade to the given `state` over a duration of seconds. Defaults to `1.0`. |
| 90 |
|
* @return \Psr\Http\Message\StreamInterface |
| 91 |
|
*/ |
| 92 |
|
public function setLights($selector = 'all', $state = 'on', $duration = 1.0) |
| 93 |
|
{ |
| 94 |
|
$request = new Request('PUT', 'lights/' . $selector . '/power'); |
| 95 |
|
$response = $this->sendRequest($request,[ |
| 96 |
|
'query' => [ |
| 97 |
|
'state' => $state, |
| 98 |
|
'duration' => $duration |
| 99 |
|
] |
| 100 |
|
]); |
| 101 |
|
|
| 102 |
|
return $response->getBody(); |
| 103 |
|
} |
| 104 |
|
|
| 105 |
|
/** |
| 106 |
|
* Set lights to any color. |
|
@@ 114-126 (lines=13) @@
|
| 111 |
|
* @param bool $power_on (Optional) Whether to turn light on first. Defaults to `true`. |
| 112 |
|
* @return \Psr\Http\Message\StreamInterface |
| 113 |
|
*/ |
| 114 |
|
public function setColor($selector = 'all', $color = 'white', $duration = 1.0, $power_on = true) |
| 115 |
|
{ |
| 116 |
|
$request = new Request('PUT', 'lights/' . $selector . '/color'); |
| 117 |
|
$response = $this->sendRequest($request,[ |
| 118 |
|
'query' => [ |
| 119 |
|
'color' => $color, |
| 120 |
|
'duration' => $duration, |
| 121 |
|
'power_on' => $power_on, |
| 122 |
|
] |
| 123 |
|
]); |
| 124 |
|
|
| 125 |
|
return $response->getBody(); |
| 126 |
|
} |
| 127 |
|
|
| 128 |
|
/** |
| 129 |
|
* Performs a breathe effect by slowly fading between the given colors. |