File tree Expand file tree Collapse file tree 3 files changed +44
-2
lines changed
Expand file tree Collapse file tree 3 files changed +44
-2
lines changed Original file line number Diff line number Diff line change 88 * @package Aqara\Models
99 *
1010 * @property string $status
11- * @property int $rotateDegrees
11+ * @property int $rotateDegrees
1212 */
1313class Cube extends Subdevice
1414{
15+ const STATUS_MOVE = 'move ' ;
16+ const STATUS_FLIP_90 = 'flip90 ' ;
17+ const STATUS_FLIP_180 = 'flip180 ' ;
18+ const STATUS_ROTATE = 'rotate ' ;
19+ const STATUS_SHAKE_AIR = 'shake_air ' ;
20+ const STATUS_TAP_TWICE = 'tap_twice ' ;
21+
1522 public function __construct (array $ attributes = [])
1623 {
1724 $ this ->type = 'cube ' ;
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ public function handleMessage($response)
7979 break ;
8080 case 'motion ' :
8181 case 'sensor_motion.aq2 ' :
82- // TODO: motion
82+ $ subDevice = new Motion ([ ' sid ' => $ response -> sid ]);
8383 break ;
8484 case 'sensor_ht ' :
8585 case 'weather.v1 ' :
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Aqara \Models ;
4+
5+ /**
6+ * Class Motion
7+ *
8+ * @package Aqara\Models
9+ *
10+ * @property string $status
11+ */
12+ class Motion extends Subdevice
13+ {
14+ const MOTION = 'motion ' ;
15+
16+ public function __construct (array $ attributes = [])
17+ {
18+ $ this ->type = 'motion ' ;
19+ parent ::__construct ($ attributes );
20+ }
21+
22+ /**
23+ * @param array $state
24+ */
25+ public function handleState ($ state )
26+ {
27+ if (!is_array ($ state )) {
28+ return ;
29+ }
30+
31+ $ this ->status = $ state ['status ' ] ?? null ;
32+
33+ $ this ->emit ('update ' );
34+ }
35+ }
You can’t perform that action at this time.
0 commit comments