Automation and api fixes
This commit is contained in:
@@ -41,7 +41,11 @@ class Ajax extends Template
|
||||
|
||||
} else if (isset($_POST['automation_id'])){
|
||||
$automationId = $_POST['automation_id'];
|
||||
AutomationManager::deactive($automationId);
|
||||
if (isset($_POST['action']) && $_POST['action'] == 'delete') {
|
||||
AutomationManager::remove($automationId);
|
||||
}else {
|
||||
AutomationManager::deactive($automationId);
|
||||
}
|
||||
} else if (isset($_POST['subDevice']) && isset($_POST['action']) && $_POST['action'] == "chart") {
|
||||
//TODO lepe rozstrukturovat
|
||||
$subDeviceId = $_POST['subDevice'];
|
||||
@@ -154,7 +158,11 @@ class Ajax extends Template
|
||||
die();
|
||||
} else if (isset($_POST['scene_id'])) {
|
||||
$sceneId = $_POST['scene_id'];
|
||||
echo SceneManager::execScene($sceneId);
|
||||
if (isset($_POST['action']) && $_POST['action'] == 'delete') {
|
||||
SceneManager::delete($sceneId);
|
||||
}else {
|
||||
echo SceneManager::execScene($sceneId);
|
||||
}
|
||||
}
|
||||
|
||||
die();
|
||||
|
@@ -19,11 +19,19 @@ class Automation extends Template
|
||||
$automations = [];
|
||||
$automationsData = AutomationManager::getAll();
|
||||
foreach ($automationsData as $automationKey => $automationData) {
|
||||
$doSomething = [];
|
||||
foreach (json_decode($automationData['do_something']) as $subdeviceId => $subDeviceState) {
|
||||
$subDeviceMasterDeviceData = SubDeviceManager::getSubDeviceMaster($subdeviceId);
|
||||
$doSomething[$subdeviceId] = [
|
||||
'name' => $subDeviceMasterDeviceData['name'],
|
||||
'state' => $subDeviceState,
|
||||
];
|
||||
}
|
||||
$automations[$automationData['automation_id']] = [
|
||||
'name' => '',
|
||||
'onDays' => implode(', ',json_decode($automationData['on_days'])),
|
||||
'onDays' => json_decode($automationData['on_days']),
|
||||
'ifSomething' => $automationData['if_something'],
|
||||
'doSomething' => $automationData['do_something'],
|
||||
'doSomething' => $doSomething,
|
||||
'active' => $automationData['active'],
|
||||
];
|
||||
}
|
||||
@@ -37,6 +45,7 @@ class Automation extends Template
|
||||
$approvedSubDevices[$subDeviceValue['subdevice_id']] = [
|
||||
'name' => $allDevicesData[$deviceKey]['name'],
|
||||
'type' => $subDeviceValue['type'],
|
||||
'masterDevice' => $subDeviceValue['device_id'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user