Automation api Endpoint

This commit is contained in:
Václav Španinger 2021-02-16 14:28:31 +01:00
parent 821c0926e8
commit 38b29a2a4a
2 changed files with 25 additions and 0 deletions

View File

@ -40,6 +40,9 @@ $router->post('/api/widgets/{widgetId}/run', 'WidgetApi@run');
$router->get('/api/widgets/{widgetId}/detail', 'WidgetApi@detail');
$router->get('/api/widgets/{widgetId}/detail/{period}', 'WidgetApi@detail');
$router->get('/api/automations', 'AutomationsApi@default');
//cron
$router->post('/cron/clean', 'CronApi@clean');

View File

@ -0,0 +1,22 @@
<?php
class AutomationsApi extends ApiController
{
public function default()
{
//$this->requireAuth();
$response = [];
$automationData = AutomationManager::getAll();
foreach ($automationData as $automationKey => $automation) {
$response[] = [
"automation_id" => $automation['automation_id'],
"name" => $automation['name'],
"enabled" => $automation['enabled'],
];
}
$this->response($response);
}
}