Automation and api fixes

This commit is contained in:
JonatanRek
2019-08-24 13:07:07 +02:00
parent 97e955d382
commit 1ea7e600c2
13 changed files with 152 additions and 54 deletions

View File

@@ -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'],
];
}
}