diff --git a/app/class/AutomationManager.php b/app/class/AutomationManager.php
index a06581b..ae23625 100644
--- a/app/class/AutomationManager.php
+++ b/app/class/AutomationManager.php
@@ -77,9 +77,9 @@ class AutomationManager{
}
} else if ($onValue['type'] == 'outHome') {
-
+ //TODO: Add Ovner to automation
} else if ($onValue['type'] == 'inHome') {
-
+ //TODO: Add Ovner to automation
} else if ($onValue['type'] == 'noOneHome') {
$users = UserManager::getUsers();
$membersHome = 0;
@@ -120,14 +120,19 @@ class AutomationManager{
$subscribers = NotificationManager::getSubscription();
$i = 0;
- foreach ($subscribers as $key => $subscriber) {
- $logManager->write("[NOTIFICATION] SENDING NOTIFICATION TO" . $subscriber['id'] . " was executed" . $i);
- $title = 'Automatization '.$automation['name']." was just executed";
- $notification = new Notification(SERVERKEY);
- $notification->to($subscriber['token']);
- $notification->notification($title, '' , '', '');
- $notification->send();
- $notification = null;
+ $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) {
+ $logManager->write("[NOTIFICATION/AUTOOMATION] SENDING TO" . $subscriber['id'] . " ");
+ $notificationMng::sendSimpleNotification(SERVERKEY, $subscriber['token'], $notificationData);
+ }
}
$logManager->write("[AUTOMATIONS] automation id ". $automation['automation_id'] . " was executed");
diff --git a/app/class/NotificationManager.php b/app/class/NotificationManager.php
index d346589..6f2d683 100644
--- a/app/class/NotificationManager.php
+++ b/app/class/NotificationManager.php
@@ -2,6 +2,7 @@
/**
* Notification Manager
*/
+//TODO: Working timestamp to body or $title
class NotificationManager
{
function addSubscriber($userID = '', $token = ''){
@@ -19,7 +20,7 @@ class NotificationManager
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 = [
'title' => '',
'body' => '',
@@ -30,6 +31,10 @@ class NotificationManager
return;
}
+ if ($timeStamp) {
+ $data['title'] = $data['title'] . date();
+ }
+
$notification = new Notification($serverKey);
$notification->to($to);
$notification->notification($data['title'], $data['body'], $data['icon'], '');
@@ -64,8 +69,12 @@ class Notification
$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"]["body"] = $body;
$this->jsonPayload["data"]["notification"]["icon"] = $icon;
diff --git a/app/class/Utilities.php b/app/class/Utilities.php
index b45fef7..1beaf38 100644
--- a/app/class/Utilities.php
+++ b/app/class/Utilities.php
@@ -119,7 +119,7 @@ class Utilities
case '>=': // Greater than or equal to
return $value1 >= $value2;
case '==': // Equal
- return $value1 == $value2;
+ return ($value1 == $value2);
case '===': // Identical
return $value1 === $value2;
case '!==': // Not Identical
diff --git a/app/templates/part/deviceDetail.phtml b/app/templates/part/deviceDetail.phtml
index d0bcbe0..b143984 100644
--- a/app/templates/part/deviceDetail.phtml
+++ b/app/templates/part/deviceDetail.phtml
@@ -62,9 +62,6 @@
@@ -72,10 +69,12 @@
$value) { ?>
echo('t_time');?>
-
- echo('t_raw');?>
-
echo('t_state');?>