Automations

This commit is contained in:
JonatanRek
2020-02-21 14:01:39 +01:00
parent edf0b1ceb4
commit d8c7a54446
5 changed files with 39 additions and 24 deletions

View File

@@ -55,7 +55,7 @@ class AutomationManager{
$run = false;
$restart = false;
if ($automation['active'] == 1 && $automation['locked'] != 1){
if ($automation['active'] == 1 && $automation['locked'] != 1){
Db::edit('automation', array('locked' => 1), 'WHERE automation_id = ?', array($automation['automation_id']));
if (in_array($dayNameNow, $actionDays)){
if (in_array($onValue['type'], ['sunSet', 'sunRise', 'time','now'])) {
@@ -118,6 +118,18 @@ class AutomationManager{
} else if ($membersHome > 0 && $automation['executed'] == 0){
$run = true;
}
} else if ($onValue['type'] == 'atDeviceValue') {
$subDeviceId = SubDeviceManager::getSubDeviceByMaster($onValue['value']['deviceID'], $onValue['value']['type'])["subdevice_id"];
$lastValue = RecordManager::getLastRecord($subDeviceId);
if ($lastValue['value'] == $onValue['value']['value'] && $automation['executed'] == 0) {
$run = true;
} else if ($lastValue['value'] != $onValue['value']['value'] && $automation['executed'] == 1){
$restart = true;
}
}
//finalization