PHP_SMART_HOME_V3/app/api/AutomationsApi.php
2021-02-23 12:41:48 +01:00

35 lines
734 B
PHP

<?php
class AutomationsApi extends ApiController
{
public function default()
{
//$this->requireAuth();
$response = [];
$response = AutomationManager::getAll(["automation_id","name","enabled"]);
$this->response($response);
}
public function detail($automationId)
{
//$this->requireAuth();
$response = [];
$response = AutomationManager::getById($automationId, ["automation_id", "last_execution_time", "owner_id", "conditions", "tasks"]);
$this->response($response);
}
public function create()
{
$this->requireAuth();
$obj = $this->input;
$response = [];
$response = AutomationManager::create($obj['name'],$obj['days'], $obj['tasks'], $obj['conditions']);
$this->response(['value'=>'OK']);
}
}