Person at home detection

This commit is contained in:
JonatanRek 2020-01-17 08:12:40 +01:00
parent dd8743d33e
commit db3ab9dd95
3 changed files with 20 additions and 3 deletions

View File

@ -78,8 +78,20 @@ class AutomationManager{
} else if ($onValue['type'] == 'outHome') { } else if ($onValue['type'] == 'outHome') {
//TODO: Add Ovner to automation //TODO: Add Ovner to automation
$userHomeStatus = UserManager::getUserData('at_home', $onValue['value']);
if ($userHomeStatus == 'false' && $automation['executed'] == 0) {
$run = true;
} else if ($userHomeStatus == 'true' && $automation['executed'] == 1) {
$restart = true;
}
} else if ($onValue['type'] == 'inHome') { } else if ($onValue['type'] == 'inHome') {
//TODO: Add Ovner to automation //TODO: Add Ovner to automation
$userHomeStatus = UserManager::getUserData('at_home', $onValue['value']);
if ($userHomeStatus == 'true' && $automation['executed'] == 0) {
$run = true;
} else if ($userHomeStatus == 'false' && $automation['executed'] == 1) {
$restart = true;
}
} else if ($onValue['type'] == 'noOneHome') { } else if ($onValue['type'] == 'noOneHome') {
$users = UserManager::getUsers(); $users = UserManager::getUsers();
$membersHome = 0; $membersHome = 0;

View File

@ -21,9 +21,12 @@
'value'=> $subDeviceValue, 'value'=> $subDeviceValue,
]); ]);
echo htmlspecialchars($json); echo htmlspecialchars($json);
} } else {
else { if ($_POST['atSelector'] == "inHome" || $_POST['atSelector'] == "outHome") {
echo $USERMANAGER->getUserData('user_id');
} else {
echo $_POST['atSelector']; echo $_POST['atSelector'];
}
} ?>" required/> } ?>" required/>
<input type="hidden" name="atDays" value="<?php echo htmlspecialchars(($_POST['day'] != '' ? json_encode($_POST['day']) : '')); ?>" required/> <input type="hidden" name="atDays" value="<?php echo htmlspecialchars(($_POST['day'] != '' ? json_encode($_POST['day']) : '')); ?>" required/>
<?php foreach ($_POST['devices'] as $value) { ?> <?php foreach ($_POST['devices'] as $value) { ?>

View File

@ -54,6 +54,8 @@ class Automation extends Template
$template->prepare('baseDir', BASEDIR); $template->prepare('baseDir', BASEDIR);
$template->prepare('title', 'Automation'); $template->prepare('title', 'Automation');
$template->prepare('langMng', $langMng); $template->prepare('langMng', $langMng);
$template->prepare('userManager', $userManager);
$template->prepare('automations', $automations); $template->prepare('automations', $automations);
$template->prepare('subDevices', $approvedSubDevices); $template->prepare('subDevices', $approvedSubDevices);