@@ -24,8 +24,8 @@ public function getRgb(Device $device)
24
24
{
25
25
$ hexValue = $ this ->getRgbAndBrightness ($ device );
26
26
27
- if (strlen ($ hexValue ) == 8 ) {
28
- return substr ($ hexValue, 2 );
27
+ if (strlen ($ hexValue ) >= 7 ) {
28
+ return strrev ( substr (strrev ( $ hexValue), 0 , 6 ) );
29
29
}
30
30
31
31
return null ;
@@ -41,7 +41,7 @@ public function setRgb(Device $device, $value)
41
41
$ value = dechex ($ value );
42
42
}
43
43
44
- $ bright = $ this ->getBrightness ($ device );
44
+ $ bright = $ this ->getBrightness ($ device ) ?? ' 01 ' ;
45
45
46
46
$ this ->miIO ->send ($ device , 'set_rgb ' , [hexdec ($ bright . $ value )]);
47
47
}
@@ -54,8 +54,8 @@ public function getBrightness(Device $device)
54
54
{
55
55
$ hexValue = $ this ->getRgbAndBrightness ($ device );
56
56
57
- if (strlen ($ hexValue ) == 8 ) {
58
- return substr ($ hexValue, 0 , 2 );
57
+ if (strlen ($ hexValue ) >= 7 ) {
58
+ return strrev ( substr (strrev ( $ hexValue), 6 ) );
59
59
}
60
60
61
61
return null ;
@@ -71,7 +71,7 @@ public function setBrightness(Device $device, $value)
71
71
$ value = dechex ($ value );
72
72
}
73
73
74
- $ rgb = $ this ->getRgb ($ device );
74
+ $ rgb = $ this ->getRgb ($ device ) ?? ' ffffff ' ;
75
75
76
76
$ this ->miIO ->send ($ device , 'set_rgb ' , [hexdec ($ value . $ rgb )]);
77
77
}
@@ -80,7 +80,7 @@ public function setBrightness(Device $device, $value)
80
80
* @param Device $device
81
81
* @return string|null
82
82
*/
83
- public function getRgbAndBrightness (Device $ device )
83
+ public function getBrightnessAndRgb (Device $ device )
84
84
{
85
85
$ response = $ this ->miIO ->send ($ device , 'get_prop ' , ['rgb ' ]);
86
86
@@ -95,7 +95,7 @@ public function getRgbAndBrightness(Device $device)
95
95
* @param Device $device
96
96
* @param int|string $value
97
97
*/
98
- public function setRgbAndBrightness (Device $ device , $ value )
98
+ public function setBrightnessAndRgb (Device $ device , $ value )
99
99
{
100
100
if (preg_match ('/^[0-9a-f]{8}$/i ' , $ value ) !== false ) {
101
101
$ value = hexdec ($ value );
0 commit comments