mirror of
https://github.com/CyanoFresh/SmartHomePHP.git
synced 2026-02-20 03:11:26 +01:00
Fixes
This commit is contained in:
@@ -70,6 +70,43 @@ class ItemController extends Controller
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $item_id
|
||||
* @return array
|
||||
* @throws BadRequestHttpException
|
||||
* @throws NotSupportedException
|
||||
*/
|
||||
public function actionTurnOff($item_id)
|
||||
{
|
||||
$item = $this->findItem($item_id);
|
||||
|
||||
if ($item->type !== Item::TYPE_SWITCH) {
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
|
||||
$board = $item->board;
|
||||
|
||||
switch ($board->type) {
|
||||
case Board::TYPE_AREST:
|
||||
throw new NotSupportedException();
|
||||
break;
|
||||
case Board::TYPE_WEBSOCKET:
|
||||
$api = new WebSocketAPI(Yii::$app->user->identity);
|
||||
|
||||
if (!$api->turnOff($item_id)) {
|
||||
return [
|
||||
'success' => false,
|
||||
];
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return Item
|
||||
|
||||
@@ -7,7 +7,6 @@ use app\models\Task;
|
||||
use app\models\Trigger;
|
||||
use app\models\History;
|
||||
use app\models\Item;
|
||||
use app\models\TaskAction;
|
||||
use app\models\User;
|
||||
use Ratchet\ConnectionInterface;
|
||||
use Ratchet\MessageComponentInterface;
|
||||
|
||||
Reference in New Issue
Block a user