File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change 4
4
5
5
use MiIO \MiIO ;
6
6
use MiIO \Models \Device ;
7
+ use MiIO \Models \Response ;
8
+ use Socket \Raw \Factory ;
7
9
8
10
trait Light
9
11
{
@@ -14,7 +16,7 @@ trait Light
14
16
15
17
public function __construct ()
16
18
{
17
- $ this ->miIO = new MiIO ();
19
+ $ this ->miIO = new MiIO (new Factory () );
18
20
}
19
21
20
22
/**
@@ -88,13 +90,15 @@ public function setBrightness(Device $device, $value)
88
90
*/
89
91
public function getBrightnessAndRgb (Device $ device )
90
92
{
91
- $ response = $ this ->miIO ->send ($ device , 'get_prop ' , ['rgb ' ]);
93
+ $ this ->miIO ->send ($ device , 'get_prop ' , ['rgb ' ]);
92
94
93
- if (isset ($ response ['result ' ][0 ])) {
94
- return dechex ($ response ['result ' ][0 ]);
95
- }
95
+ return $ this ->miIO ->read ($ device )->done (function ($ response ) {
96
+ if ($ response instanceof Response) {
97
+ return dechex ($ response ->getResult ()[0 ]);
98
+ }
96
99
97
- return null ;
100
+ return null ;
101
+ });
98
102
}
99
103
100
104
/**
You can’t perform that action at this time.
0 commit comments