Skip to content

Commit e6380d8

Browse files
authored
Merge pull request #1 from ggottwald/b1acn01_switch
ADD switch
2 parents 794b7bf + 3898292 commit e6380d8

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

src/Models/Gateway.php

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
*
1111
* @package Aqara\Models
1212
*
13-
* @property string $ip
14-
* @property int $port
15-
* @property bool $ready
16-
* @property string $rgb
17-
* @property string $brightness
13+
* @property string $ip
14+
* @property int $port
15+
* @property bool $ready
16+
* @property string $rgb
17+
* @property string $brightness
1818
* @property Subdevice[] $subDevices
19-
* @property \Closure $sendUnicast
19+
* @property \Closure $sendUnicast
2020
*
2121
* @method sendUnicast(string $payload)
2222
*/
@@ -73,7 +73,7 @@ public function handleMessage($response)
7373
case 'sensor_magnet.aq2':
7474
$subDevice = new Magnet(
7575
[
76-
'sid' => $response->sid,
76+
'sid' => $response->sid,
7777
'model' => $response->model,
7878
]
7979
);
@@ -82,11 +82,12 @@ public function handleMessage($response)
8282
case 'sensor_switch.aq2':
8383
case '86sw1':
8484
case '86sw2':
85+
case 'remote.b1acn01';
8586
case 'remote.b186acn01':
8687
case 'remote.b286acn01':
8788
$subDevice = new SwitchDevice(
8889
[
89-
'sid' => $response->sid,
90+
'sid' => $response->sid,
9091
'model' => $response->model,
9192
]
9293
);
@@ -95,7 +96,7 @@ public function handleMessage($response)
9596
case 'sensor_motion.aq2':
9697
$subDevice = new Motion(
9798
[
98-
'sid' => $response->sid,
99+
'sid' => $response->sid,
99100
'model' => $response->model,
100101
]
101102
);
@@ -104,39 +105,39 @@ public function handleMessage($response)
104105
case 'weather.v1':
105106
$subDevice = new Sensor(
106107
[
107-
'sid' => $response->sid,
108+
'sid' => $response->sid,
108109
'model' => $response->model,
109110
]
110111
);
111112
break;
112113
case 'sensor_wleak.aq1':
113114
$subDevice = new Leak(
114115
[
115-
'sid' => $response->sid,
116+
'sid' => $response->sid,
116117
'model' => $response->model,
117118
]
118119
);
119120
break;
120121
case 'cube':
121122
$subDevice = new Cube(
122123
[
123-
'sid' => $response->sid,
124+
'sid' => $response->sid,
124125
'model' => $response->model,
125126
]
126127
);
127128
break;
128129
case 'smoke':
129130
$subDevice = new Smoke(
130131
[
131-
'sid' => $response->sid,
132+
'sid' => $response->sid,
132133
'model' => $response->model,
133134
]
134135
);
135136
break;
136137
default:
137138
$subDevice = new Class(
138139
[
139-
'sid' => $response->sid,
140+
'sid' => $response->sid,
140141
'model' => $response->model,
141142
]
142143
) extends Subdevice
@@ -151,9 +152,9 @@ public function __construct(array $attributes = [])
151152

152153
if (isset($subDevice)) {
153154
$subDevice->handleState($state);
154-
$subDevices = $this->subDevices;
155+
$subDevices = $this->subDevices;
155156
$subDevices[$response->sid] = $subDevice;
156-
$this->subDevices = $subDevices;
157+
$this->subDevices = $subDevices;
157158
$this->emit('subdevice', [$subDevice]);
158159
}
159160
}
@@ -196,7 +197,7 @@ protected function handleState($state)
196197

197198
if (strlen($hexValue) >= 7) {
198199
$this->brightness = strrev(substr(strrev($hexValue), 6));
199-
$this->rgb = strrev(substr(strrev($hexValue), 0, 6));
200+
$this->rgb = strrev(substr(strrev($hexValue), 0, 6));
200201
$this->emit('lightState', ['rgb' => $this->rgb, 'brightness' => $this->brightness]);
201202
}
202203
}

0 commit comments

Comments
 (0)