Periodical sync from dev FTP

This commit is contained in:
JonatanRek 2020-01-16 14:33:11 +01:00
parent 6f0fa2f81e
commit ad89a18093
6 changed files with 43 additions and 24 deletions

View File

@ -77,9 +77,9 @@ class AutomationManager{
} }
} else if ($onValue['type'] == 'outHome') { } else if ($onValue['type'] == 'outHome') {
//TODO: Add Ovner to automation
} else if ($onValue['type'] == 'inHome') { } else if ($onValue['type'] == 'inHome') {
//TODO: Add Ovner to automation
} else if ($onValue['type'] == 'noOneHome') { } else if ($onValue['type'] == 'noOneHome') {
$users = UserManager::getUsers(); $users = UserManager::getUsers();
$membersHome = 0; $membersHome = 0;
@ -120,14 +120,19 @@ class AutomationManager{
$subscribers = NotificationManager::getSubscription(); $subscribers = NotificationManager::getSubscription();
$i = 0; $i = 0;
$notificationMng = new NotificationManager;
$notificationData = [
'title' => 'Automatization',
'body' => 'Automatization '.$automation['name']." was just executed",
'icon' => BASEDIR . '/app/templates/images/icon-192x192.png',
];
if ($notificationData != []) {
$subscribers = $notificationMng::getSubscription();
foreach ($subscribers as $key => $subscriber) { foreach ($subscribers as $key => $subscriber) {
$logManager->write("[NOTIFICATION] SENDING NOTIFICATION TO" . $subscriber['id'] . " was executed" . $i); $logManager->write("[NOTIFICATION/AUTOOMATION] SENDING TO" . $subscriber['id'] . " ");
$title = 'Automatization '.$automation['name']." was just executed"; $notificationMng::sendSimpleNotification(SERVERKEY, $subscriber['token'], $notificationData);
$notification = new Notification(SERVERKEY); }
$notification->to($subscriber['token']);
$notification->notification($title, '' , '', '');
$notification->send();
$notification = null;
} }
$logManager->write("[AUTOMATIONS] automation id ". $automation['automation_id'] . " was executed"); $logManager->write("[AUTOMATIONS] automation id ". $automation['automation_id'] . " was executed");

View File

@ -2,6 +2,7 @@
/** /**
* Notification Manager * Notification Manager
*/ */
//TODO: Working timestamp to body or $title
class NotificationManager class NotificationManager
{ {
function addSubscriber($userID = '', $token = ''){ function addSubscriber($userID = '', $token = ''){
@ -19,7 +20,7 @@ class NotificationManager
return Db::loadAll('SELECT * FROM notifications;', array()); return Db::loadAll('SELECT * FROM notifications;', array());
} }
function sendSimpleNotification(string $serverKey, string $to, array $data){ function sendSimpleNotification(string $serverKey, string $to, array $data, bool $timeStamp = false){
$dataTemplate = [ $dataTemplate = [
'title' => '', 'title' => '',
'body' => '', 'body' => '',
@ -30,6 +31,10 @@ class NotificationManager
return; return;
} }
if ($timeStamp) {
$data['title'] = $data['title'] . date();
}
$notification = new Notification($serverKey); $notification = new Notification($serverKey);
$notification->to($to); $notification->to($to);
$notification->notification($data['title'], $data['body'], $data['icon'], ''); $notification->notification($data['title'], $data['body'], $data['icon'], '');
@ -64,8 +69,12 @@ class Notification
$this->jsonPayload["to"] = $to; $this->jsonPayload["to"] = $to;
} }
function notification($title = '', $body = '', $icon = '', $action = '') function notification($title = '', $body = '', $icon = '', $action = '', bool $timeStamp = false)
{ {
if ($timeStamp) {
$data['title'] = $data['title'] . date();
}
$this->jsonPayload["data"]["notification"]["title"] = $title; $this->jsonPayload["data"]["notification"]["title"] = $title;
$this->jsonPayload["data"]["notification"]["body"] = $body; $this->jsonPayload["data"]["notification"]["body"] = $body;
$this->jsonPayload["data"]["notification"]["icon"] = $icon; $this->jsonPayload["data"]["notification"]["icon"] = $icon;

View File

@ -119,7 +119,7 @@ class Utilities
case '>=': // Greater than or equal to case '>=': // Greater than or equal to
return $value1 >= $value2; return $value1 >= $value2;
case '==': // Equal case '==': // Equal
return $value1 == $value2; return ($value1 == $value2);
case '===': // Identical case '===': // Identical
return $value1 === $value2; return $value1 === $value2;
case '!==': // Not Identical case '!==': // Not Identical

View File

@ -62,9 +62,6 @@
<thead> <thead>
<tr> <tr>
<th><?php $LANGMNG->echo('t_time');?></th> <th><?php $LANGMNG->echo('t_time');?></th>
<?php if (DEBUGMOD) { ?>
<th><?php $LANGMNG->echo('t_raw');?></th>
<?php } ?>
<th><?php $LANGMNG->echo('t_state');?></th> <th><?php $LANGMNG->echo('t_state');?></th>
</tr> </tr>
</thead> </thead>
@ -72,10 +69,12 @@
<?php foreach ($SUBDEVICE['events'] as $key => $value) { ?> <?php foreach ($SUBDEVICE['events'] as $key => $value) { ?>
<tr> <tr>
<td><?php echo (new DateTime($value['time']))->format(DATEFORMAT); ?></td> <td><?php echo (new DateTime($value['time']))->format(DATEFORMAT); ?></td>
<?php if (DEBUGMOD) { ?> <td title="test"><?php
<td><?php echo $SUBDEVICE['eventsRaw'][$key]['value']; ?></td> echo $value['value'] . $SUBDEVICE['unit'];
<?php } ?> if (DEBUGMOD) {
<td title="test"><?php echo $value['value'] . $SUBDEVICE['unit'];?></td> echo ' (' . $SUBDEVICE['eventsRaw'][$key]['value'] . ')';
}
?></td>
<?php //TODO: P5IDAT TOOLTIP PRO RAW VALUE?> <?php //TODO: P5IDAT TOOLTIP PRO RAW VALUE?>
</tr> </tr>
<?php } ?> <?php } ?>

View File

@ -69,15 +69,21 @@
</div> </div>
<div class="field"> <div class="field">
<div class="label">IP:</div> <div class="label">IP:</div>
<input class="input" type="text" name="deviceToken" value="<?php echo $DEVICE['ip']; ?>" minlength="7" maxlength="15" size="15" pattern="^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$" disabled> <input class="input" type="text" name="deviceIp" value="<?php echo $DEVICE['ip']; ?>" minlength="7" maxlength="15" size="15" pattern="^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$" disabled>
</div> </div>
<div class="field"> <div class="field">
<div class="label">Subnet:</div> <div class="label">Subnet:</div>
<input class="input" type="text" name="deviceToken" value="<?php echo $DEVICE['subnet']; ?>" minlength="7" maxlength="15" size="15" pattern="^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$" disabled> <input class="input" type="text" name="deviceSubnet" value="<?php echo $DEVICE['subnet']; ?>" minlength="7" maxlength="15" size="15" pattern="^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$" disabled>
</div> </div>
<div class="field"> <div class="field">
<div class="label">Gateway:</div> <div class="label">Gateway:</div>
<input class="input" type="text" name="deviceToken" value="<?php echo $DEVICE['gateway']; ?>" minlength="7" maxlength="15" size="15" pattern="^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$" disabled> <input class="input" type="text" name="deviceGateway" value="<?php echo $DEVICE['gateway']; ?>" minlength="7" maxlength="15" size="15" pattern="^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$" disabled>
</div>
<?php //TODO: ADD DNS TO DB MAKE ALL NETWORK SETTING EDITABLE ?>
<div class="field">
<div class="label">DNS:</div>
<input class="input" type="text" name="deviceDns" value="<?php echo $DEVICE['dns']; ?>" minlength="7" maxlength="15" size="15" pattern="^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$" disabled>
</div> </div>
<?php if ($DEVICE['userIsAdmin']) { ?> <?php if ($DEVICE['userIsAdmin']) { ?>
<?php if (!in_array($SUBDEVICE['type'], ['on/off', 'door', 'water'])) { ?> <?php if (!in_array($SUBDEVICE['type'], ['on/off', 'door', 'water'])) { ?>

View File

@ -1,6 +1,6 @@
<div class="col-12 col-md-6 col-xl-4 square-wrap noselect"> <div class="col-12 col-md-6 col-xl-4 square-wrap noselect">
<div class="rectangle-2"> <div class="rectangle-2">
<div class="square-content double" id="scene-<?php echo $SCENEID ?>" onClick="ajaxPost('ajax',{scene_id:'<?php echo $SCENEID; ?>'}, this);" > <div class="square-content double" id="scene-<?php echo $SCENEID ?>" onClick="ajaxPost('ajax',{scene_id:'<?php echo $SCENEID; ?>',action:'execute'}, this);" >
<div class="row"> <div class="row">
<div class="col-1"> <div class="col-1">
<h5 class="fa noselect"> <h5 class="fa noselect">