diff --git a/.github/workflows/translations.yml b/.github/workflows/translations.yml
new file mode 100644
index 00000000..fe9a14ca
--- /dev/null
+++ b/.github/workflows/translations.yml
@@ -0,0 +1,18 @@
+name: translate
+
+on:
+ workflow_dispatch:
+ push:
+ branches:
+ - beta
+
+jobs:
+ auto-translate:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: jeedom/jeetranslate@main
+ with:
+ deepl_api_key: ${{ secrets.DEEPL_API_KEY }}
+ include_empty_translation: false
+ target_languages: "en_US,es_ES,de_DE,it_IT,pt_PT"
+ use_core_translations: true
diff --git a/core/ajax/mobile.ajax.php b/core/ajax/mobile.ajax.php
index 08459a87..535bbbfb 100755
--- a/core/ajax/mobile.ajax.php
+++ b/core/ajax/mobile.ajax.php
@@ -60,6 +60,57 @@
ajax::success($return);
}
+ if (init('action') == 'getNotificationsV2') {
+ $return = '';
+ $iq = init('iq');
+ $mobile = eqLogic::byLogicalId($iq, 'mobile');
+ if (is_object($mobile)) {
+ $return = mobile::getNotificationsV2($iq);
+ }
+ ajax::success($return);
+ }
+
+ if (init('action') == 'removeNotificationV2') {
+ ajax::success(mobile::removeNotificationV2(init('iq', ''), init('id', '')));
+ }
+
+ // APP V1
+
+ if (init('action') == 'AppV1Savescenario') {
+ $id = init('id');
+ $sendApp = init('valueSend');
+ $scenario = scenario::byId($id);
+ if (!is_object($scenario)) {
+ throw new Exception(__('scenario non trouvé', __FILE__));
+ }
+ $scenario->setDisplay("sendToApp", $sendApp);
+ $scenario->save();
+ ajax::success();
+ }
+ if (init('action') == 'AppV1RegenConfig') {
+ mobile::makeTemplateJson();
+ ajax::success();
+ }
+ if (init('action') == 'AppV2GetSaveFavDash') {
+ $iq = init('iq');
+ $jsonFavDash = mobile::getSaveJson($iq, 'favdash');
+ if ($jsonFavDash == "") {
+ $reponse = false;
+ } else {
+ $reponse = true;
+ }
+ ajax::success($reponse);
+ }
+ if (init('action') == 'AppV2GetSaveDashboard') {
+ $iq = init('iq');
+ $jsonDashboard = mobile::getSaveJson($iq, 'dashboard');
+ if ($jsonDashboard == "") {
+ $reponse = false;
+ } else {
+ $reponse = true;
+ }
+ ajax::success($reponse);
+ }
throw new Exception(__('Aucune methode correspondante à : ', __FILE__) . init('action'));
} catch (Exception $e) {
ajax::error(displayException($e), $e->getCode());
diff --git a/core/api/mobile.api.php b/core/api/mobile.api.php
index ee0736b3..a185608b 100755
--- a/core/api/mobile.api.php
+++ b/core/api/mobile.api.php
@@ -26,31 +26,32 @@
}
$params = $jsonrpc->getParams();
-log::add('mobile', 'debug', '┌──────────▶︎ :fg-warning: Appel API Mobile :/fg: ◀︎───────────');
-log::add('mobile', 'debug', '| Method > ' . $jsonrpc->getMethod());
+log::add('mobile', 'debug', '┌──────────▶︎:fg-warning: Call API :/fg:◀︎─────────────');
+log::add('mobile', 'debug', '| Method ─▶︎ ' . $jsonrpc->getMethod());
$secureApikeyLog = $params;
if (isset($secureApikeyLog['apikey'])) $secureApikeyLog['apikey'] = substr($secureApikeyLog['apikey'], 0, 10) . '...';
-log::add('mobile', 'debug', '| Paramètres passés > ' . json_encode($secureApikeyLog));
+log::add('mobile', 'debug', '| Parameters ─▶︎ ' . json_encode($secureApikeyLog));
if ($params['Iq']) {
- if (mobile::whoIsIq($params['Iq']) == 'mobile non detecte') {
- //createMobile($params, 3);
- log::add('mobile', 'debug', '| [WARNING] mobile non detecté !');
+ if (mobile::whoIsIq($params['Iq']) == 'Mobile not detected') {
+ log::add('mobile', 'debug', '| [WARNING] Mobile not detected !');
} else {
- log::add('mobile', 'debug', '| Mobile demandeur > ' . mobile::whoIsIq($params['Iq']));
+ log::add('mobile', 'debug', '| Mobile : ' . mobile::whoIsIq($params['Iq']));
}
} else {
- log::add('mobile', 'debug', '| [WARNING] Paramètre Iq inexistant !');
+ log::add('mobile', 'debug', '| [WARNING] Parameter Iq does not exist !');
}
log::add('mobile', 'debug', '└───────────────────────────────────────────');
+// APP V2 //
/**
* Create a new equipment
* Call by api setConfigs
* @param array
* @return new object
*/
-function createMobile($params, $nbIcones = 3)
+function createMobileV2($params, $nbIcones = 3)
{
+ log::add('mobile', 'debug', '|┌──:fg-success: createMobileV2 :/fg:──');
$configs = $params['configs'];
$notification = $configs['notification'];
$user = user::byHash($params['apikey']);
@@ -58,10 +59,9 @@ function createMobile($params, $nbIcones = 3)
$mobile = new mobile();
$mobile->setEqType_name('mobile');
$mobile->setName($notification['platform'] . '-' . $params['Iq']);
- log::add('mobile', 'debug', ' ---- CREATE_NEW_MOBILE WITH ' . $nbIcones . ' ICONS ----');
+ log::add('mobile', 'debug', '|| [NOTICE] Create new mobile with ' . $nbIcones . ' icons ----');
$mobile->setConfiguration('menuCustomArray', mobile::getMenuDefaultV2($nbIcones));
$mobile->setConfiguration('nbIcones', intval($nbIcones));
- //$mobile->setConfiguration('defaultIdMobile', 'default'); moved to postInsert
$mobile->setConfiguration('type_mobile', $notification['platform']);
$mobile->setConfiguration('affect_user', $userId);
$mobile->setConfiguration('validate', 'no');
@@ -69,6 +69,7 @@ function createMobile($params, $nbIcones = 3)
$mobile->setLogicalId($params['Iq']);
$mobile->setIsEnable(1);
$mobile->save();
+ log::add('mobile', 'debug', '|└───────────────────');
return $mobile;
}
@@ -79,7 +80,7 @@ function createMobile($params, $nbIcones = 3)
*/
function saveMenuFromAppV2($menu, $mobile)
{
- log::add('mobile', 'debug', '||┌── :fg-success:saveMenuFromAppV2:/fg: ──');
+ log::add('mobile', 'debug', '||┌──:fg-success: saveMenuFromAppV2 :/fg:──');
log::add('mobile', 'debug', '||| [INFO] Menu > ' . json_encode($menu));
if (is_object($mobile)) {
$menuCustomArray = [];
@@ -122,60 +123,62 @@ function saveMenuFromAppV2($menu, $mobile)
* @return string ok makeSuccess
*/
if ($jsonrpc->getMethod() == 'setConfigs') {
- log::add('mobile', 'debug', '┌─────▶︎ AppV2 setConfigs ─────────────────');
+ log::add('mobile', 'debug', '┌──────────▶︎ setConfigs ──────────────');
$configs = $params['configs'];
$geolocs = $params['geolocs'];
$menu = $configs['menu'];
$notification = $configs['notification'];
- log::add('mobile', 'debug', '| [INFO] Configs > ' . json_encode($configs));
- log::add('mobile', 'debug', '| [INFO] Geolocs > ' . json_encode($geolocs));
- //log::add('mobile', 'debug', '| [INFO] Menu > ' . json_encode($menu));
- log::add('mobile', 'debug', '| [INFO] Notification > ' . json_encode($notification));
+ log::add('mobile', 'debug', '| [INFO] Configs ─▶︎ ' . json_encode($configs));
+ log::add('mobile', 'debug', '| [INFO] Geolocs ─▶︎ ' . json_encode($geolocs));
+ //log::add('mobile', 'debug', '| [INFO] Menu ─▶︎ ' . json_encode($menu));
+ log::add('mobile', 'debug', '| [INFO] Notification ─▶︎ ' . json_encode($notification));
$mobile = null;
if (isset($params['Iq'])) {
$mobile = eqLogic::byLogicalId($params['Iq'], 'mobile');
+ if (!is_object($mobile)) {
+ $mobile = createMobileV2($params, 3);
+ }
}
- if (!is_object($mobile)) {
- $mobile = createMobile($params,3);
- }
- $mobile->setConfiguration('type_mobile', $notification['platform']);
- if (isset($notification['token'])) {
- if ($notification['token'] != '') {
- log::add('mobile', 'debug', '| Token à ajouter > ' . $notification['token']);
- $mobile->setConfiguration('notificationRegistrationToken', $notification['token']);
- if ($notification['token'] == 'notifsBGDisabled') {
- message::removeAll("mobile", 'alertNotifs');
- message::add('mobile', 'Les notifications sur votre mobile : ' . $mobile->getName() . ' sont desactivées', 'notifsbg', 'alertNotifs');
+ if (is_object($mobile)) {
+ $mobile->setConfiguration('type_mobile', $notification['platform']);
+ if (isset($notification['token'])) {
+ if ($notification['token'] != '') {
+ log::add('mobile', 'debug', '| Token to add ─▶︎ ' . $notification['token']);
+ $mobile->setConfiguration('notificationRegistrationToken', $notification['token']);
+ if ($notification['token'] == 'notifsBGDisabled') {
+ message::removeAll("mobile", 'alertNotifs');
+ message::add('mobile', __('Les notifications sur votre mobile sont desactivées', __FILE__) . ' ─▶︎ ' . $mobile->getName(), 'notifsbg', 'alertNotifs');
+ }
+ } else {
+ log::add('mobile', 'debug', '| [NOTICE] Empty token');
}
- } else {
- log::add('mobile', 'debug', '| [NOTICE] Token vide ');
}
- }
- if (isset($notification['notifsTime'])) {
- $notifsTime = intval($notification['notifsTime']);
- if ($mobile->getConfiguration('notifsTime', 30) != $notifsTime) {
- $mobile->setConfiguration('notifsTime', $notifsTime);
- log::add('mobile', 'debug', '| [INFO] New notifsTime > ' . intval($notification['notifsTime']));
- $mobile->cleaningNotifications();
+ if (isset($notification['notifsTime'])) {
+ $notifsTime = intval($notification['notifsTime']);
+ if ($mobile->getConfiguration('notifsTime', 30) != $notifsTime) {
+ $mobile->setConfiguration('notifsTime', $notifsTime);
+ log::add('mobile', 'debug', '| [INFO] New notifsTime ─▶︎ ' . intval($notification['notifsTime']));
+ $mobile->cleaningNotifications();
+ }
}
- }
- if (is_object($user = user::byHash($params['apikey']))) {
- log::add('mobile', 'debug', '| [INFO] affect_user > ' . $user->getLogin() . ' (' . $user->getId() . ')');
- $mobile->setConfiguration('affect_user', $user->getId());
- }
- $mobile->save();
+ if (is_object($user = user::byHash($params['apikey']))) {
+ log::add('mobile', 'debug', '| [INFO] affect_user ─▶︎ ' . $user->getLogin() . ' (' . $user->getId() . ')');
+ $mobile->setConfiguration('affect_user', $user->getId());
+ }
+ $mobile->save();
- if ($geolocs) {
- if ($geolocs != [] && !(is_object($geolocs) && empty((array)$geolocs)) && !(is_string($geolocs) && $geolocs == "{}")) {
- mobile::createCmdGeoLocV2($params['Iq'], $params['geolocs']);
- } else {
- log::add('mobile', 'debug', '| Geolocs vide, suppression des commandes précédentes');
- $mobile = eqLogic::byLogicalId($params['Iq'], 'mobile');
- if (is_object($mobile)) {
- $cmds = $mobile->getCmd();
- foreach ($cmds as $cmd) {
- if (strpos($cmd->getLogicalId(), 'geoloc_') !== false) {
- $cmd->remove();
+ if ($geolocs) {
+ if ($geolocs != [] && !(is_object($geolocs) && empty((array)$geolocs)) && !(is_string($geolocs) && $geolocs == "{}")) {
+ mobile::createCmdGeoLocV2($params['Iq'], $params['geolocs']);
+ } else {
+ log::add('mobile', 'debug', '| Geolocs empty, previous commands deleted');
+ $mobile = eqLogic::byLogicalId($params['Iq'], 'mobile');
+ if (is_object($mobile)) {
+ $cmds = $mobile->getCmd();
+ foreach ($cmds as $cmd) {
+ if (strpos($cmd->getLogicalId(), 'geoloc_') !== false) {
+ $cmd->remove();
+ }
}
}
}
@@ -191,16 +194,18 @@ function saveMenuFromAppV2($menu, $mobile)
* @return string ok makeSuccess
*/
if ($jsonrpc->getMethod() == 'setCustomMenu') {
- log::add('mobile', 'debug', '┌─────▶︎ AppV2 setCustomMenu ─────────────────');
+ log::add('mobile', 'debug', '┌──────────▶︎ AppV2 setCustomMenu ───────────');
$configs = $params['configs'];
$menu = $configs['menu'];
- log::add('mobile', 'debug', '| [INFO] Configs > ' . json_encode($configs));
- log::add('mobile', 'debug', '| [INFO] Menu > ' . json_encode($menu));
+ log::add('mobile', 'debug', '| [INFO] Configs ─▶︎ ' . json_encode($configs));
+ log::add('mobile', 'debug', '| [INFO] Menu ─▶︎ ' . json_encode($menu));
$mobile = null;
- if (isset($params['Iq']) && is_object($mobile = eqLogic::byLogicalId($params['Iq'], 'mobile'))) {
- saveMenuFromAppV2($menu, $mobile);
- } else {
- log::add('mobile', 'debug', '| [WARNING] Paramètre Iq manquant ou équipement inexistant !');
+ if (isset($params['Iq'])) {
+ if (is_object($mobile = eqLogic::byLogicalId($params['Iq'], 'mobile'))) {
+ saveMenuFromAppV2($menu, $mobile);
+ } else {
+ log::add('mobile', 'debug', '| [WARNING] A required parameter Iq does not exist !');
+ }
}
log::add('mobile', 'debug', '└───────────────────────────────────────────');
$jsonrpc->makeSuccess('ok');
@@ -213,7 +218,7 @@ function saveMenuFromAppV2($menu, $mobile)
* @return array makeSuccess
*/
if ($jsonrpc->getMethod() == 'getPlugins') {
- log::add('mobile', 'debug', '┌─────◀︎ AppV2 getPlugins Infos ────────────────────');
+ log::add('mobile', 'debug', '┌──────────◀︎ AppV2 getPlugins ────────');
$idBox = jeedom::getHardwareKey();
$return = [];
$arrayPlugins = [];
@@ -254,7 +259,7 @@ function saveMenuFromAppV2($menu, $mobile)
$return[$idBox]['informations']['plugins'] = $arrayPlugins;
$return[$idBox]['informations']['changelog'] = $changeLogs;
$return[$idBox]['informations']['infosDemon'] = $deamons_infos;
- log::add('mobile', 'debug', '| [INFO] Retour vers App > ' . json_encode($return));
+ log::add('mobile', 'debug', '| [INFO] Sent to app ─▶︎ ' . json_encode($return));
log::add('mobile', 'debug', '└───────────────────────────────────────────');
$jsonrpc->makeSuccess($return);
}
@@ -266,7 +271,7 @@ function saveMenuFromAppV2($menu, $mobile)
*/
if ($jsonrpc->getMethod() == 'getJson') {
- log::add('mobile', 'debug', '┌─────◀︎ AppV2 getJson ────────────────────');
+ log::add('mobile', 'debug', '┌──────────◀︎ AppV2 getJson ──────────────────');
$registerDevice = $_USER_GLOBAL->getOptions('registerDevice', array());
if (!is_array($registerDevice)) {
$registerDevice = array();
@@ -278,7 +283,7 @@ function saveMenuFromAppV2($menu, $mobile)
$registerDevice[sha512($rdk)]['session_id'] = session_id();
$_USER_GLOBAL->setOptions('registerDevice', $registerDevice);
$_USER_GLOBAL->save();
- log::add('mobile', 'debug', '| RDK :' . $rdk);
+ log::add('mobile', 'debug', '| RDK ─▶︎ ' . $rdk);
$idBox = jeedom::getHardwareKey();
$return = array();
/* -------- MOBILE FIRST ------- */
@@ -335,25 +340,23 @@ function saveMenuFromAppV2($menu, $mobile)
$return[$idBox]['jeedom_version'] = jeedom::version();
$return[$idBox]['rdk'] = $rdk;
$return[$idBox]['name'] = config::byKey('name') == '' ? 'Jeedom' : config::byKey('name');
- log::add('mobile', 'debug', '| [INFO] Retour de base > ' . json_encode($return));
- log::add('mobile', 'debug', '| Recherche du mobile via sont Iq > ' . $params['Iq']);
- $mobile = eqLogic::byLogicalId($params['Iq'], 'mobile');
$return[$idBox]['configs'] = array();
$return[$idBox]['miscellanousParams'] = array();
- if (is_object($mobile)) {
- log::add('mobile', 'debug', '| OK Mobile trouvé > ' . $mobile->getName());
+ if (is_object($mobile = eqLogic::byLogicalId($params['Iq'], 'mobile'))) {
+ log::add('mobile', 'debug', '| OK Mobile found ─▶︎ ' . $mobile->getName());
$return[$idBox]['configs']['menu'] = $mobile->configMenuCustom();
$return[$idBox]['miscellanousParams']['hideMenuCustom'] = intval($mobile->getConfiguration('hideMenuCustom', 0));
$return[$idBox]['miscellanousParams']['hideMenuGeoloc'] = intval($mobile->getConfiguration('hideMenuGeoloc', 0));
$return[$idBox]['miscellanousParams']['sendNFCDirectly'] = intval($mobile->getConfiguration('sendNFCDirectly', 1));
} else {
+ log::add('mobile', 'debug', '| [WARNING] Mobile not found.');
$return[$idBox]['configs']['menu'] = mobile::getMenuDefaultTab();
$return[$idBox]['miscellanousParams']['hideMenuCustom'] = 0;
$return[$idBox]['miscellanousParams']['hideMenuGeoloc'] = 0;
$return[$idBox]['miscellanousParams']['sendNFCDirectly'] = 1;
}
- log::add('mobile', 'debug', '| [INFO] CustomENVOICONFIGSAPI GETJSON > ' . json_encode($return[$idBox]['configs']));
- log::add('mobile', 'debug', '| [INFO] Retour vers App > ' . json_encode($return));
+ log::add('mobile', 'debug', '| [INFO] Menu custom ─▶︎ ' . json_encode($return[$idBox]['configs']));
+ log::add('mobile', 'debug', '| [INFO] Sent to app ─▶︎ ' . json_encode($return));
log::add('mobile', 'debug', '└───────────────────────────────────────────');
$jsonrpc->makeSuccess($return);
@@ -365,44 +368,32 @@ function saveMenuFromAppV2($menu, $mobile)
* @return array makeSuccess
*/
if ($jsonrpc->getMethod() == 'getCustomMenu') {
- log::add('mobile', 'debug', '┌─────◀︎ AppV2 getCustomMenu ────────────────────');
- log::add('mobile', 'debug', '| Recherche du mobile via sont Iq > ' . $params['Iq']);
- $mobile = eqLogic::byLogicalId($params['Iq'], 'mobile');
- if (is_object($mobile)) {
- log::add('mobile', 'debug', '| OK Mobile trouvé > ' . $mobile->getName());
+ log::add('mobile', 'debug', '┌──────────◀︎ AppV2 getCustomMenu ───────────');
+ if (is_object($mobile = eqLogic::byLogicalId($params['Iq'], 'mobile'))) {
+ log::add('mobile', 'debug', '| OK Mobile found ─▶︎ ' . $mobile->getName());
$menu = $mobile->configMenuCustom();
} else {
+ log::add('mobile', 'debug', '| [WARNING] Mobile not found.');
$menu = mobile::getMenuDefaultTab();
}
- log::add('mobile', 'debug', '| [INFO] Retour vers App > ' . json_encode($menu));
+ log::add('mobile', 'debug', '| [INFO] Sent to app ─▶︎ ' . json_encode($menu));
log::add('mobile', 'debug', '└───────────────────────────────────────────');
$jsonrpc->makeSuccess($menu);
}
-/**
- * delete message jeedom by id
- *
- * @return bool makeSuccess
- */
-if ($jsonrpc->getMethod() == 'deleteMessage') {
- $message = message::byId($params['appInfos']['idmessage']);
- if (is_object($message)) {
- $message->remove();
- $jsonrpc->makeSuccess("true");
- }
- $jsonrpc->makeSuccess("false");
-}
-
/**
* delete message jeedom by type
*
* @return bool makeSuccess
*/
if ($jsonrpc->getMethod() == 'deleteAllMessageByType') {
+ log::add('mobile', 'debug', '┌──────────▶︎ AppV2 deleteAllMessageByType ───────────');
+ $return = "false";
if (isset($params['appInfos']['messageType'])) {
+ log::add('mobile', 'debug', '| deleting of all messages of the type "' . $params['appInfos']['messageType'] . '"');
if ($params['appInfos']['messageType'] == 'jeedom') {
message::removeAll('jeedom');
- $jsonrpc->makeSuccess("true");
+ $return = "true";
} elseif ($params['appInfos']['messageType'] == 'plugins') {
$messages = message::all();
foreach ($messages as $message) {
@@ -410,15 +401,13 @@ function saveMenuFromAppV2($menu, $mobile)
if ($message->getPlugin() != 'jeedom') {
$message->remove();
}
- } else {
- $jsonrpc->makeSuccess("false");
}
}
- $jsonrpc->makeSuccess("true");
+ $return = "true";
}
- } else {
- $jsonrpc->makeSuccess("false");
- }
+ } else log::add('mobile', 'debug', '| A required parameter "messageType" does not exist !');
+ log::add('mobile', 'debug', '└───────────────────────────────────────────');
+ $jsonrpc->makeSuccess($return);
}
/* V1 ?
@@ -449,32 +438,28 @@ function saveMenuFromAppV2($menu, $mobile)
* @return makeSuccess
*/
if ($jsonrpc->getMethod() == 'askText') {
- log::add('mobile', 'debug', '┌─────▶︎ ASK ───────────────────────────────');
- /*$configs = $params['configs'];
- $menu = $configs['menu'];
- $notification = $configs['notification'];*/
- $mobile = eqLogic::byLogicalId($params['Iq'], 'mobile');
- if (is_object($mobile)) {
+ log::add('mobile', 'debug', '┌──────────▶︎ ASK ───────────────────────────');
+ if (is_object($mobile = eqLogic::byLogicalId($params['Iq'], 'mobile'))) {
$askCasse = config::byKey('askCasse', 'mobile', false);
$textCasse = $params['text'];
if ($askCasse == false) {
$textCasse = strtolower($params['text']);
}
- $cmd = $mobile->getCmd(null, 'notif');
- log::add('mobile', 'debug', '| Réponse : ' . $textCasse . ' - IQ > ' . $params['Iq'] . ' -- Demande cmd > ' . $cmd->getId());
- if ($cmd->askResponse($textCasse)) {
- log::add('mobile', 'debug', '| ASK bien trouvé : Réponse validée');
- } else {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $cmd->generateAskResponseLink($params['text']));
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- $output = curl_exec($ch);
- curl_close($ch);
- if (!empty($output)) log::add('mobile', 'debug', '| ' . $output);
- }
- } else {
- log::add('mobile', 'debug', __('| [ERROR] EqLogic inconnu : ', __FILE__) . $params['Iq']);
- }
+ if (is_object($cmd = $mobile->getCmd(null, 'notif'))) {
+ log::add('mobile', 'debug', '| Response ─▶︎ ' . $textCasse);
+ log::add('mobile', 'debug', '| Cmd ─▶︎ ' . $cmd->getHumanName() . ' (' . $cmd->getId() . ')');
+ if ($cmd->askResponse($textCasse)) {
+ log::add('mobile', 'debug', '| OK Response confirmed');
+ } else {
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $cmd->generateAskResponseLink($params['text']));
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ $output = curl_exec($ch);
+ curl_close($ch);
+ if (!empty($output)) log::add('mobile', 'debug', '| ' . $output);
+ }
+ } else log::add('mobile', 'debug', '| [ERROR] Cmd notification not found');
+ } else log::add('mobile', 'debug', '| [ERROR] EqLogic unknown ─▶︎ ' . $params['Iq']);
log::add('mobile', 'debug', '└───────────────────────────────────────────');
$jsonrpc->makeSuccess();
}
@@ -485,110 +470,93 @@ function saveMenuFromAppV2($menu, $mobile)
* @return string ok
*/
if ($jsonrpc->getMethod() == 'getAskResponse') {
- log::add('mobile', 'debug', '┌────▶︎ getAskResponse ────────────────────');
- $Iq = $params['Iq'];
- $filePath = dirname(__FILE__) . '/../data/notifications/' . $Iq . '.json';
- $idNotif = $params['idNotif'];
- $choiceAsk = $params['choiceAsk'];
- log::add('mobile', 'debug', '| Réponse ASK > ' . $Iq . ' > ' . $idNotif . ' > ' . $choiceAsk);
- if (file_exists($filePath)) {
- $notifications = file_get_contents($filePath);
- $notificationsArray = json_decode($notifications, true);
- foreach ($notificationsArray as $key => $notif) {
- if ($notif['data']['idNotif'] == $idNotif) {
- $notificationsArray[$key]['data']['choiceAsk'] = $choiceAsk;
- break;
+ log::add('mobile', 'debug', '┌──────────▶︎ getAskResponse ────────────────');
+ if (is_object($mobile = eqLogic::byLogicalId($params['Iq'], 'mobile'))) {
+ $Iq = $params['Iq'];
+ $filePath = dirname(__FILE__) . '/../data/notifications/' . $Iq . '.json';
+ $idNotif = $params['idNotif'];
+ $choiceAsk = $params['choiceAsk'];
+ log::add('mobile', 'debug', '| Id notif ─▶︎ ' . $idNotif);
+ log::add('mobile', 'debug', '| Response ─▶︎ ' . $choiceAsk);
+ if (file_exists($filePath)) {
+ $notifications = file_get_contents($filePath);
+ $notificationsArray = json_decode($notifications, true);
+ foreach ($notificationsArray as $key => $notif) {
+ if ($notif['data']['idNotif'] == $idNotif) {
+ $notificationsArray[$key]['data']['choiceAsk'] = $choiceAsk;
+ break;
+ }
}
- }
- $updatedNotifications = json_encode($notificationsArray);
- file_put_contents($filePath, $updatedNotifications);
- }
+ $updatedNotifications = json_encode($notificationsArray);
+ file_put_contents($filePath, $updatedNotifications);
+ } else log::add('mobile', 'debug', '| [ERROR] Notification file does not exist');
+ } else log::add('mobile', 'debug', '| [ERROR] EqLogic unknown ─▶︎ ' . $params['Iq']);
log::add('mobile', 'debug', '└───────────────────────────────────────────');
$jsonrpc->makeSuccess('ok');
}
-/**
- * saveMobile
- *
- * @return makeSuccess
- */
-if ($jsonrpc->getMethod() == 'saveMobile') {
- log::add('mobile', 'debug', 'Demande de sauvegarde ' . $params['type'] . ' > ' . $params['Iq'] . ' > ' . mobile::whoIsIq($params['Iq']));
- mobile::makeSaveJson($params['Iq'], $params['Json'], $params['type']);
- $jsonrpc->makeSuccess();
-}
-
/**
* save event coming from geofencing and methodeForSpecificChannel
*
* @return makeSuccess
*/
if ($jsonrpc->getMethod() == 'mobile::geoloc') {
- log::add('mobile', 'debug', '┌─────▶︎ GeoLocV2 geofencing ───────────────');
+ log::add('mobile', 'debug', '┌──────────▶︎ GeoLocV2 geofencing ───────────');
$mobile = eqLogic::byLogicalId($params['Iq'], 'mobile');
if (is_object($mobile)) {
- if (isset($params['transmition']) && isset($params['transmition']['extras']) && isset($params['transmition']['extras']['method'])) {
- if ($params['transmition']['extras']['method'] == 'getDeviceInformations') {
- log::add('mobile', 'debug', '| ───:fg-success: methodeForSpecificChannel in Background :/fg: ───');
- $mobile->cmdForSpecificChannel($params, 'transmition');
- }
- } else if (isset($params['transmition']) && isset($params['transmition']['event']) && $params['transmition']['event'] == 'geofence') {
- log::add('mobile', 'debug', '| Event > ' . $params['transmition']['event']);
- $geofence = $params['transmition']['geofence'];
- log::add('mobile', 'debug', '| Event > ' . json_encode($geofence));
- log::add('mobile', 'debug', '| OK Mobile trouvé -> ' . $mobile->getName() . ' (' . $params['Iq'] . ')');
- $cmdgeoloc = cmd::byEqLogicIdAndLogicalId($mobile->getId(), 'geoloc_' . $geofence['identifier']);
- if (is_object($cmdgeoloc)) {
- if ($geofence['action'] == 'ENTER' || $geofence['action'] == 'EXIT') {
- $eventAge = time() - intval(strtotime($geofence['timestamp']));
- if ($eventAge > 1800) {
- log::add('mobile', 'debug', '| SKIP stale event (' . round($eventAge / 60) . 'min) ' . $geofence['action'] . ' geoloc_' . $geofence['identifier']);
- } else {
- $value = ($geofence['action'] == 'ENTER') ? 1 : 0;
- log::add('mobile', 'debug', '| OK Commande "' . $cmdgeoloc->getName() . '" -> ' . $value);
- $mobile->checkAndUpdateCmd('geoloc_' . $geofence['identifier'], $value);
- }
- } else {
- log::add('mobile', 'debug', '| Event -> ' . $geofence['action']);
- }
- }
- } else {
- $transmitions = $params['transmition'];
- $errorCount = 0;
- foreach ($transmitions as $transmition) {
- if (isset($transmition['event']) && $transmition['event'] == 'geofence') {
- log::add('mobile', 'debug', '| Transmition :' . json_encode($params['transmition']));
- $geofence = $transmition['geofence'];
- log::add('mobile', 'debug', '| Event > ' . json_encode($geofence));
- log::add('mobile', 'debug', '| OK Mobile trouvé -> ' . $mobile->getName() . ' (' . $params['Iq'] . ')');
- $cmdgeoloc = cmd::byEqLogicIdAndLogicalId($mobile->getId(), 'geoloc_' . $geofence['identifier']);
- if (is_object($cmdgeoloc)) {
- if ($geofence['action'] == 'ENTER' || $geofence['action'] == 'EXIT') {
- $eventAge = time() - intval(strtotime($geofence['timestamp']));
- if ($eventAge > 1800) {
- log::add('mobile', 'debug', '| SKIP stale event (' . round($eventAge / 60) . 'min) ' . $geofence['action'] . ' geoloc_' . $geofence['identifier']);
- } else {
- $value = ($geofence['action'] == 'ENTER') ? 1 : 0;
- log::add('mobile', 'debug', '| OK Commande "' . $cmdgeoloc->getName() . '" -> ' . $value);
- $mobile->checkAndUpdateCmd('geoloc_' . $geofence['identifier'], $value);
- }
+ log::add('mobile', 'debug', '| OK Mobile found ─▶︎ ' . $mobile->getName() . ' (' . $params['Iq'] . ')');
+ if (isset($params['transmition'])) {
+ if (isset($params['transmition']['event']) && $params['transmition']['event'] == 'geofence') {
+ log::add('mobile', 'debug', '| Event ─▶︎ ' . $params['transmition']['event']);
+ $geofence = $params['transmition']['geofence'];
+ log::add('mobile', 'debug', '| Geofence ─▶︎ ' . json_encode($geofence));
+ $cmdgeoloc = cmd::byEqLogicIdAndLogicalId($mobile->getId(), 'geoloc_' . $geofence['identifier']);
+ if (is_object($cmdgeoloc)) {
+ if ($geofence['action'] == 'ENTER' || $geofence['action'] == 'EXIT') {
+ $eventAge = time() - intval(strtotime($geofence['timestamp']));
+ if ($eventAge > 1800) {
+ log::add('mobile', 'debug', '| [WARNING] SKIP stale event (' . round($eventAge / 60) . 'min)');
} else {
- log::add('mobile', 'debug', '| [INFO] Event -> ' . $geofence['action']);
+ $value = ($geofence['action'] == 'ENTER') ? 1 : 0;
+ log::add('mobile', 'debug', '| OK Command "' . $cmdgeoloc->getName() . '" ( geoloc_' . $geofence['identifier'] . ' ) ─▶︎ ' . $value . ' ( eventAge = ' . $eventAge . 'sec )');
+ $mobile->checkAndUpdateCmd('geoloc_' . $geofence['identifier'], $value);
}
- } else {
- log::add('mobile', 'debug', '| [ERROR] Commande geoloc_' . $geofence['identifier'] . ' inexistante.');
+ } else log::add('mobile', 'debug', '| [WARNING] Action unknown ─▶︎ ' . $geofence['action']);
+ } else log::add('mobile', 'debug', '| [ERROR] geofencing command unknown ─▶︎ ' . 'geoloc_' . $geofence['identifier']);
+ $mobile->cmdForSpecificChannel($params, 'transmition');
+ } else if (is_array($transmitions = $params['transmition'])) {
+ log::add('mobile', 'debug', '| [INFO] transmition is array');
+ $nbTransmition = count($transmitions);
+ foreach ($transmitions as $key => $transmition) {
+ log::add('mobile', 'debug', '|┌────────── [' . $key . '] ──────────');
+ if (isset($transmition['event']) && $transmition['event'] == 'geofence') {
+ log::add('mobile', 'debug', '|| Event ─▶︎ ' . $transmition['event']);
+ $geofence = $transmition['geofence'];
+ log::add('mobile', 'debug', '|| Geofence ─▶︎ ' . json_encode($geofence));
+ $cmdgeoloc = cmd::byEqLogicIdAndLogicalId($mobile->getId(), 'geoloc_' . $geofence['identifier']);
+ if (is_object($cmdgeoloc)) {
+ if ($geofence['action'] == 'ENTER' || $geofence['action'] == 'EXIT') {
+ $eventAge = time() - intval(strtotime($geofence['timestamp']));
+ if ($eventAge > 1800) {
+ log::add('mobile', 'debug', '|| [WARNING] SKIP stale event (' . round($eventAge / 60) . 'min)');
+ } else {
+ $value = ($geofence['action'] == 'ENTER') ? 1 : 0;
+ log::add('mobile', 'debug', '|| OK Command "' . $cmdgeoloc->getName() . '" ( geoloc_' . $geofence['identifier'] . ' ) ─▶︎ ' . $value . ' ( eventAge = ' . $eventAge . 'sec )');
+ $mobile->checkAndUpdateCmd('geoloc_' . $geofence['identifier'], $value);
+ }
+ } else log::add('mobile', 'debug', '|| [WARNING] Action unknown ─▶︎ ' . $geofence['action']);
+ } else log::add('mobile', 'debug', '|| [ERROR] geofencing command unknown ─▶︎ ' . 'geoloc_' . $geofence['identifier']);
+ } else log::add('mobile', 'debug', '|| [ERROR] No geofencing settings');
+ log::add('mobile', 'debug', '|└────────────────────────');
+ if ($key == $nbTransmition - 1) {
+ $mobile->cmdForSpecificChannel($transmitions, $key);
}
- } else {
- $errorCount++;
}
}
- if ($errorCount > 0) {
- log::add('mobile', 'debug', __('| Pas de paramètre de geofencing', __FILE__));
- }
}
} else {
- if (isset($params['Iq'])) log::add('mobile', 'debug', __('| [ERROR] EqLogic inconnu : ', __FILE__) . $params['Iq']);
- else log::add('mobile', 'debug', __('| [ERROR] Paramètre Iq inexistant !', __FILE__));
+ if (isset($params['Iq'])) log::add('mobile', 'debug', '| [ERROR] EqLogic unknown ─▶︎ ' . $params['Iq']);
+ else log::add('mobile', 'debug', '[WARNING] Parameter Iq does not exist !');
}
log::add('mobile', 'debug', '└───────────────────────────────────────────');
$jsonrpc->makeSuccess();
@@ -600,16 +568,16 @@ function saveMenuFromAppV2($menu, $mobile)
* @return makeSuccess
*/
if ($jsonrpc->getMethod() == "qrcodemethod") {
- log::add('mobile', 'debug', '┌─────▶︎ qrcodemethod ──────────────────────');
+ log::add('mobile', 'debug', '┌──────────▶︎ qrcodemethod ──────────────────');
if ($params['appInfos']) {
- log::add('mobile', 'debug', '| [INFO] Valeur du QrCode > ' . json_encode($params['appInfos']['qrCode']));
+ log::add('mobile', 'debug', '| [INFO] QR Code Value > ' . json_encode($params['appInfos']['qrCode']));
if (isset($params['appInfos']['qrCode']['displayValue'])) {
mobile::cmdForApi($params['Iq'], "barrecodemethod", $params['appInfos']['qrCode']['displayValue'], "CodeBarre");
} else {
mobile::cmdForApi($params['Iq'], "qrcodemethod", json_encode($params['appInfos']['qrCode']), "QrCode");
}
- log::add('mobile', 'debug', '└───────────────────────────────────────────');
}
+ log::add('mobile', 'debug', '└───────────────────────────────────────────');
$jsonrpc->makeSuccess();
}
@@ -619,21 +587,21 @@ function saveMenuFromAppV2($menu, $mobile)
* @return makeSuccess || makeError
*/
if ($jsonrpc->getMethod() == "methodeForSpecificChannel") {
- log::add('mobile', 'debug', '┌─────▶︎ methodeForSpecificChannel ──────────────────────');
- log::add('mobile', 'debug', '| [INFO] params > ' . json_encode($params));
+ log::add('mobile', 'debug', '┌──────────▶︎ methodeForSpecificChannel ──────────────────────');
+ log::add('mobile', 'debug', '| [INFO] params ─▶︎ ' . json_encode($params));
$mobile = eqLogic::byLogicalId($params['Iq'], 'mobile');
if (is_object($mobile)) {
$mobile->cmdForSpecificChannel($params, 'location');
} else {
if (isset($params['Iq'])) {
- log::add('mobile', 'debug', __('| [ERROR] EqLogic inconnu : ', __FILE__) . $params['Iq']);
+ log::add('mobile', 'debug', '| [ERROR] EqLogic unknown ─▶︎ ' . $params['Iq']);
$jsonrpc->makeError('EqLogic inconnu');
} else {
- log::add('mobile', 'debug', __('| [ERROR] Paramètre Iq inexistant !', __FILE__));
+ log::add('mobile', 'debug', '[WARNING] Parameter Iq does not exist !');
$jsonrpc->makeError('Paramètre Iq inexistant');
}
}
- log::add('mobile', 'debug', '└───────────────────────────────────────────');
+ log::add('mobile', 'debug', '└─────────────────────────────────────────────────────────────');
$jsonrpc->makeSuccess();
}
@@ -643,13 +611,13 @@ function saveMenuFromAppV2($menu, $mobile)
* @return makeSuccess
*/
if ($jsonrpc->getMethod() == "nfc") {
- log::add('mobile', 'debug', '┌─────▶︎ nfc ───────────────────────────────');
+ log::add('mobile', 'debug', '┌──────────▶︎ NFC ───────────────────────────');
$id = (isset($params['appInfos']['payload']['id'])) ? $params['appInfos']['payload']['id'] : "";
$payload = (isset($params['appInfos']['payload']['payload'])) ? $params['appInfos']['payload']['payload'] : "";
mobile::cmdForApi($params['Iq'], "nfcId", $id, "Nfc Id");
mobile::cmdForApi($params['Iq'], "nfcPayload", json_encode($payload), "Nfc Payload");
- log::add('mobile', 'debug', '| [INFO] Id > ' . $id);
- log::add('mobile', 'debug', '| [INFO] Payload > ' . $payload);
+ log::add('mobile', 'debug', '| [INFO] Id ─▶︎ ' . $id);
+ log::add('mobile', 'debug', '| [INFO] Payload ─▶︎ ' . $payload);
log::add('mobile', 'debug', '└───────────────────────────────────────────');
$jsonrpc->makeSuccess();
}
@@ -660,8 +628,8 @@ function saveMenuFromAppV2($menu, $mobile)
* @return
*/
if ($jsonrpc->getMethod() == "syncBella") {
- log::add('mobile', 'debug', '┌─────▶︎ syncBella ─────────────────────────');
- log::add('mobile', 'debug', '| JeedomApp > syncBella');
+ log::add('mobile', 'debug', '┌──────────▶︎ syncBella ─────────────────────');
+ log::add('mobile', 'debug', '| JeedomApp ─▶︎ syncBella');
log::add('mobile', 'debug', '└───────────────────────────────────────────');
}
@@ -671,7 +639,7 @@ function saveMenuFromAppV2($menu, $mobile)
* @return array
*/
if ($jsonrpc->getMethod() == 'getNotificationsFromFile') {
- log::add('mobile', 'debug', '┌──────────▶︎ :fg-warning: Recuperation des Notifications :/fg: ──────────');
+ log::add('mobile', 'debug', '┌──────────▶︎:fg-warning: getNotificationsFromFile :/fg:──────────');
$Iq = $params['Iq'];
$filePath = dirname(__FILE__) . '/../data/notifications/' . $Iq . '.json';
$notifications = 'noNotifications';
@@ -681,8 +649,8 @@ function saveMenuFromAppV2($menu, $mobile)
$notifications = 'noNotifications';
}
}
- log::add('mobile', 'debug', '| [INFO] Notifications > ' . $notifications);
- log::add('mobile', 'debug', '└───────────────────────────────────────────');
+ log::add('mobile', 'debug', '| [INFO] Notifications ─▶︎ ' . $notifications);
+ log::add('mobile', 'debug', '└─────────────────────────────────────────────────────');
$jsonrpc->makeSuccess($notifications);
}
@@ -692,7 +660,7 @@ function saveMenuFromAppV2($menu, $mobile)
* @return string ok
*/
if ($jsonrpc->getMethod() == 'deleteNotificationInJsonFile') {
- log::add('mobile', 'debug', '┌────▶︎ deleteNotificationInJsonFile ──────');
+ log::add('mobile', 'debug', '┌──────────▶︎ deleteNotificationInJsonFile ──────');
$Iq = $params['Iq'];
$filePath = dirname(__FILE__) . '/../data/notifications/' . $Iq . '.json';
$idNotif = $params['IdNotif'];
@@ -708,7 +676,7 @@ function saveMenuFromAppV2($menu, $mobile)
file_put_contents($filePath, $notifications);
}
}
- log::add('mobile', 'debug', '└───────────────────────────────────────────');
+ log::add('mobile', 'debug', '└───────────────────────────────────────────────');
$jsonrpc->makeSuccess('ok');
}
@@ -718,7 +686,7 @@ function saveMenuFromAppV2($menu, $mobile)
* @return string ok
*/
if ($jsonrpc->getMethod() == 'deleteGeolocCommand') {
- log::add('mobile', 'debug', '┌────▶︎ Commande suppression GeoLoc ───────');
+ log::add('mobile', 'debug', '┌──────────▶︎ deleteGeolocCommand ───────');
$geolocId = $params['geoloc_id'];
$eqLogic = eqLogic::byLogicalId($params['Iq'], 'mobile');
if (is_object($eqLogic)) {
@@ -727,10 +695,9 @@ function saveMenuFromAppV2($menu, $mobile)
log::add('mobile', 'debug', '| [WARNING] Suppression de la commande "' . $cmd->getName() . '"');
$cmd->remove();
}
- } else {
- log::add('mobile', 'debug', __('| [ERROR] EqLogic inconnu : ', __FILE__) . $params['Iq']);
- }
- log::add('mobile', 'debug', '└───────────────────────────────────────────');
+ } else if (isset($params['Iq'])) log::add('mobile', 'debug', '| [ERROR] EqLogic unknown ─▶︎ ' . $params['Iq']);
+ else log::add('mobile', 'debug', '[WARNING] Parameter Iq does not exist !');
+ log::add('mobile', 'debug', '└───────────────────────────────────────────────');
$jsonrpc->makeSuccess('ok');
}
@@ -740,14 +707,14 @@ function saveMenuFromAppV2($menu, $mobile)
* @return array
*/
if ($jsonrpc->getMethod() == 'getScenarios') {
- log::add('mobile', 'debug', '┌────◀︎ Get Scénarios ─────────────────────');
+ log::add('mobile', 'debug', '┌──────────◀︎ getScenarios ─────────────────');
$scenarios = array();
$hasScenario = false;
$scenarioListGroup = scenario::listGroup();
$emptyListGroup = false;
$emptyNoGroup = false;
if (empty($scenarioListGroup)) {
- log::add('mobile', 'debug', '| Scénarios > Aucun groupe de scénario');
+ log::add('mobile', 'debug', '| Scenarios ─▶︎ No scenario group');
$emptyListGroup = true;
}
if (is_array($scenarioListGroup)) {
@@ -761,15 +728,15 @@ function saveMenuFromAppV2($menu, $mobile)
$scenarios['{{Aucun}}'] = $scenarioNoGroup;
$hasScenario = true;
} else {
- log::add('mobile', 'debug', '| Scénarios > Aucun "sans groupe" de scénario');
+ log::add('mobile', 'debug', '| Scenarios ─▶︎ No scenario "without a group"');
$emptyNoGroup = true;
}
- log::add('mobile', 'debug', '| Scénarios > ' . json_encode($scenarios));
+ log::add('mobile', 'debug', '| Scenarios ─▶︎ ' . json_encode($scenarios));
$scenarioTemp = array();
foreach ($scenarios as $key => $scenario) {
$scenarioTemp[$key][] = utils::o2a($scenario);
}
- log::add('mobile', 'debug', '| $scenarioTemp > ' . json_encode($scenarioTemp));
+ log::add('mobile', 'debug', '| $scenarioTemp ─▶︎ ' . json_encode($scenarioTemp));
if ($emptyListGroup && $emptyNoGroup) {
$return = 'noScenarios';
} else {
@@ -779,44 +746,232 @@ function saveMenuFromAppV2($menu, $mobile)
$jsonrpc->makeSuccess($return);
}
-// /**
-// * command scenarios by id
-// *
-// * @return array
-// */
-// if ($jsonrpc->getMethod() == 'handleScenario'){
-// log::add('mobile', 'debug', '┌────▶︎ handleScenario ────────────────────');
-// $scenarioId = $params['scenario_id'];
-// $action = $params['action'];
-// $result = 'ko';
-// log::add('mobile', 'debug', '| Scénario > ' . $scenarioId);
-// log::add('mobile', 'debug', '| Action > ' . $action);
-// if (is_object($scenario = scenario::byId($scenarioId))) {
-// switch($action) {
-// case 'start':
-// $scenario->launch();
-// $result = 'ok';
-// break;
-// case 'stop':
-// $scenario->stop();
-// $result = 'ok';
-// break;
-// case 'activate':
-// $scenario->setIsActive(1);
-// $scenario->save();
-// $result = 'ok';
-// break;
-// case 'desactivate':
-// $scenario->setIsActive(0);
-// $scenario->save();
-// $result = 'ok';
-// break;
-// }
-// } else {
-// log::add('mobile', 'debug', '| [ERROR] Scénario > ' . $scenarioId . ' inexistant !');
-// }
-// log::add('mobile', 'debug', '└───────────────────────────────────────────');
-// $jsonrpc->makeSuccess($result);
-// }
+// APP V1 //
+
+if ($jsonrpc->getMethod() == 'sync') {
+ log::add('mobile', 'debug', '┌──────────▶︎ Sync App V1 ───────────────────');
+ if (jeedom::version() >= '3.2.0') {
+ log::add('mobile', 'debug', '| Demande du RDK ....');
+ $registerDevice = $_USER_GLOBAL->getOptions('registerDevice', array());
+ if (!is_array($registerDevice)) {
+ $registerDevice = array();
+ }
+ $rdk = (!isset($params['rdk']) || !isset($registerDevice[sha512($params['rdk'])])) ? config::genKey() : $params['rdk'];
+ $registerDevice[sha512($rdk)] = array();
+ $registerDevice[sha512($rdk)]['datetime'] = date('Y-m-d H:i:s');
+ $registerDevice[sha512($rdk)]['ip'] = getClientIp();
+ $registerDevice[sha512($rdk)]['session_id'] = session_id();
+ $_USER_GLOBAL->setOptions('registerDevice', $registerDevice);
+ $_USER_GLOBAL->save();
+ log::add('mobile', 'debug', '| RDK : ' . $rdk);
+ }
+ $mobile = null;
+ if (isset($params['Iq'])) {
+ $mobile = eqLogic::byLogicalId($params['Iq'], 'mobile');
+ }
+ if (!is_object($mobile)) {
+ $user = user::byHash($params['apikey']);
+ $userId = $user->getId();
+ $mobile = new mobile();
+ $mobile->setEqType_name('mobile');
+ $mobile->setName($params['platform'] . '-' . config::genKey(3));
+ $mobile->setConfiguration('type_mobile', $params['platform']);
+ $mobile->setConfiguration('affect_user', $userId);
+ $mobile->setConfiguration('validate', 'no');
+ if (isset($params['notificationProvider']) && $params['notificationProvider'] != '') {
+ $mobile->setConfiguration('notificationArn', substr($params['notificationProvider'], 1, -1));
+ }
+ if (isset($params['notificationRegistrationToken']) && $params['notificationRegistrationToken'] != '') {
+ if ($params['notificationRegistrationToken'] != 'nok') {
+ $mobile->setConfiguration('notificationRegistrationToken', $params['notificationRegistrationToken']);
+ }
+ }
+ $mobile->setIsEnable(1);
+ $mobile->save();
+ $params['Iq'] = $mobile->getLogicalId();
+ }
+
+ if (isset($params['notificationProvider']) && $params['notificationProvider'] != '') {
+ log::add('mobile', 'debug', '| notificationProvider available');
+ $arn = $mobile->getConfiguration('notificationArn', '');
+ $arnMobile = substr($params['notificationProvider'], 1, -1);
+ if ($arn != $arnMobile) {
+ $mobile->setConfiguration('notificationArn', $arnMobile);
+ $mobile->save();
+ }
+ }
+
+ if (isset($params['notificationRegistrationToken']) && $params['notificationRegistrationToken'] != '') {
+ log::add('mobile', 'debug', '| notificationRegistrationToken available');
+ $token = $mobile->getConfiguration('notificationRegistrationToken', 'nok');
+ $tokenMobile = $params['notificationRegistrationToken'];
+ if ($token == 'nok') {
+ log::add('mobile', 'debug', '| notificationRegistrationToken null in the configuration ─▶︎ ' . $token);
+ $mobile->setConfiguration('notificationRegistrationToken', $tokenMobile);
+ $mobile->save();
+ } else {
+ log::add('mobile', 'debug', '| Token in the configuration ─▶︎ ' . $token);
+ if ($token != $tokenMobile) {
+ log::add('mobile', 'debug', '| Token config != Token mobile ─▶︎ ' . $token . ' != ' . $tokenMobile);
+ $mobile->setConfiguration('notificationRegistrationToken', $tokenMobile);
+ $mobile->save();
+ }
+ }
+ }
+
+ if (isset($params['gen_json']) && $params['gen_json'] == 1) {
+ mobile::makeTemplateJson();
+ }
+ $return = mobile::getTemplateJson();
+ $return['messages'] = mobile::discovery_message();
+ $return['summaryValue'] = mobile::discovery_summaryValue($return['objects']);
+ $return['config']['datetime'] = getmicrotime();
+ $return['config']['Iq'] = $params['Iq'];
+ $return['config']['NameMobile'] = $mobile->getName();
+ if (isset($rdk)) {
+ $return['config']['rdk'] = $rdk;
+ }
+ log::add('mobile', 'debug', '| Return $discovery_summaryValue ─▶︎ ' . json_encode($return['summaryValue']));
+ log::add('mobile', 'debug', '└───────────────────────────────────────────');
+ $jsonrpc->makeSuccess($return);
+}
+
+if ($jsonrpc->getMethod() == 'cmdsbyEqlogicID') {
+ log::add('mobile', 'debug', 'Querying the ID module ' . $params['id'] . ' for cmds');
+ $PluginToSend = mobile::PluginToSend();
+ $discover_eqLogic = mobile::discovery_eqLogic($PluginToSend);
+ $sync_new = mobile::change_cmdAndeqLogic(mobile::discovery_cmd($PluginToSend, $discover_eqLogic, true), $discover_eqLogic);
+ $i = 0;
+ $cmdAPI = array();
+ foreach ($sync_new['cmds'] as $cmd) {
+ if (isset($cmd["eqLogic_id"])) {
+ if ($cmd["eqLogic_id"] != $params['id']) {
+ unset($commandes[$i]);
+ } else {
+ array_push($cmdAPI, $commandes[$i]);
+ }
+ }
+ $i++;
+ }
+ log::add('mobile', 'debug', 'Commands ─▶︎ ' . json_encode($cmdAPI));
+ $jsonrpc->makeSuccess($cmdAPI);
+}
+
+if ($jsonrpc->getMethod() == 'version') {
+ $mobile_update = update::byLogicalId('mobile');
+ $jsonrpc->makeSuccess($mobile_update->getLocalVersion());
+}
+
+if ($jsonrpc->getMethod() == 'event') {
+ $eqLogic = eqLogic::byId($params['eqLogic_id']);
+ if (!is_object($eqLogic)) {
+ throw new Exception(__('EqLogic inconnu : ', __FILE__) . $params['eqLogic_id']);
+ }
+ $cmd = $eqLogic->getCmd(null, $params['cmd_logicalId']);
+ if (!is_object($cmd)) {
+ throw new Exception(__('Cmd inconnu : ', __FILE__) . $params['cmd_logicalId']);
+ }
+ $cmd->event($params['value']);
+ $jsonrpc->makeSuccess();
+}
+
+if ($jsonrpc->getMethod() == 'saveMobile') {
+ log::add('mobile', 'debug', '┌──────────▶︎:fg-warning: saveMobile V1 :/fg:──────────────');
+ if (isset($params['Iq'])) {
+ log::add('mobile', 'debug', '| Backup request ─▶︎ ' . $params['type'] . ' ─▶︎ ' . $params['Iq'] . ' (' . mobile::whoIsIq($params['Iq']) . ')');
+ log::add('mobile', 'debug', '| Data to save ─▶︎ ' . json_encode($params['Json']));
+ mobile::makeSaveJson($params['Iq'], $params['Json'], $params['type']);
+ }
+ log::add('mobile', 'debug', '└───────────────────────────────────────────');
+ $jsonrpc->makeSuccess();
+}
+
+if ($jsonrpc->getMethod() == 'getMobile') {
+ log::add('mobile', 'debug', '┌──────────▶︎:fg-warning: getMobile V1 :/fg:──────────────');
+ log::add('mobile', 'debug', '| Recovery request ─▶︎ ' . $params['type'] . ' ─▶︎ ' . $params['Iq'] . ' (' . mobile::whoIsIq($params['Iq']) . ')');
+ log::add('mobile', 'debug', '| Backup recovery ─▶︎ ' . $params['IqRestore'] . ' (' . mobile::whoIsIq($params['IqRestore']) . ')');
+ $saveJson = mobile::getSaveJson($params['IqRestore'], $params['type']);
+ log::add('mobile', 'debug', '| Data sent to the app ─▶︎ ' . json_encode($saveJson));
+ log::add('mobile', 'debug', '└───────────────────────────────────────────');
+ $jsonrpc->makeSuccess($saveJson);
+}
+
+if ($jsonrpc->getMethod() == 'geoloc') {
+ log::add('mobile', 'debug', '┌──────────▶︎:fg-warning: geoloc V1 :/fg:──────────────');
+ if (isset($params['Iq'])) {
+ $mobile = eqLogic::byLogicalId($params['Iq'], 'mobile');
+ if (is_object($mobile)) {
+ if (isset($params['id']) && $params['id'] != '' && isset($params['name']) && $params['name'] != '' && isset($params['value']) && $params['value'] != '') {
+ log::add('mobile', 'debug', '| geoId_' . $params['id'] . ' ─▶︎ ' . $params['name'] . ' ─▶︎ ' . $params['value']);
+ if ($mobile->checkAndUpdateCmd('geoId_' . $params['id'], $params['value'])) {
+ log::add('mobile', 'debug', '| ↳ Update geofence point ─▶︎ ' . $params['value']);
+ }
+ } else log::add('mobile', 'debug', '| [WARNING] A required parameter does not exist !');
+ } else log::add('mobile', 'debug', '| [ERROR] EqLogic unknown ─▶︎ ' . $params['Iq']);
+ }
+ log::add('mobile', 'debug', '└───────────────────────────────────────────');
+ $jsonrpc->makeSuccess();
+}
+
+if ($jsonrpc->getMethod() == 'geolocSave') {
+ log::add('mobile', 'debug', '┌──────────▶︎:fg-warning: geolocSave V1 :/fg:──────────────');
+ if (isset($params['Iq'])) {
+ $mobile = eqLogic::byLogicalId($params['Iq'], 'mobile');
+ if (is_object($mobile)) {
+ if (isset($params['id']) && $params['id'] != '') {
+ $cmdgeoloc = cmd::byEqLogicIdAndLogicalId($mobile->getId(), 'geoId_' . $params['id']);
+ if ($params['name'] == "") {
+ $name = $params['id'];
+ } else {
+ $name = $params['name'];
+ }
+ if (!is_object($cmdgeoloc)) {
+ $cmdgeoloc = new mobileCmd();
+ $cmdgeoloc->setLogicalId('geoId_' . $params['id']);
+ $cmdgeoloc->setEqLogic_id($mobile->getId());
+ $cmdgeoloc->setType('info');
+ $cmdgeoloc->setSubType('binary');
+ $cmdgeoloc->setTemplate('dashboard', 'core::presence');
+ $cmdgeoloc->setTemplate('mobile', 'core::presence');
+ $cmdgeoloc->setDisplay('icon', '');
+ $cmdgeoloc->setDisplay('showIconAndNamedashboard', 1);
+ $cmdgeoloc->setIsHistorized(1);
+ $cmdgeoloc->setGeneric_type('PRESENCE');
+ $cmdgeoloc->setIsVisible(1);
+ $cmdgeoloc->setName($name);
+ }
+ $cmdgeoloc->setConfiguration('latitude', $params['latitude']);
+ $cmdgeoloc->setConfiguration('longitude', $params['longitude']);
+ $cmdgeoloc->setConfiguration('subtitle', $params['subtitle']);
+ $cmdgeoloc->setConfiguration('radius', $params['radius']);
+ $cmdgeoloc->save();
+ log::add('mobile', 'debug', '| geoId_' . $params['id'] . ' ─▶︎ ' . $name . ' ─▶︎ ' . $params['value']);
+ if ($mobile->checkAndUpdateCmd('geoId_' . $params['id'], $params['value'])) {
+ log::add('mobile', 'debug', '| ↳ Update geofence point ─▶︎ ' . $params['value']);
+ }
+ } else log::add('mobile', 'debug', '| [WARNING] A required parameter does not exist or is empty !');
+ } else log::add('mobile', 'debug', '| [ERROR] EqLogic unknown ─▶︎ ' . $params['Iq']);
+ }
+ log::add('mobile', 'debug', '└───────────────────────────────────────────');
+ $jsonrpc->makeSuccess();
+}
+
+if ($jsonrpc->getMethod() == 'geolocDel') {
+ log::add('mobile', 'debug', '┌──────────▶︎:fg-warning: geolocDel V1 :/fg:──────────────');
+ if (isset($params['Iq'])) {
+ $mobile = eqLogic::byLogicalId($params['Iq'], 'mobile');
+ if (is_object($mobile)) {
+ if (isset($params['id']) && $params['id'] != '') {
+ $cmdgeoloc = cmd::byEqLogicIdAndLogicalId($mobile->getId(), 'geoId_' . $params['id']);
+ if (is_object($cmdgeoloc)) {
+ $cmdgeoloc->remove();
+ log::add('mobile', 'debug', '| geoId_' . $params['id'] . ' (' . $params['name'] . ') is deleted with success.');
+ }
+ } else log::add('mobile', 'debug', '| [WARNING] A required parameter Id does not exist or is empty !');
+ } else log::add('mobile', 'debug', '| [ERROR] EqLogic unknown ─▶︎ ' . $params['Iq']);
+ }
+ log::add('mobile', 'debug', '└───────────────────────────────────────────');
+ $jsonrpc->makeSuccess();
+}
throw new Exception(__('Aucune demande', __FILE__));
diff --git a/core/class/mobile.class.php b/core/class/mobile.class.php
index bcb5901d..0fdaf818 100755
--- a/core/class/mobile.class.php
+++ b/core/class/mobile.class.php
@@ -24,13 +24,52 @@
class mobile extends eqLogic
{
+ /* AppV1 */
+ public static $_pluginSuported = array('mobile', 'openzwave', 'rfxcom', 'edisio', 'mpower', 'mySensors', 'Zibasedom', 'virtual', 'camera', 'weather', 'philipsHue', 'enocean', 'wifipower', 'alarm', 'mode', 'apcupsd', 'btsniffer', 'dsc', 'rflink', 'mysensors', 'relaynet', 'remora', 'unipi', 'eibd', 'thermostat', 'netatmoThermostat', 'espeasy', 'jeelink', 'teleinfo', 'tahoma', 'protexiom', 'boilerThermostat', 'lifx', 'wattlet', 'rfplayer', 'openenocean', 'netatmoWeather', 'Volets', 'vmczehnder', 'zigbee');
+ public static $_pluginWidget = array('alarm', 'camera', 'thermostat', 'netatmoThermostat', 'weather', 'mode', 'mobile');
+ public static $_pluginMulti = array('LIGHT_STATE', 'ENERGY_STATE', 'FLAP_STATE', 'HEATING_STATE', 'SIREN_STATE', 'LOCK_STATE');
+ public static $_listenEvents = array('cmd::update', 'scenario::update', 'jeeObject::summary::update');
+
/* * ***********************Methode static*************************** */
+ /**
+ * Core callback to returns the directory of data not to be saved in the Jeedom backup
+ *
+ * @return array
+ */
+ public static function backupExclude()
+ {
+ return ['data/images'];
+ }
+
+ /**
+ * cron callback
+ * clean notification V2
+ * makeTemplate V1
+ */
public static function cronDaily()
{
+ // APP V2
foreach (eqLogic::byType('mobile') as $mobile) {
- $mobile->cleaningNotifications();
+ if ($mobile->getConfiguration('appVersion', 1) == 2) {
+ $mobile->cleaningNotifications();
+ }
}
+ // App V1
+ mobile::makeTemplateJson();
+ }
+
+ /**
+ * wizard AppV2
+ * Call by wizard.php
+ * @return array
+ */
+ public static function getWizardSteps(): array
+ {
+ $wizard['doc1'] = __('Accueil', __FILE__);
+ $wizard['doc2'] = __('Page2', __FILE__);
+ $wizard['doc3'] = __('Page3', __FILE__);
+ return $wizard;
}
/**
@@ -47,11 +86,11 @@ public static function getConfigForCommunity()
$res = '
```
';
$res .= 'OS : ' . $distrib . ' on ' . $hw;
$res .= ' - PHP : ' . phpversion();
- $res .= '
';
+ $res .= '
';
$res .= 'Etat Clé Api Core : ' . config::byKey('api::core::mode');
- $res .= '
';
- $res .= 'Etat Clé Api Mobile : ' . config::byKey('api::mobile::mode') . '
```';
- $res .= '
';
+ $res .= '
';
+ $res .= 'Etat Clé Api Mobile : ' . config::byKey('api::mobile::mode') . '
```';
+ $res .= '
';
$res .= '[details="Equipement(s)"]
';
$res .= '|Id | LogicalId | Type | App | defaultIdMobile | Profil | hideMenuGeoloc | hideMenuCustom|
';
$res .= '|--- | --- | --- | --- | --- | --- | --- | ---|
';
@@ -79,10 +118,489 @@ public static function whoIsIq($iq)
if (is_object($search)) {
return $search->getName();
} else {
- return 'mobile non detecte';
+ return 'Mobile not detected';
+ }
+ }
+
+ /******************************************************/
+ /******************** APP V1 *************************/
+ /******************************************************/
+
+ public static function pluginToSend()
+ {
+ $return = [];
+ $plugins = plugin::listPlugin(true);
+ foreach ($plugins as $plugin) {
+ $plugId = $plugin->getId();
+ //if ($plugId == 'mobile') {
+ // continue;
+ //} else if (in_array($plugId, self::$_pluginWidget)) {
+ if (in_array($plugId, self::$_pluginWidget)) {
+ $return[] = $plugId;
+ } else if (in_array($plugId, self::$_pluginSuported) && !in_array($plugId, self::$_pluginWidget) && config::byKey('sendToApp', $plugId, 1) == 1) {
+ $return[] = $plugId;
+ } else if (!in_array($plugId, self::$_pluginSuported) && config::byKey('sendToApp', $plugId, 0) == 1) {
+ $subClasses = config::byKey('subClass', $plugId, '');
+ if ($subClasses != '') {
+ $subClassesList = explode(';', $subClasses);
+ foreach ($subClassesList as $subClass) {
+ $return[] = $subClass;
+ }
+ }
+ $return[] = $plugId;
+ }
+ }
+ return $return;
+ }
+
+ public static function makeTemplateJson()
+ {
+ log::add(__CLASS__, 'debug', '┌──────────▶︎ makeTemplateJson ──────────────');
+ $pluginToSend = mobile::pluginToSend();
+ $discover_eqLogic = mobile::discovery_eqLogic($pluginToSend);
+ $sync_new = mobile::change_cmdAndeqLogic(mobile::discovery_cmd($pluginToSend, $discover_eqLogic), $discover_eqLogic);
+ $config = array(
+ 'url_internal' => network::getNetworkAccess('internal'),
+ 'url_external' => network::getNetworkAccess('external'),
+ );
+ $objectReturn = mobile::delete_object_eqlogic_null(mobile::discovery_object(), $sync_new['eqLogics']);
+ $data = array(
+ 'eqLogics' => $sync_new['eqLogics'],
+ 'cmds' => $sync_new['cmds'],
+ 'objects' => mobile::delete_object_eqlogic_null(mobile::discovery_object(), $sync_new['eqLogics']),
+ 'scenarios' => mobile::discovery_scenario(),
+ 'plans' => mobile::discovery_plan(),
+ 'summary' => mobile::discovery_summary(),
+ 'config' => $config,
+ );
+ $path = dirname(__FILE__) . '/../../data/mobile.json';
+ if (!file_exists(dirname(__FILE__) . '/../../data')) {
+ mkdir(dirname(__FILE__) . '/../../data');
+ }
+ if (file_exists(dirname(__FILE__) . '/../../data/mobile.json')) {
+ unlink(dirname(__FILE__) . '/../../data/mobile.json');
+ }
+ file_put_contents(dirname(__FILE__) . '/../../data/mobile.json', json_encode($data));
+ log::add(__CLASS__, 'debug', '| mobile.json > ' . json_encode($data));
+ $event_cmd = array();
+ foreach ($data['cmds'] as $cmd) {
+ $event_cmd[] = $cmd['id'];
+ }
+ cache::set('mobile::event', $event_cmd);
+ log::add(__CLASS__, 'debug', '| cache set mobile::event ─▶︎ ' . json_encode($event_cmd));
+ log::add(__CLASS__, 'debug', '└───────────────────────────────────────────');
+ }
+
+ public static function getTemplateJson()
+ {
+ if (!file_exists(dirname(__FILE__) . '/../../data/mobile.json')) {
+ self::makeTemplateJson();
+ }
+ return json_decode(cmd::cmdToValue(file_get_contents(dirname(__FILE__) . '/../../data/mobile.json')), true);
+ }
+
+ public static function makeSaveJson($mobileID, $_data = array(), $type = 'dashboard')
+ {
+ $path = dirname(__FILE__) . '/../../data/' . $mobileID . '/' . $type . '.json';
+ if (!file_exists(dirname(__FILE__) . '/../../data')) {
+ mkdir(dirname(__FILE__) . '/../../data');
+ }
+ if (!file_exists(dirname(__FILE__) . '/../../data/' . $mobileID)) {
+ mkdir(dirname(__FILE__) . '/../../data/' . $mobileID);
+ }
+ if (file_exists(dirname(__FILE__) . '/../../data/' . $mobileID . '/' . $type . '.json')) {
+ unlink(dirname(__FILE__) . '/../../data/' . $mobileID . '/' . $type . '.json');
+ }
+ file_put_contents(dirname(__FILE__) . '/../../data/' . $mobileID . '/' . $type . '.json', json_encode($_data));
+ }
+
+ public static function getSaveJson($mobileID, $type = 'dashboard')
+ {
+ if (!file_exists(dirname(__FILE__) . '/../../data/' . $mobileID . '/' . $type . '.json')) {
+ self::makeSaveJson($mobileID, array(), $type);
+ }
+ return json_decode(file_get_contents(dirname(__FILE__) . '/../../data/' . $mobileID . '/' . $type . '.json'), true);
+ }
+
+ public static function discovery_eqLogic($plugin = array(), $hash = null)
+ {
+ $return = array();
+ foreach ($plugin as $plugin_type) {
+ $eqLogics = eqLogic::byType($plugin_type, true);
+ if (!is_array($eqLogics)) {
+ continue;
+ }
+ foreach ($eqLogics as $eqLogic) {
+ if ($eqLogic->getEqType_name() != 'mobile') {
+ if ($eqLogic->getIsEnable() != 1) {
+ continue;
+ }
+ if ($eqLogic->getObject_id() == null) {
+ continue;
+ }
+ $objectNow = $eqLogic->getObject();
+ if (!is_object($objectNow)) {
+ continue;
+ }
+ if (($eqLogic->getIsVisible() != 1 && (!in_array($eqLogic->getEqType_name(), self::$_pluginWidget)) || $objectNow->getDisplay('sendToApp', 1) != 1)) {
+ continue;
+ }
+ }
+ $eqLogic_array = utils::o2a($eqLogic);
+ if ($eqLogic->getEqType_name() == 'mobile') {
+ if (isset($eqLogic_array["logicalId"])) {
+ $eqLogic_array["localApiKey"] = $eqLogic_array["logicalId"];
+ }
+ }
+ if (isset($eqLogic_array["configuration"]["localApiKey"])) {
+ $eqLogic_array["localApiKey"] = $eqLogic_array["configuration"]["localApiKey"];
+ }
+ if ($eqLogic_array['eqType_name'] == 'jeelink') {
+ if (isset($eqLogic_array['configuration']['real_eqType'])) {
+ $eqLogic_array['eqType_name'] = $eqLogic_array['configuration']['real_eqType'];
+ }
+ }
+ unset($eqLogic_array['eqReal_id'], $eqLogic_array['comment'], $eqLogic_array['configuration'], $eqLogic_array['specificCapatibilities'], $eqLogic_array['timeout'], $eqLogic_array['category'], $eqLogic_array['display']);
+ unset($eqLogic_array['status']);
+ unset($eqLogic_array['generic_type']);
+ unset($eqLogic_array['logicalId']);
+ unset($eqLogic_array['isVisible']);
+ unset($eqLogic_array['isEnable']);
+ if (!in_array($eqLogic_array['eqType_name'], self::$_pluginWidget)) {
+ unset($eqLogic_array['eqType_name']);
+ }
+ $return[] = $eqLogic_array;
+ }
+ }
+ return $return;
+ }
+
+ public static function discovery_cmd($plugin = array(), $eqLogics = null, $_withValue = false)
+ {
+ $return = array();
+ $genericisvisible = array();
+ foreach (jeedom::getConfiguration('cmd::generic_type') as $key => $info) {
+ if ($info['family'] !== 'Generic') {
+ $genericisvisible[] = $key;
+ }
+ }
+ if ($eqLogics == null) {
+ $eqLogics = self::discovery_eqLogic($plugin);
+ }
+ $eqLogics_id = array();
+ foreach ($eqLogics as $eqLogic) {
+ $eqLogics_id[] = $eqLogic['id'];
+ }
+ if (count($eqLogics_id) > 0) {
+ foreach (cmd::byEqLogicId($eqLogics_id, null, null, null, true) as $cmd) {
+ if (in_array($cmd->getGeneric_type(), ['GENERIC_ERROR', 'DONT'])) {
+ continue;
+ }
+ if (!isset($eqLogic['eqType_name'])) {
+ $eqLogic['eqType_name'] = '';
+ }
+ if ($cmd->getIsVisible() != 1 && !in_array($cmd->getGeneric_type(), $genericisvisible) && !in_array($eqLogic['eqType_name'], self::$_pluginWidget)) {
+ continue;
+ }
+ $info = $cmd->exportApi();
+ unset($info['isHistorized']);
+ unset($info['template']);
+ unset($info['html']);
+ unset($info['alert']);
+ unset($info['isVisible']);
+ unset($info['logicalId']);
+ unset($info['eqType']);
+ unset($info['order']);
+ $info['configuration'] = array();
+ $info['configuration']['actionCodeAccess'] = $cmd->getConfiguration('actionCodeAccess');
+ $info['configuration']['actionConfirm'] = $cmd->getConfiguration('actionConfirm');
+ $info['configuration']['maxValue'] = $cmd->getConfiguration('maxValue');
+ $info['configuration']['minValue'] = $cmd->getConfiguration('minValue');
+ $info['display'] = array();
+ $info['display']['invertBinary'] = $cmd->getDisplay('invertBinary');
+ $info['display']['icon'] = $cmd->getDisplay('icon');
+ $info['display']['title_disable'] = $cmd->getDisplay('title_disable');
+ $info['display']['title_placeholder'] = $cmd->getDisplay('title_placeholder');
+ $info['display']['message_placeholder'] = $cmd->getDisplay('message_placeholder');
+ if (!in_array($cmd->getGeneric_type(), ['GENERIC_INFO', 'GENERIC_ACTION', 'HEATING_ON', 'HEATING_OTHER', 'MODE_SET_STATE']) && isset($info['display']['icon'])) {
+ unset($info['display']['icon']);
+ }
+ if (isset($info['display']['icon'])) {
+ $info['display']['icon'] = str_replace(array(''), '', $info['display']['icon']);
+ if (strstr($info['display']['icon'], ' icon_')) {
+ $info['display']['icon'] = strstr($info['display']['icon'], ' icon_', true);
+ }
+ }
+ foreach ($info['display'] as $key => $value) {
+ if (trim($value) == '') {
+ unset($info['display'][$key]);
+ }
+ }
+ if (count($info['display']) == 0) {
+ unset($info['display']);
+ }
+ foreach ($info['configuration'] as $key => $value) {
+ if (trim($value) == '') {
+ unset($info['configuration'][$key]);
+ }
+ }
+ if (count($info['configuration']) == 0) {
+ unset($info['configuration']);
+ }
+ if ($info['type'] == 'action') {
+ unset($info['currentValue']);
+ } else if (!$_withValue) {
+ $info['currentValue'] = '#' . $info['id'] . '#';
+ }
+ if ($info['value'] == null) {
+ unset($info['value']);
+ }
+ if ($info['unite'] == '') {
+ unset($info['unite']);
+ }
+ $return[] = $info;
+ }
+ }
+ return $return;
+ }
+
+ public static function discovery_multi($cmds)
+ {
+ $array_final = array();
+ $tableData = self::$_pluginMulti;
+ foreach ($cmds as $cmd) {
+ if (in_array($cmd['generic_type'], $tableData)) {
+ $result = array_intersect(
+ array_keys(array_column($cmds, 'eqLogic_id'), $cmd['eqLogic_id']),
+ array_keys(array_column($cmds, 'generic_type'), $cmd['generic_type'])
+ );
+ if (count($result) > 1) {
+ $array_final = array_merge_recursive($array_final, $result);
+ }
+ }
+ }
+ $dif = array();
+ $array_cmd_multi = array();
+ foreach ($array_final as $array_fi) {
+ if (!in_array($array_fi, $dif)) {
+ array_push($dif, $array_fi);
+ array_push($array_cmd_multi, $array_fi);
+ }
+ }
+ return $array_cmd_multi;
+ }
+
+ public static function change_cmdAndeqLogic($_cmds, $_eqLogics)
+ {
+ $findEqLogic = array();
+ foreach ($_cmds as $cmd) {
+ $findEqLogic[$cmd['eqLogic_id']] = $cmd['eqLogic_id'];
+ }
+ $eqLogics = array();
+ foreach ($_eqLogics as $eqLogic) {
+ if (!isset($findEqLogic[$eqLogic['id']])) {
+ continue;
+ }
+ $eqLogics[] = $eqLogic;
+ }
+ $plage_cmds = mobile::discovery_multi($_cmds);
+ if (count($plage_cmds) == 0) {
+ return array('cmds' => $_cmds, 'eqLogics' => $eqLogics);
+ }
+ $eqLogic_array = array();
+ foreach ($plage_cmds as $plage_cmd) {
+ $eqLogic_id = $_cmds[$plage_cmd]['eqLogic_id'];
+ $name_cmd = $_cmds[$plage_cmd]['name'];
+ foreach ($eqLogics as $eqLogic) {
+ if ($eqLogic['id'] == $eqLogic_id) {
+ $eqLogic_name = $eqLogic['name'] . ' / ' . $name_cmd;
+ }
+ }
+ $id = $_cmds[$plage_cmd]['id'];
+ $new_eqLogic_id = '999' . $eqLogic_id . '' . $id;
+ $_cmds[$plage_cmd]['eqLogic_id'] = $new_eqLogic_id;
+ $keys = array_keys(array_column($_cmds, 'eqLogic_id'), $eqLogic_id);
+ foreach ($keys as $key) {
+ if (isset($_cmds[$key]['value']) && $_cmds[$key]['value'] == $_cmds[$plage_cmd]['id'] && $_cmds[$key]['type'] == 'action') {
+ $_cmds[$key]['eqLogic_id'] = $new_eqLogic_id;
+ }
+ }
+ $eqLogic_array[] = array($eqLogic_id, $new_eqLogic_id, $eqLogic_name);
+ //$i++;
+ }
+ $column_eqlogic = array_column($eqLogics, 'id');
+ foreach ($eqLogic_array as $eqlogic_array_one) {
+ $keys = array_keys($column_eqlogic, $eqlogic_array_one[0]);
+ $new_eqLogic = $eqLogics[$keys[0]];
+ $new_eqLogic['id'] = $eqlogic_array_one[1];
+ $new_eqLogic['name'] = $eqlogic_array_one[2];
+ $eqLogics[] = $new_eqLogic;
+ }
+ return array('cmds' => $_cmds, 'eqLogics' => $eqLogics);
+ }
+
+ public static function discovery_object()
+ {
+ $all = utils::o2a(jeeObject::all());
+ $return = array();
+ foreach ($all as $object) {
+ if (isset($object['display']['sendToApp']) && $object['display']['sendToApp'] == "0") {
+ continue;
+ }
+ unset($object['configuration']);
+ unset($object['display']['tagColor']);
+ unset($object['display']['tagTextColor']);
+ unset($object['display']['desktop::summaryTextColor']);
+ unset($object['display']['dashboard::size']);
+ unset($object['display']['summaryTextColor']);
+ unset($object['image']);
+ unset($object['img']);
+ unset($object['father_id']);
+ if (isset($object['display']['icon'])) {
+ if ($object['display']['icon'] == '') {
+ unset($object['display']['icon']);
+ } else {
+ $object['display']['icon'] = str_replace(array(''), '', $object['display']['icon']);
+ $tableEx = array();
+ $explodes = explode(' ', $object['display']['icon']);
+ foreach ($explodes as $explode) {
+ if (substr($explode, 0, 5) != 'icon_') {
+ $tableEx[] = $explode;
+ }
+ }
+ $object['display']['icon'] = implode(' ', $tableEx);
+ }
+ }
+ $return[] = $object;
+ }
+ return $return;
+ }
+
+ public static function discovery_scenario()
+ {
+ $all = utils::o2a(scenario::all());
+ $return = array();
+ foreach ($all as &$scenario) {
+ if (isset($scenario['display']['sendToApp']) && $scenario['display']['sendToApp'] == "0") {
+ continue;
+ }
+ if (!isset($scenario['display']['sendToApp'])) {
+ continue;
+ }
+ if ($scenario['display']['name'] != '') {
+ $scenario['name'] = $scenario['display']['name'];
+ }
+ if (isset($scenario['display'])) {
+ unset($scenario['display']);
+ }
+ unset($scenario['mode'], $scenario['schedule'], $scenario['scenarioElement'], $scenario['trigger'], $scenario['timeout'], $scenario['description'], $scenario['configuration'], $scenario['type'], $scenario['display']['name']);
+ $return[] = $scenario;
+ }
+ return $return;
+ }
+
+ public static function discovery_message()
+ {
+ //return utils::o2a(message::all());
+ return array();
+ }
+
+ public static function discovery_plan()
+ {
+ $plans = utils::o2a(planHeader::all());
+ foreach ($plans as &$plan) {
+ if (isset($plan['image'])) {
+ unset($plan['image']);
+ }
+ if (isset($plan['configuration'])) {
+ if (!isset($plan['configuration']['simee'])) {
+ unset($plan['configuration']);
+ }
+ }
}
+ return $plans;
}
+ public static function discovery_summary()
+ {
+ $return = array();
+ $def = config::byKey('object:summary');
+ foreach ($def as $key => &$value) {
+ //$value['value'] = jeeObject::getGlobalSummary($key);
+ if (isset($value['icon'])) {
+ if ($value['icon'] == '') {
+ unset($value['icon']);
+ } else {
+ $value['icon'] = str_replace(array(''), '', $value['icon']);
+ $tableEx = array();
+ $explodes = explode(' ', $value['icon']);
+ foreach ($explodes as $explode) {
+ if (substr($explode, 0, 5) != 'icon_') {
+ $tableEx[] = $explode;
+ }
+ }
+ $value['icon'] = implode(' ', $tableEx);
+ }
+ }
+ }
+ return $def;
+ }
+
+ public static function discovery_summaryValue($jeeObjectEnvoi)
+ {
+ $def = config::byKey('object:summary');
+ $tableKey = array();
+ foreach ($def as $key => $value) {
+ $tableKey[] = $key;
+ }
+ $table = array();
+ foreach ($jeeObjectEnvoi as $jeeobject) {
+ $object = jeeObject::byId($jeeobject['id']);
+ if (is_object($object)) {
+ foreach ($tableKey as $key) {
+ if ($object->getSummary($key) != null) {
+ $tableObject = array();
+ $tableObject['object_id'] = $object->getId();
+ $tableObject['key'] = $key;
+ $tableObject['value'] = $object->getSummary($key);
+ $table[] = $tableObject;
+ }
+ }
+ }
+ }
+ foreach ($tableKey as $key) {
+ if (jeeObject::getGlobalSummary($key) != null) {
+ $tableObject = array();
+ $tableObject['object_id'] = 'global';
+ $tableObject['key'] = $key;
+ $tableObject['value'] = jeeObject::getGlobalSummary($key);
+ $table[] = $tableObject;
+ }
+ }
+
+ return $table;
+ }
+
+ public static function delete_object_eqlogic_null($objects, $eqLogics)
+ {
+ $return = array();
+ $object_id = array();
+ foreach ($eqLogics as $eqLogic) {
+ $object_id[$eqLogic['object_id']] = $eqLogic['object_id'];
+ }
+ foreach ($objects as $object) {
+ if (!isset($object_id[$object['id']])) {
+ continue;
+ }
+ $return[] = $object;
+ }
+ return $return;
+ }
+
+ /************************************************************/
+ /******************** APP V1 && V2 *************************/
+ /************************************************************/
+
/**
* get json for notification
* Call by class notification
@@ -91,8 +609,8 @@ public static function whoIsIq($iq)
public static function jsonPublish($os, $titre, $message, $type, $idNotif, $answer, $timeout, $token, $photo, $version, $optionsNotif = [], $critical = false, $Iq = null, $specific = false, $silent = false)
{
log::add('mobile', 'debug', '||┌──:fg-success: jsonPublish :/fg:──');
- log::add('mobile', 'debug', '||┌──:fg-success: PARAMS :/fg:──'.$silent);
- if (isset($Iq)) log::add('mobile', 'debug', '||| IQ for jsonPublish > ' . $Iq);
+ if ($silent) log::add('mobile', 'debug', '||| Silent notification');
+ if (isset($Iq)) log::add('mobile', 'debug', '||| IQ for jsonPublish ─▶︎ ' . $Iq);
$dateNotif = date("Y-m-d H:i:s");
$newDate = date("Y-m-d");
@@ -121,6 +639,7 @@ public static function jsonPublish($os, $titre, $message, $type, $idNotif, $answ
}
} else {
if ($version == 2) {
+ //App V2
if ($addAsk != '') {
$askParams = [
'choices' => $answer,
@@ -142,25 +661,7 @@ public static function jsonPublish($os, $titre, $message, $type, $idNotif, $answ
if ($os == 'android' && $critical == true) {
$channelId = "critical";
}
- if ($critical == true) {
- $criticalString = 'true';
- } else {
- $criticalString = 'false';
- }
- // $customData = [
- // 'title' => $titre,
- // 'body' => $message,
- // 'idNotif' => strval($idNotif),
- // 'channelId' => $channelId,
- // 'date' => $dateNotif,
- // 'critical' => $criticalString,
- // 'boxName' => $defaultName,
- // 'boxApiKey' => jeedom::getHardwareKey(),
- // "askParams" => $askParams,
- // 'textToDisplay' => 'none',
- // 'newDate' => $newDate,
- // 'horaireFormat' => $horaireFormat
- // ];
+ $criticalString = ($critical == true) ? 'true' : 'false';
$customData = [
'title' => $titre,
'body' => $message,
@@ -174,7 +675,7 @@ public static function jsonPublish($os, $titre, $message, $type, $idNotif, $answ
'textToDisplay' => 'none',
'newDate' => $newDate,
'horaireFormat' => $horaireFormat,
- 'silent' => $silent ? 'true' : 'false'
+ 'silent' => $silent ? 'true' : 'false'
];
$notification = [
@@ -200,6 +701,7 @@ public static function jsonPublish($os, $titre, $message, $type, $idNotif, $answ
'aps' => array_merge([
'content-available' => true,
], $silent ? [] : [
+ 'mutable-content' => 1,
'sound' => [
'name' => 'default',
'critical' => $critical
@@ -222,8 +724,6 @@ public static function jsonPublish($os, $titre, $message, $type, $idNotif, $answ
]
]
];
-
-
if ($photo != null) {
$data['image'] = $photo;
@@ -255,9 +755,8 @@ public static function jsonPublish($os, $titre, $message, $type, $idNotif, $answ
'data' => $data,
];
-
if (isset($Iq) && !$specific) {
- // SAVE NOTIFS IN JSON
+ // SAVE NOTIFS IN FILE
$pathNotificationData = '/../data/notifications';
if (!is_dir(dirname(__FILE__) . $pathNotificationData)) {
mkdir(dirname(__FILE__) . $pathNotificationData, 0775, true);
@@ -278,20 +777,59 @@ public static function jsonPublish($os, $titre, $message, $type, $idNotif, $answ
if (isset($notification['data']['askParams'])) {
$askParams = json_decode($notification['data']['askParams'], true);
if ($askParams !== null && isset($askParams['timeout'])) {
- //log::add('mobile', 'debug', 'Timeout Ask remis à zero');
$askParams['timeout'] = 0;
$notification['data']['askParams'] = json_encode($askParams);
}
}
}
$notifications[$idNotif] = $publishJson;
- log::add('mobile', 'debug', '||| [INFO] Notification enregistrée : ' . json_encode($notifications));
+ log::add('mobile', 'debug', '||| [INFO] Notification logged ─▶︎ ' . json_encode($notifications));
file_put_contents($filePath, json_encode($notifications));
}
+ } else {
+ // APP V1
+ if ($os == 'android' && $version == 1) {
+ $android = [
+ 'notification' => [
+ 'title' => $titre,
+ 'body' => $message,
+ 'channel_id' => 'default',
+ 'color' => '#0000FF'
+ ]
+ ];
+
+ $data = [
+ 'title' => $titre,
+ 'text' => $message,
+ 'idNotif' => strval($idNotif),
+ 'channelId' => 'default',
+ 'date' => $dateNotif
+ ];
+
+ if ($photo != null) {
+ $notification = [
+ 'title' => $titre,
+ 'body' => $message,
+ 'image' => $photo
+ ];
+ } else {
+ $notification = [
+ 'title' => $titre,
+ 'body' => $message
+ ];
+ }
+
+ $publish = [
+ 'token' => $token,
+ 'notification' => $notification,
+ 'android' => $android,
+ 'data' => $data
+ ];
+ }
}
}
- log::add('mobile', 'debug', '||| [INFO] JSON publish > ' . json_encode($publish));
- log::add('mobile', 'debug', '||└────────────────────');
+ log::add('mobile', 'debug', '||| [INFO] JSON publish ─▶︎ ' . json_encode($publish));
+ log::add('mobile', 'debug', '||└─────────────────');
return $publish;
}
@@ -302,70 +840,115 @@ public static function jsonPublish($os, $titre, $message, $type, $idNotif, $answ
*/
public static function notification($arn, $os, $titre, $message, $type, $idNotif, $answer, $timeout, $token, $photo, $version = 1, $optionsNotif = [], $critical = false, $Iq = null, $specific = false, $silent = false)
{
- log::add('mobile', 'debug', '|┌──:fg-success: Notification en cours ! :/fg:──');
- if ($version == 2) {
- $publish = mobile::jsonPublish($os, $titre, $message, $type, $idNotif, $answer, $timeout, $token, $photo, $version, $optionsNotif, $critical, $Iq, $specific, $silent);
- if ($token != null) {
- if ($token == 'notifsBGDisabled') {
- log::add('mobile', 'debug', '|| [ERROR] NOTIFICATION NON ENVOYEE : LE SERVICE NOTIF EST DESACTIVE SUR LE TELEPHONE');
- message::add(__CLASS__, 'Échec de l\'envoie de notification : le service est désactivé dans les paramètres du téléphone', 'notifsbgSend', 'alertNotifsSend');
- return;
- }
- if ($token == 'desactivate') {
- log::add('mobile', 'debug', '|| [ERROR] NOTIFICATION NON ENVOYEE : LES NOTIFICATIONS SONT DESACTIVEES DANS L\'APP : ');
- message::add(__CLASS__, 'Échec de l\'envoie de notification : le service est désactivé dans les paramètres de l\'application', 'notifsbgSend', 'alertNotifsSend');
- return;
- }
- $url = config::byKey('service::cloud::url', 'core', 'https://cloud.jeedom.com') . '/service/fcm';
- $options = [
- 'contentAvailable' => true,
- 'mutableContent' => true,
- 'priority' => 'high',
- 'collapseKey' => strval($publish['data']['idNotif'])
- ];
-
- $post = ['message' => $publish, 'options' => $options];
- log::add('mobile', 'debug', '|| [INFO] JSON envoyé en mode FCM > ' . json_encode($post));
- } elseif ($token == null && $version == 2) {
- log::add('mobile', 'debug', '|| [ERROR] NOTIFICATION NON ENVOYEE : PAS DE TOKEN ENREGISTRE SUR LE TELEPHONE : ');
- //message::removeAll(__CLASS__, 'noValidToken');
- message::add(__CLASS__, '| NOTIFICATION NON ENVOYÉE : PAS DE TOKEN ENREGISTRE SUR LE TÉLÉPHONE :', 'noValidTok', 'noValidToken');
+ log::add('mobile', 'debug', '|┌──:fg-success: notification :/fg:──');
+ //if ($version == 2) {
+ $publish = mobile::jsonPublish($os, $titre, $message, $type, $idNotif, $answer, $timeout, $token, $photo, $version, $optionsNotif, $critical, $Iq, $specific, $silent);
+ if ($token != null) {
+ if ($token == 'notifsBGDisabled') {
+ log::add('mobile', 'debug', '|| [ERROR] NOTIFICATION NOT SENT ─▶︎ The notification service is disabled on the phone.');
+ message::add(__CLASS__, __('Echec de l\'envoi de la notification', __FILE__) . ' ─▶︎ ' . __('le service est désactivé dans les paramètres du téléphone', __FILE__), 'notifsbgSend', 'alertNotifsSend');
return;
- } else {
- log::add('mobile', 'debug', '|| [INFO] JSON envoyé : APN' . $publish);
- $post = [
- 'arn' => $arn,
- 'text' => $publish,
- ];
- $url = config::byKey('service::cloud::url', 'core', 'https://cloud.jeedom.com') . '/service/notif';
}
+ if ($token == 'desactivate') {
+ log::add('mobile', 'debug', '|| [ERROR] NOTIFICATION NOT SENT ─▶︎ The notification service is disabled on the application.');
+ message::add(__CLASS__, __('Echec de l\'envoi de la notification', __FILE__) . ' ─▶︎ ' . __('le service est désactivé dans les paramètres de l\'application', __FILE__), 'notifsbgSend', 'alertNotifsSend');
+ return;
+ }
+ $url = config::byKey('service::cloud::url', 'core', 'https://cloud.jeedom.com') . '/service/fcm';
+ $options = [
+ 'contentAvailable' => true,
+ 'mutableContent' => true,
+ 'priority' => 'high',
+ 'collapseKey' => strval($publish['data']['idNotif'])
+ ];
+
+ $post = ['message' => $publish, 'options' => $options];
+ log::add('mobile', 'debug', '|| [INFO] JSON sent in FCM mode ─▶︎ ' . json_encode($post));
+ } elseif ($token == null && $version == 2) {
+ log::add('mobile', 'debug', '|| [ERROR] NOTIFICATION NOT SENT ─▶︎ No token registered on the phone');
+ message::add(__CLASS__, __('Echec de l\'envoi de la notification', __FILE__) . ' ─▶︎ ' . __('pas de token enregistré sur le téléphone', __FILE__), 'noValidTok', 'noValidToken');
+ return;
+ } else {
+ log::add('mobile', 'debug', '|| [INFO] JSON sent in APN mode ─▶︎ ' . $publish);
+ $post = [
+ 'arn' => $arn,
+ 'text' => $publish,
+ ];
+ $url = config::byKey('service::cloud::url', 'core', 'https://cloud.jeedom.com') . '/service/notif';
+ }
- $request_http = new com_http($url);
- $request_http->setHeader(array(
- 'Content-Type: application/json',
- 'Autorization: ' . sha512(strtolower(config::byKey('market::username')) . ':' . config::byKey('market::password'))
- ));
- //$request_http->setLogError(true);
- $request_http->setPost(json_encode($post));
+ $request_http = new com_http($url);
+ $request_http->setHeader(array(
+ 'Content-Type: application/json',
+ 'Autorization: ' . sha512(strtolower(config::byKey('market::username')) . ':' . config::byKey('market::password'))
+ ));
+ //$request_http->setLogError(true);
+ $request_http->setPost(json_encode($post));
+ $result = json_decode($request_http->exec(30, 3), true);
+ if (!isset($result['state']) || $result['state'] != 'ok') {
+ log::add('mobile', 'debug', '|| [WARNING] First attempt to send notification failed.');
+ log::add('mobile', 'debug', '|| New attempt ....');
+ sleep(rand(1, 10));
$result = json_decode($request_http->exec(30, 3), true);
- if (!isset($result['state']) || $result['state'] != 'ok') {
- log::add('mobile', 'info', '|| [WARNING] Echec Première Tentative d\'envoi de la notification');
- log::add('mobile', 'info', '|| Nouvelle tentative ....');
- sleep(rand(1, 10));
- $result = json_decode($request_http->exec(30, 3), true);
+ }
+ if (!isset($result['state']) || $result['state'] != 'ok') {
+ if (isset($result['error']) && strpos($result['error'], 'Quotas exceeded') !== false) {
+ log::add('mobile', 'error', __("Les quotas pour fcm sont dépassés. Le maximum autorisé est de 5 requêtes par minute.", __FILE__));
+ log::add('mobile', 'debug', __('Echec de l\'envoi de la notification', __FILE__) . ' ─▶︎ ' . json_encode($result));
+ } else {
+ throw new Exception(__('Echec de l\'envoi de la notification', __FILE__) . ' ─▶︎ ' . json_encode($result));
}
- if (!isset($result['state']) || $result['state'] != 'ok') {
- if (isset($result['error']) && strpos($result['error'], 'Quotas exceeded') !== false) {
- log::add('mobile', 'error', __("Les quotas pour fcm sont dépassés. Le maximum autorisé est de 5 requêtes par minute.", __FILE__));
- log::add('mobile', 'debug', __('Echec de l\'envoi de la notification :', __FILE__) . json_encode($result));
- } else {
- throw new Exception(__('Echec de l\'envoi de la notification :', __FILE__) . json_encode($result));
- }
+ }
+ //} else {
+ //log::add('mobile', 'error', __('Echec de l\'envoi de la notification', __FILE__) . ' ─▶︎ ' . __('la version 1 de l\'app n\'est plus prise en charge', __FILE__));
+ //}
+ log::add('mobile', 'debug', '|└─────────────────────────────');
+ }
+
+ /*****************************************************/
+ /******************** APP V2 *************************/
+ /*****************************************************/
+
+ /**
+ * Get all notifications from Iq
+ * Call by ajax getNotificationsV2
+ * @return array
+ */
+ public static function getNotificationsV2($Iq)
+ {
+ $return = __('Aucune notification.', __FILE__);
+ $filePath = dirname(__FILE__) . '/../data/notifications/' . $Iq . '.json';
+ if (file_exists($filePath)) {
+ $notifs = json_decode(file_get_contents($filePath), true);
+ if (is_array($notifs) && count($notifs) > 0) $return = json_encode(array_reverse($notifs));
+ }
+ return $return;
+ }
+
+ /**
+ * remove notification from Id into filepath id
+ * Call by ajax removeNotificationV2
+ */
+ public static function removeNotificationV2($_iq, $_id)
+ {
+ $pathNotificationData = '/../data/notifications';
+ $filePath = dirname(__FILE__) . $pathNotificationData . '/' . $_iq . '.json';
+ if (file_exists($filePath)) {
+ $notificationsContent = file_get_contents($filePath);
+ $notifications = json_decode($notificationsContent, true);
+ if ($notifications === null) {
+ throw new Exception(__('Fichier de notification vide.', __FILE__));
+ }
+ if (isset($notifications[$_id])) {
+ unset($notifications[$_id]);
+ file_put_contents($filePath, json_encode($notifications));
+ return count($notifications);
+ } else {
+ throw new Exception(__('Id notification inexistant', __FILE__) . ' ─▶︎ ' . $_id);
}
} else {
- log::add('mobile', 'error', __("Échec de l'envoi de notification : la version 1 de l'app n'est plus prise en charge !", __FILE__));
+ throw new Exception(__('Fichier de notifications inexistant', __FILE__) . ' ─▶︎ ' . $filePath);
}
- log::add('mobile', 'debug', '|└────────────────────');
}
/**
@@ -374,26 +957,26 @@ public static function notification($arn, $os, $titre, $message, $type, $idNotif
*/
public static function createCmdGeoLocV2($Iq, $geolocs)
{
- log::add('mobile', 'debug', '|┌──:fg-success: GeoLocV2 :/fg:──');
+ log::add('mobile', 'debug', '|┌──:fg-success: createCmdGeoLocV2 :/fg:──');
$mobile = eqLogic::byLogicalId($Iq, 'mobile');
if (is_object($mobile)) {
- log::add('mobile', 'debug', '|| OK Mobile existant > ' . $mobile->getName());
- log::add('mobile', 'debug', '|| [INFO] GEOLOCS > ' . $geolocs);
-
+ log::add('mobile', 'debug', '|| OK Mobile found ─▶︎ ' . $mobile->getName());
+ log::add('mobile', 'debug', '|| [INFO] GEOLOCS ─▶︎ ' . $geolocs);
$order = count($mobile->getCmd());
- $noExistCmd = 0;
$decodedGeolocs = json_decode($geolocs, true);
foreach ($decodedGeolocs as $index => $geoloc) {
if (!isset($geoloc['name'])) continue;
- log::add('mobile', 'debug', '|| geoloc_' . $index . ' > ' . $geoloc['name']);
- $cmd = cmd::byEqLogicIdAndLogicalId($mobile->getId(), 'geoloc_' . $index);
$logicalId = 'geoloc_' . $index;
+ log::add('mobile', 'debug', '|| ' . $logicalId . ' ─▶︎ ' . $geoloc['name'] . ' ─▶︎ ' . $geoloc['value']);
+ $cmd = cmd::byEqLogicIdAndLogicalId($mobile->getId(), 'geoloc_' . $index);
if (!is_object($cmd)) {
if (!preg_match('/^geoloc_\d+$/', $logicalId)) {
foreach ($mobile->getCmd() as $existing) {
- if (preg_match('/^geoloc_\d+$/', $existing->getLogicalId())
- && $existing->getName() === $geoloc['name']) {
- log::add('mobile', 'debug', '|| Migration UUID : renommage ' . $existing->getLogicalId() . ' -> ' . $logicalId);
+ if (
+ preg_match('/^geoloc_\d+$/', $existing->getLogicalId())
+ && $existing->getName() === $geoloc['name']
+ ) {
+ log::add('mobile', 'debug', '|| ↳ Migrate UUID ─▶︎ renaming ' . $existing->getLogicalId() . ' to ' . $logicalId);
$existing->setLogicalId($logicalId);
$existing->save();
$cmd = $existing;
@@ -403,7 +986,6 @@ public static function createCmdGeoLocV2($Iq, $geolocs)
}
}
if (!is_object($cmd)) {
- $noExistCmd = 1;
$cmd = new mobileCmd();
$cmd->setLogicalId($logicalId);
$cmd->setEqLogic_id($mobile->getId());
@@ -416,7 +998,7 @@ public static function createCmdGeoLocV2($Iq, $geolocs)
$cmd->setIsHistorized(1);
$cmd->setOrder($order);
$order++;
- log::add('mobile', 'debug', '|| Ajout geofencing > ' . $geoloc['name']);
+ log::add('mobile', 'debug', '|| ↳ Adding geofence point ─▶︎ ' . $geoloc['name']);
}
$cmd->setName($geoloc['name']);
$cmd->setType('info');
@@ -425,16 +1007,14 @@ public static function createCmdGeoLocV2($Iq, $geolocs)
$cmd->setConfiguration('longitude', $geoloc['longitude']);
$cmd->setConfiguration('radius', $geoloc['radius']);
if ($cmd->getChanged() === true) $cmd->save();
- if ($noExistCmd == 1) {
- $mobile->checkAndUpdateCmd($logicalId, $geoloc['value']);
- log::add('mobile', 'debug', '|| Valeur enregistrée > ' . $geoloc['value']);
+ if ($mobile->checkAndUpdateCmd($logicalId, $geoloc['value'])) {
+ log::add('mobile', 'debug', '|| ↳ Update geofence point ─▶︎ ' . $geoloc['value']);
}
- $noExistCmd = 0;
}
} else {
- log::add('mobile', 'debug', '| [ERROR] Mobile inexistant !');
+ log::add('mobile', 'debug', '| [WARNING] Mobile not detected !');
}
- log::add('mobile', 'debug', '|└────────────────────');
+ log::add('mobile', 'debug', '|└──────────────');
}
/**
@@ -486,20 +1066,18 @@ public static function handleMenuDefaultBySelect($eqId, $eqDefault)
log::add('mobile', 'debug', '┌──:fg-success: handleMenuDefaultBySelect( ' . $eqId . ', ' . $eqDefault . ') :/fg:──');
// ATTRIBUTION D'UN MENU AU MOBILE
if ($eqDefault == 'default') { //reset menuCustom
- log::add('mobile', 'debug', '| menu souce : default');
+ log::add('mobile', 'debug', '| source menu ─▶︎ default');
$menuCustomArray = mobile::getMenuDefaultV2();
$mobile->setConfiguration('menuCustomArray', $menuCustomArray);
$mobile->setConfiguration('nbIcones', 3);
$mobile->setConfiguration('defaultIdMobile', 'default');
$mobile->save();
} else if (is_object($mobileDefault = eqLogic::byId($eqDefault, 'mobile'))) {
- log::add('mobile', 'debug', '| menu souce : ' . $mobileDefault->getHumanName());
// ATTRIBUTION DU MENU DUN AUTRE MOBILE
+ log::add('mobile', 'debug', '| source menu ─▶︎ ' . $mobileDefault->getHumanName());
$mobile->setConfiguration('defaultIdMobile', $eqDefault);
if ($mobile->getId() == $mobileDefault->getId()) {
- log::add('mobile', 'debug', '| souce et cible identique ');
- //$mobile->save();
- //return;
+ log::add('mobile', 'debug', '| same source and target');
}
$nbIcones = $mobileDefault->getConfiguration('nbIcones', 3);
$menuCustomArray = $mobileDefault->getConfiguration('menuCustomArray');
@@ -517,23 +1095,19 @@ public static function handleMenuDefaultBySelect($eqId, $eqDefault)
public static function generateTabIcon($menuCustomArray, $i)
{
$result = array();
-
$tabIconName = isset($menuCustomArray[$i]['spanIcon']) ? $menuCustomArray[$i]['spanIcon'] : 'none';
if ($tabIconName != 'none') {
$arrayIcon = explode(' ', $tabIconName);
$tabIconName = substr(strstr($arrayIcon[1], '-'), 1);
$tabLibName = strstr($arrayIcon[1], '-', true);
- if ($tabLibName == 'mdi') {
- $tabLibName = 'Mdi';
- }
+ if ($tabLibName == 'mdi') $tabLibName = 'Mdi';
} else {
$tabIconName = 'in';
$tabLibName = 'jeedomapp';
}
$tabRenameInput = (isset($menuCustomArray[$i]['renameIcon']) && $menuCustomArray[$i]['renameIcon'] != 'none') ? $menuCustomArray[$i]['renameIcon'] : 'Accueil';
-
$result['tabIconName'] = $tabIconName;
$result['tabLibName'] = $tabLibName;
$result['tabRenameInput'] = $tabRenameInput;
@@ -663,22 +1237,22 @@ public static function cmdForApi($Iq, $logicalId, $value, $name = "", $subtype =
*/
public function configMenuCustom()
{
- log::add('mobile', 'debug', '|┌──:fg-success: CONFIGMENU CUSTOM JEEDOM ' . jeedom::version() . ' :/fg:──');
+ log::add('mobile', 'debug', '|┌──:fg-success: configMenuCustom (' . jeedom::version() . ') :/fg:──');
$menuCustomArray = mobile::getMenuDefaultV2();
$pluginPanelMobile = config::byKey('pluginPanelMobile', 'mobile');
$defaultIdMobile = $this->getConfiguration('defaultIdMobile');
if ($defaultIdMobile == 'default') {
- log::add('mobile', 'debug', '|| [WARNING] Envoi menu par défaut');
+ log::add('mobile', 'debug', '|| [WARNING] Send default menu');
$this->setConfiguration('menuCustomArray', $menuCustomArray);
$this->save();
} else if (is_object($eqDefault = eqLogic::byId($defaultIdMobile)) && $this->getId() != $defaultIdMobile) {
- log::add('mobile', 'debug', '|| [WARNING] Envoi menu de ' . $eqDefault->getHumanName());
+ log::add('mobile', 'debug', '|| [WARNING] source menu ─▶︎ ' . $eqDefault->getHumanName());
$menuCustomArray = $eqDefault->getConfiguration('menuCustomArray');
$this->setConfiguration('menuCustomArray', $menuCustomArray);
$this->save();
} else {
- log::add('mobile', 'debug', '|| [INFO] Envoi menu de ' . $this->getHumanName());
+ log::add('mobile', 'debug', '|| [INFO] source menu ─▶︎ ' . $this->getHumanName());
$menuCustomArray = $this->getConfiguration('menuCustomArray');
}
if (empty($menuCustomArray)) {
@@ -705,14 +1279,8 @@ public function configMenuCustom()
$tabIconName = $resultTabIcon['tabIconName'];
$tabLibName = $resultTabIcon['tabLibName'];
$tabRenameInput = $resultTabIcon['tabRenameInput'];
- //$objectId = $menuCustomArray[$i]['selectNameMenu'];
- //$objectId = isset($menuCustomArray[$i]['selectNameMenu']) ? $menuCustomArray[$i]['selectNameMenu'] : '';
$isActive = true;
- //$webviewUrl = 'd';
- //if (!empty($objectId)) log::add('mobile', 'debug', '|| - objectId > ' . $objectId);
-
- // GENERATE URLS FOR MENU CUSTOM
- //$result = self::generateTypeObject($objectId, $i, $webviewUrl, $pluginPanelMobile);
+ // GENERATE URLS FOR MENU CUSTOM
$result = self::generateTypeObject($pluginPanelMobile, isset($menuCustomArray[$i]) ? $menuCustomArray[$i] : '');
$typeObject = $result['typeObject'];
$typewebviewurl = $result['typewebviewurl'];
@@ -742,7 +1310,7 @@ public function configMenuCustom()
$j++;
$count++;
}
- log::add('mobile', 'debug', '|| [INFO] arrayElements > ' . json_encode($arrayElements));
+ log::add('mobile', 'debug', '|| [INFO] arrayElements ─▶︎ ' . json_encode($arrayElements));
log::add('mobile', 'debug', '|└────────────────────');
return $arrayElements;
}
@@ -829,93 +1397,143 @@ public static function getQrCodeV2($userId)
*/
public function cmdForSpecificChannel($params = array(), $_trigger = 'location')
{
- if (isset($params['Iq'])) {
- if (isset($params[$_trigger])) {
- $order = count($this->getCmd());
+ log::add('mobile', 'debug', '|┌──:fg-success: cmdForSpecificChannel :/fg:──');
+ if (isset($params[$_trigger])) {
+ $order = count($this->getCmd());
+ $getDeviceInformations = (isset($params[$_trigger]['extras']) && isset($params[$_trigger]['extras']['method']) && $params[$_trigger]['extras']['method'] == 'getDeviceInformations');
+ $eventAge = time() - intval(strtotime($params[$_trigger]['timestamp']));
+ if ($eventAge > 1800) {
+ log::add('mobile', 'debug', '|| SKIP stale specific event (' . round($eventAge / 60) . 'min) ');
+ } else {
+ log::add('mobile', 'debug', '|| eventAge = ' . $eventAge . ' s');
// Battery
if (isset($params[$_trigger]['battery'])) {
// level
if (isset($params[$_trigger]['battery']['level'])) {
- $cmd = $this->getCmd(null, 'phoneBattery');
- if (!is_object($cmd)) {
- $cmd = new mobileCmd();
- $cmd->setLogicalId('phoneBattery');
- $cmd->setName(__('Batterie du téléphone', __FILE__));
- $cmd->setDisplay('icon', '');
- $cmd->setDisplay('showIconAndNamedashboard', 1);
- $cmd->setDisplay('showIconAndNamemobile', 1);
- $cmd->setDisplay('forceReturnLineAfter', 1);
- $cmd->setConfiguration('historizeRound', 2);
- $cmd->setConfiguration('minValue', 0);
- $cmd->setConfiguration('maxValue', 100);
- $cmd->setUnite('%');
- $cmd->setIsVisible(0);
- $cmd->setOrder($order);
- $order++;
- log::add('mobile', 'debug', 'Create cmd for phoneBattery');
+ if ($getDeviceInformations) {
+ $cmd = $this->getCmd(null, 'battery::level');
+ if (!is_object($cmd)) {
+ $cmd = new mobileCmd();
+ $cmd->setLogicalId('battery::level');
+ $cmd->setName(__('Batterie du téléphone', __FILE__));
+ $cmd->setDisplay('icon', '');
+ $cmd->setDisplay('showIconAndNamedashboard', 1);
+ $cmd->setDisplay('showIconAndNamemobile', 1);
+ $cmd->setDisplay('forceReturnLineAfter', 1);
+ $cmd->setConfiguration('historizeRound', 2);
+ $cmd->setConfiguration('minValue', 0);
+ $cmd->setConfiguration('maxValue', 100);
+ $cmd->setUnite('%');
+ $cmd->setIsVisible(0);
+ $cmd->setOrder($order);
+ $order++;
+ log::add('mobile', 'debug', '|| Creating the "phone battery" command');
+ }
+ $cmd->setEqLogic_id($this->getId());
+ $cmd->setType('info');
+ $cmd->setConfiguration('calculValueOffset', '#value# * 100');
+ $cmd->setSubType('numeric');
+ if ($cmd->getChanged() === true) $cmd->save();
+ }
+ if ($params[$_trigger]['battery']['level'] != -1) {
+ if ($this->checkAndUpdateCmd('battery::level', $params[$_trigger]['battery']['level'])) {
+ log::add('mobile', 'debug', '|| Updating "phone battery" value ─▶︎ ' . $params[$_trigger]['battery']['level'] * 100 . '%');
+ }
+ } else {
+ log::add('mobile', 'debug', '|| [WARNING] No data available for battery level ─▶︎ ' . $params[$_trigger]['battery']['level']);
}
- $cmd->setEqLogic_id($this->getId());
- $cmd->setType('info');
- $cmd->setSubType('numeric');
- if ($cmd->getChanged() === true) $cmd->save();
- log::add('mobile', 'debug', '| OK phoneBattery = ' . $params[$_trigger]['battery']['level'] * 100);
- $this->checkAndUpdateCmd('phoneBattery', $params[$_trigger]['battery']['level'] * 100);
}
// charging
if (isset($params[$_trigger]['battery']['is_charging'])) {
- $cmd = $this->getCmd(null, 'phoneCharging');
- if (!is_object($cmd)) {
- $cmd = new mobileCmd();
- $cmd->setLogicalId('phoneCharging');
- $cmd->setName(__('En charge', __FILE__));
- $cmd->setDisplay('icon', '');
- $cmd->setDisplay('showIconAndNamedashboard', 1);
- $cmd->setDisplay('showIconAndNamemobile', 1);
- $cmd->setDisplay('forceReturnLineAfter', 1);
- $cmd->setTemplate('dashboard', 'core::line');
- $cmd->setTemplate('mobile', 'core::line');
- $cmd->setIsVisible(0);
- $cmd->setOrder($order);
- $order++;
- log::add('mobile', 'debug', 'Create cmd for phoneCharging');
+ if ($getDeviceInformations) {
+ $cmd = $this->getCmd(null, 'battery::isCharging');
+ if (!is_object($cmd)) {
+ $cmd = new mobileCmd();
+ $cmd->setLogicalId('battery::isCharging');
+ $cmd->setName(__('En charge', __FILE__));
+ $cmd->setDisplay('icon', '');
+ $cmd->setDisplay('showIconAndNamedashboard', 1);
+ $cmd->setDisplay('showIconAndNamemobile', 1);
+ $cmd->setDisplay('forceReturnLineAfter', 1);
+ $cmd->setTemplate('dashboard', 'core::line');
+ $cmd->setTemplate('mobile', 'core::line');
+ $cmd->setIsVisible(0);
+ $cmd->setOrder($order);
+ $order++;
+ log::add('mobile', 'debug', '|| Creating the "in charge" command');
+ }
+ $cmd->setEqLogic_id($this->getId());
+ $cmd->setType('info');
+ $cmd->setSubType('binary');
+ if ($cmd->getChanged() === true) $cmd->save();
+ }
+ if ($this->checkAndUpdateCmd('battery::isCharging', intval($params[$_trigger]['battery']['is_charging']))) {
+ log::add('mobile', 'debug', '|| Updating "in charge" value ─▶︎ ' . intval($params[$_trigger]['battery']['is_charging']));
}
- $cmd->setEqLogic_id($this->getId());
- $cmd->setType('info');
- $cmd->setSubType('binary');
- if ($cmd->getChanged() === true) $cmd->save();
- log::add('mobile', 'debug', '| OK phoneCharging = ' . intval($params[$_trigger]['battery']['is_charging']));
- $this->checkAndUpdateCmd('phoneCharging', intval($params[$_trigger]['battery']['is_charging']));
}
}
// coords
if (isset($params[$_trigger]['coords'])) {
if (isset($params[$_trigger]['coords']['latitude']) && isset($params[$_trigger]['coords']['longitude'])) {
- $cmd = $this->getCmd(null, 'coords');
- if (!is_object($cmd)) {
- $cmd = new mobileCmd();
- $cmd->setLogicalId('coords');
- $cmd->setName(__('Coordonnées', __FILE__));
- $cmd->setDisplay('icon', '');
- $cmd->setDisplay('showIconAndNamedashboard', 1);
- $cmd->setDisplay('showIconAndNamemobile', 1);
- $cmd->setDisplay('forceReturnLineAfter', 1);
- $cmd->setTemplate('dashboard', 'core::line');
- $cmd->setTemplate('mobile', 'core::line');
- $cmd->setIsVisible(0);
- $cmd->setOrder($order);
- $order++;
- log::add('mobile', 'debug', 'Create cmd for coords');
+ if ($getDeviceInformations) {
+ $cmd = $this->getCmd(null, 'coords');
+ if (!is_object($cmd)) {
+ $cmd = new mobileCmd();
+ $cmd->setLogicalId('coords');
+ $cmd->setName(__('Coordonnées', __FILE__));
+ $cmd->setDisplay('icon', '');
+ $cmd->setDisplay('showIconAndNamedashboard', 1);
+ $cmd->setDisplay('showIconAndNamemobile', 1);
+ $cmd->setDisplay('forceReturnLineAfter', 1);
+ $cmd->setTemplate('dashboard', 'core::line');
+ $cmd->setTemplate('mobile', 'core::line');
+ $cmd->setIsVisible(0);
+ $cmd->setOrder($order);
+ $order++;
+ log::add('mobile', 'debug', '|| Creating the "coordinates" command');
+ }
+ $cmd->setEqLogic_id($this->getId());
+ $cmd->setType('info');
+ $cmd->setSubType('string');
+ if ($cmd->getChanged() === true) $cmd->save();
+ }
+ $coord = $params[$_trigger]['coords']['latitude'] . ',' . $params[$_trigger]['coords']['longitude'];
+ if ($this->checkAndUpdateCmd('coords', $coord)) {
+ log::add('mobile', 'debug', '|| Updating "coordinates" value ─▶︎ ' . $coord);
+ }
+ }
+ if (isset($params[$_trigger]['coords']['altitude'])) {
+ if ($getDeviceInformations) {
+ $cmd = $this->getCmd(null, 'altitude');
+ if (!is_object($cmd)) {
+ $cmd = new mobileCmd();
+ $cmd->setLogicalId('altitude');
+ $cmd->setName(__('Altitude', __FILE__));
+ $cmd->setDisplay('icon', '');
+ $cmd->setDisplay('showIconAndNamedashboard', 1);
+ $cmd->setDisplay('showIconAndNamemobile', 1);
+ $cmd->setDisplay('forceReturnLineAfter', 1);
+ $cmd->setTemplate('dashboard', 'core::line');
+ $cmd->setTemplate('mobile', 'core::line');
+ $cmd->setIsVisible(0);
+ $cmd->setUnite('m');
+ $cmd->setOrder($order);
+ $order++;
+ log::add('mobile', 'debug', '|| Creating the "altitude" command');
+ }
+ $cmd->setEqLogic_id($this->getId());
+ $cmd->setType('info');
+ $cmd->setSubType('string');
+ if ($cmd->getChanged() === true) $cmd->save();
+ }
+ if ($this->checkAndUpdateCmd('altitude', $params[$_trigger]['coords']['altitude'])) {
+ log::add('mobile', 'debug', '|| Updating "Altitude" value ─▶︎ ' . $params[$_trigger]['coords']['altitude'] . 'm');
}
- $cmd->setEqLogic_id($this->getId());
- $cmd->setType('info');
- $cmd->setSubType('string');
- if ($cmd->getChanged() === true) $cmd->save();
- log::add('mobile', 'debug', '| OK coords = ' . $params[$_trigger]['coords']['latitude'] . ',' . $params[$_trigger]['coords']['longitude']);
- $this->checkAndUpdateCmd('coords', $params[$_trigger]['coords']['latitude'] . ',' . $params[$_trigger]['coords']['longitude']);
}
}
}
}
+ log::add('mobile', 'debug', '|└──────────────');
}
/**
@@ -925,8 +1543,8 @@ public function cmdForSpecificChannel($params = array(), $_trigger = 'location')
public function cleaningNotifications()
{
$notifsTime = $this->getConfiguration('notifsTime', 30);
- log::add('mobile', 'debug', '┌──────────▶︎ :fg-warning: Nettoyage des Notifications et Images :/fg: ──────────');
- log::add('mobile', 'debug', '| Durée de retention actuelle : ' . $notifsTime . ' jours');
+ log::add('mobile', 'debug', '┌──────────▶︎ :fg-warning: cleaningNotifications :/fg: ──────────');
+ log::add('mobile', 'debug', '| Current retention period ─▶︎ ' . $notifsTime . ' days');
// Images
$retentionSeconds = intVal($notifsTime) * 24 * 60 * 60;
$currentTime = time();
@@ -938,9 +1556,9 @@ public function cleaningNotifications()
$fileCreationTime = filemtime($image);
if ($fileCreationTime < ($currentTime - $retentionSeconds)) {
if (!unlink($image)) {
- log::add('mobile', 'error', 'Erreur lors de la suppression de: ' . $image);
+ log::add('mobile', 'error', __("Erreur lors de la suppression", __FILE__) . ' ─▶︎ ' . $image);
} else {
- log::add('mobile', 'debug', '| ─▶︎ :fg-danger:suppression image:/fg: > ' . $image);
+ log::add('mobile', 'debug', '| [WARNING] image removal ─▶︎ ' . $image);
}
}
}
@@ -954,7 +1572,7 @@ public function cleaningNotifications()
if ($notifications) {
$notifications = json_decode($notifications, true);
if (json_last_error() !== JSON_ERROR_NONE) {
- log::add('mobile', 'error', 'Erreur decodage du JSON : ' . json_last_error_msg());
+ log::add('mobile', 'error', __("Erreur decodage du JSON", __FILE__) . ' ─▶︎ ' . json_last_error_msg());
return;
}
$notificationsModified = false;
@@ -962,7 +1580,7 @@ public function cleaningNotifications()
foreach ($notifications as $id => $value) {
$notificationDate = strtotime($value['data']['date']);
if (($currentTime - $notificationDate) > $retentionSeconds) {
- log::add('mobile', 'debug', '| ─▶︎ :fg-danger:suppression notification:/fg: > N°' . $id);
+ log::add('mobile', 'debug', '| [WARNING] notification removal ─▶︎ N°' . $id);
unset($notifications[$id]);
$notificationsModified = true;
}
@@ -985,7 +1603,9 @@ public function postInsert()
$key = config::genKey(32);
$this->setLogicalId($key);
}
- $this->setConfiguration('defaultIdMobile', $this->getId());
+ if ($this->getConfiguration('appVersion', 1) == 2) {
+ $this->setConfiguration('defaultIdMobile', $this->getId());
+ }
$this->save();
}
@@ -994,15 +1614,36 @@ public function postInsert()
*/
public function postSave()
{
+ $order = count($this->getCmd());
+
+ // Notification command
+ $cmd = $this->getCmd(null, 'notif');
+ if (!is_object($cmd)) {
+ $cmd = new mobileCmd();
+ $cmd->setIsVisible(1);
+ $cmd->setName(__('Notification', __FILE__));
+ $cmd->setLogicalId('notif');
+ $cmd->setGeneric_type('GENERIC_ACTION');
+ $cmd->setDisplay('icon', '');
+ $cmd->setDisplay('forceReturnLineAfter', 1);
+ $cmd->setDisplay('showIconAndNamedashboard', 1);
+ $cmd->setDisplay('showIconAndNamemobile', 1);
+ $cmd->setOrder($order);
+ $order++;
+ }
+ $cmd->setEqLogic_id($this->getId());
+ $cmd->setType('action');
+ $cmd->setSubType('message');
+ if ($cmd->getChanged() === true) $cmd->save();
+
if ($this->getConfiguration('appVersion', 1) == 2) {
- $order = count($this->getCmd());
- // Commande notification
- $cmd = $this->getCmd(null, 'notif');
+ // Critical Notification Command
+ $cmd = $this->getCmd(null, 'notifCritical');
if (!is_object($cmd)) {
$cmd = new mobileCmd();
$cmd->setIsVisible(1);
- $cmd->setName(__('Notification', __FILE__));
- $cmd->setLogicalId('notif');
+ $cmd->setName(__('Notification Critique', __FILE__));
+ $cmd->setLogicalId('notifCritical');
$cmd->setGeneric_type('GENERIC_ACTION');
$cmd->setDisplay('icon', '');
$cmd->setDisplay('forceReturnLineAfter', 1);
@@ -1016,22 +1657,8 @@ public function postSave()
$cmd->setSubType('message');
if ($cmd->getChanged() === true) $cmd->save();
- // Commande notification Critique
- $cmd = $this->getCmd(null, 'notifCritical');
- if (!is_object($cmd)) {
- $cmd = new mobileCmd();
- $cmd->setIsVisible(1);
- $cmd->setName(__('Notification Critique', __FILE__));
- $cmd->setLogicalId('notifCritical');
- $cmd->setGeneric_type('GENERIC_ACTION');
- $cmd->setDisplay('icon', '');
- $cmd->setDisplay('forceReturnLineAfter', 1);
- $cmd->setDisplay('showIconAndNamedashboard', 1);
- $cmd->setDisplay('showIconAndNamemobile', 1);
- $cmd->setOrder($order);
- $order++;
- }
- $cmd = $this->getCmd(null, 'notifSilent');
+ // Silent notification command
+ $cmd = $this->getCmd(null, 'notifSilent');
if (!is_object($cmd)) {
$cmd = new mobileCmd();
$cmd->setIsVisible(1);
@@ -1050,7 +1677,7 @@ public function postSave()
$cmd->setSubType('message');
if ($cmd->getChanged() === true) $cmd->save();
- // Commande récupération infos du téléphone
+ // command to retrieve specific information
$cmd = $this->getCmd(null, 'notifSpecific');
if (!is_object($cmd)) {
$cmd = new mobileCmd();
@@ -1070,7 +1697,7 @@ public function postSave()
$cmd->setSubType('other');
if ($cmd->getChanged() === true) $cmd->save();
- // Commande suppression des nodifications
+ // Command to delete notifications
$cmd = $this->getCmd(null, 'removeNotifs');
if (!is_object($cmd)) {
$cmd = new mobileCmd();
@@ -1093,15 +1720,15 @@ public function postSave()
if ($cmd->getChanged() === true) $cmd->save();
}
-
-
- $cmdaskText = $this->getCmd(null, 'ask_Text');
- if (is_object($cmdaskText)) {
- $cmdaskText->remove();
- }
- $cmdaskYN = $this->getCmd(null, 'ask_YN');
- if (is_object($cmdaskYN)) {
- $cmdaskYN->remove();
+ if ($this->getConfiguration('appVersion', 1) != 2) {
+ $cmdaskText = $this->getCmd(null, 'ask_Text');
+ if (is_object($cmdaskText)) {
+ $cmdaskText->remove();
+ }
+ $cmdaskYN = $this->getCmd(null, 'ask_YN');
+ if (is_object($cmdaskYN)) {
+ $cmdaskYN->remove();
+ }
}
}
@@ -1118,18 +1745,18 @@ public function preRemove()
if ($mobile->getConfiguration('defaultIdMobile', 'none') == $Iq) {
$mobile->setConfiguration('defaultIdMobile', $mobile->getId());
$mobile->save();
- log::add('mobile', 'debug', '| Modification du defaultIdMobile pour le mobile ' . $mobile->getHumanName(false) . ' ( ' . $mobile->getId() . ' ) ');
+ log::add('mobile', 'debug', '| Update defaultIdMobile for mobile ' . $mobile->getHumanName(false) . ' ( ' . $mobile->getId() . ' ) ');
}
}
$fileNotif = dirname(__FILE__) . '/../data/notifications/' . $this->getLogicalId() . '.json';
if (file_exists($fileNotif)) {
- log::add('mobile', 'debug', '| Suppression du fichier des notifications : ' . $fileNotif);
+ log::add('mobile', 'debug', '| Deleting notifications file ─▶︎ ' . $fileNotif);
shell_exec('rm ' . $fileNotif);
}
/* App V1 */
$path = dirname(__FILE__) . '/../../data/' . $this->getLogicalId();
if (file_exists($path)) {
- log::add('mobile', 'debug', '| Suppression du dossier : ' . $path);
+ log::add('mobile', 'debug', '| Deleting folder ─▶︎ ' . $path);
shell_exec('rm -rf ' . $path);
}
log::add('mobile', 'debug', '└────────────────────');
@@ -1165,7 +1792,6 @@ public static function fileInMessage($data)
$dataArray = explode('|', $data);
$result = array();
foreach ($dataArray as $item) {
-
$arg = explode('=', trim($item), 2);
if (count($arg) == 2) {
$result[trim($arg[0])] = trim($arg[1]);
@@ -1174,17 +1800,16 @@ public static function fileInMessage($data)
$result['message'] = $dataArray[0];
$decodedMessage = json_decode($result['message']);
if (json_last_error() === JSON_ERROR_NONE) {
- log::add('mobile', 'DEBUG', '|| [INFO] Message : ' . $decodedMessage);
+ log::add('mobile', 'debug', '|| [INFO] Message ─▶︎ ' . $decodedMessage);
} else {
- log::add('mobile', 'DEBUG', '|| [INFO] Message : ' . $result['message']);
+ log::add('mobile', 'debug', '|| [INFO] Message ─▶︎ ' . str_replace(["\r", "\n"], "", $result['message']));
}
if (array_key_exists('file', $result)) {
- log::add('mobile', 'debug', '|| file > ' . $result['file']);
+ log::add('mobile', 'debug', '|| file ─▶︎ ' . $result['file']);
log::add('mobile', 'debug', '|└────────────────────');
return $result;
} else {
log::add('mobile', 'debug', '|└────────────────────');
- //log::add('mobile', 'debug', '| null');
return null;
}
}
@@ -1201,12 +1826,15 @@ public function execute($_options = array())
if ($this->getLogicalId() == 'removeNotifs') {
$filePath = dirname(__FILE__) . '/../data/notifications/' . $Iq . '.json';
- if (!file_exists($filePath)) log::add('mobile', 'info', '| Fichier de notifications non trouvé : ' . $filePath);
+ if (!file_exists($filePath)) {
+ log::add('mobile', 'debug', '| ' . __('Fichier de notifications inexistant', __FILE__) . ' ─▶︎ ' . $filePath);
+ return;
+ }
$valueUser = $_options['select'];
switch ($valueUser) {
case 1:
file_put_contents($filePath, '');
- log::add('mobile', 'info', '| Suppression des notifications effectuée');
+ log::add('mobile', 'debug', '| Deleting all notifications');
break;
case 2:
$notifs = json_decode(file_get_contents($filePath), true);
@@ -1214,27 +1842,28 @@ public function execute($_options = array())
$askParams = json_decode($notif['data']['askParams'], true);
$notifTime = strtotime($notif['data']['date']);
$currentTime = time();
- $timeout = $askParams['timeout'] / 1000;
+ $timeout = (isset($askParams['timeout'])) ? $askParams['timeout'] / 1000 : 0;
return $notif['data']['askVariable'] == 'rien' || ($currentTime - $notifTime) < $timeout;
});
file_put_contents($filePath, json_encode($notifs));
- log::add('mobile', 'info', '| Suppression des asks expirés effectuée');
+ log::add('mobile', 'debug', '| Deleting all ask expired');
break;
case 3:
$notifs = json_decode(file_get_contents($filePath), true);
$notifs = array_filter($notifs, function ($notif) {
- return $notif['data']['choiceAsk'] == '';
+ return !isset($notif['data']['choiceAsk']) || $notif['data']['choiceAsk'] == '';
});
file_put_contents($filePath, json_encode($notifs));
- log::add('mobile', 'info', '| Suppression des asks répondus effectuée');
+ log::add('mobile', 'debug', '| Deleting all ask answered');
break;
}
log::add('mobile', 'debug', '└────────────────────');
}
-
if ($this->getLogicalId() == 'notif' || $this->getLogicalId() == 'notifCritical' || $this->getLogicalId() == 'notifSpecific' || $this->getLogicalId() == 'notifSilent') {
+ $notificationArn = $eqLogic->getConfiguration('notificationArn', null);
+ $typeMobile = $eqLogic->getConfiguration('type_mobile', null);
$critical = false;
$silent = false;
$specific = false;
@@ -1258,41 +1887,35 @@ public function execute($_options = array())
$_options['message'] = $file['message'];
log::add('mobile', 'debug', '| file detected ' . json_encode($file));
}
- log::add('mobile', 'DEBUG', '| [INFO] Title : ' . $_options['title']);
- log::add('mobile', 'DEBUG', '| [INFO] Message : ' . $_options['message']);
- if ($eqLogic->getConfiguration('type_mobile') == 'android') $_options['message'] = nl2br($_options['message']);
+ log::add('mobile', 'DEBUG', '| [INFO] Title ─▶︎ ' . $_options['title']);
+ log::add('mobile', 'DEBUG', '| [INFO] Message ─▶︎ ' . str_replace(["\r", "\n"], "", $_options['message']));
+ if ($typeMobile == 'android') $_options['message'] = nl2br($_options['message']);
$answer = (isset($_options['answer']) && $_options['answer']) ? join(';', $_options['answer']) : null;
$askVariable = isset($_options['variable']) ? $_options['variable'] : null;
$askType = isset($_options['answer']) && $_options['answer'] ? 'ask_Text' : 'notif';
if ($askType == 'ask_Text') $_options['title'] = $defaultName;
$timeout = isset($_options['timeout']) && $_options['timeout'] ? $_options['timeout'] : 'nok';
$optionsNotif['askVariable'] = $askVariable;
- //log::add('mobile', 'debug', '|-----------------------------------');
- log::add('mobile', 'debug', '| Commande de notification : ' . $askType);
- if (($eqLogic->getConfiguration('notificationArn', null) != null || $eqLogic->getConfiguration('notificationRegistrationToken', null) != null) && $eqLogic->getConfiguration('type_mobile', null) != null) {
+ log::add('mobile', 'debug', '| Notification command ─▶︎ ' . $askType);
+ if (($notificationArn != null || $eqLogic->getConfiguration('notificationRegistrationToken', null) != null) && $typeMobile != null) {
$idNotif = $eqLogic->getConfiguration('idNotif', 0);
$idNotif = $idNotif + 1;
$eqLogic->setConfiguration('idNotif', $idNotif);
$eqLogic->save();
-
- log::add('mobile', 'debug', '| [INFO] Notif > ' . json_encode($_options));
- log::add('mobile', 'debug', '| eqLogic > ' . $eqLogic->getId() . ' | LogicalId > ' . $this->getLogicalId() . ' | idNotif > ' . $idNotif);
+ log::add('mobile', 'debug', '| [INFO] Notif ─▶︎ ' . json_encode($_options));
+ log::add('mobile', 'debug', '| eqLogic ─▶︎ ' . $eqLogic->getId() . ' | LogicalId ─▶︎ ' . $this->getLogicalId() . ' | idNotif ─▶︎ ' . $idNotif);
if (isset($options['file'])) {
- //log::add('mobile', 'debug', '| [NOTICE] FILE');
- //unset($data['file']);
$_options['files'] = explode(',', $options['file']);
}
if (isset($_options['files']) && is_array($_options['files'])) {
- log::add('mobile', 'debug', '| [NOTICE] FILE');
+ log::add('mobile', 'debug', '| file detected');
foreach ($_options['files'] as $file) {
- log::add('mobile', 'debug', '| FILES as FILE');
- if (trim($file) == '') {
- continue;
- }
+ if (trim($file) == '') continue;
$ext = pathinfo($file, PATHINFO_EXTENSION);
- log::add('mobile', 'debug', '| ' . $ext . ' pour > ' . $file);
+ $url = null;
+ log::add('mobile', 'debug', '| ' . $file);
if (in_array($ext, array('gif', 'jpeg', 'jpg', 'png'))) {
- log::add('mobile', 'debug', '| type photo !');
+ log::add('mobile', 'debug', '| ↳ type photo !');
if ($ext == "gif") {
$typeHint = "com.compuserve.gif";
} else if ($ext == "jpeg") {
@@ -1305,31 +1928,29 @@ public function execute($_options = array())
$typeHint = "public.jpeg";
}
$optionsNotif['typeHint'] = $typeHint;
- $url = network::getNetworkAccess('external');
- $url .= '/plugins/mobile/core/php/image.php?';
$nameFile = $Iq . '__' . base64_encode($file) . '.' . $ext;
$path = dirname(__FILE__) . '/../../data/images';
$newfile = $path . '/' . $nameFile;
- log::add('mobile', 'debug', '| copie sur > ' . $newfile);
+ log::add('mobile', 'debug', '| ↳ copy on ─▶︎ ' . $newfile);
if (!file_exists($path)) {
mkdir($path);
}
if (!copy($file, $newfile)) {
- log::add('mobile', 'error', 'la copie de l\'image a echoué');
+ log::add('mobile', 'error', __("la copie de l\'image a échouée", __FILE__));
+ } else {
+ $keyFile = md5_file($newfile);
+ $url = network::getNetworkAccess('external') . '/plugins/mobile/core/php/image.php?key=' . $keyFile . '&name=' . $nameFile;
+ log::add('mobile', 'debug', '| ↳ url ─▶︎ ' . $url);
}
- $keyFile = md5_file($newfile);
- $url .= 'key=' . $keyFile . '&name=' . $nameFile;
- log::add('mobile', 'debug', '| url > ' . $url);
- mobile::notification($eqLogic->getConfiguration('notificationArn', null), $eqLogic->getConfiguration('type_mobile', null), $_options['title'], $_options['message'], $askType, $idNotif, $answer, $timeout, $eqLogic->getConfiguration('notificationRegistrationToken', null), $url, $eqLogic->getConfiguration('appVersion', 1), $optionsNotif, $critical, $eqLogic->getLogicalId(), $specific, $silent);
- } else {
- mobile::notification($eqLogic->getConfiguration('notificationArn', null), $eqLogic->getConfiguration('type_mobile', null), $_options['title'], $_options['message'], $askType, $idNotif, $answer, $timeout, $eqLogic->getConfiguration('notificationRegistrationToken', null), null, $eqLogic->getConfiguration('appVersion', 1), $optionsNotif, $critical, $eqLogic->getLogicalId(), $specific, $silent);
}
+ mobile::notification($notificationArn, $typeMobile, $_options['title'], $_options['message'], $askType, $idNotif, $answer, $timeout, $eqLogic->getConfiguration('notificationRegistrationToken', null), $url, $eqLogic->getConfiguration('appVersion', 1), $optionsNotif, $critical, $Iq, $specific, $silent);
}
} else {
- mobile::notification($eqLogic->getConfiguration('notificationArn', null), $eqLogic->getConfiguration('type_mobile', null), $_options['title'], $_options['message'], $askType, $idNotif, $answer, $timeout, $eqLogic->getConfiguration('notificationRegistrationToken', null), null, $eqLogic->getConfiguration('appVersion', 1), $optionsNotif, $critical, $eqLogic->getLogicalId(), $specific, $silent);
+ mobile::notification($notificationArn, $typeMobile, $_options['title'], $_options['message'], $askType, $idNotif, $answer, $timeout, $eqLogic->getConfiguration('notificationRegistrationToken', null), null, $eqLogic->getConfiguration('appVersion', 1), $optionsNotif, $critical, $Iq, $specific, $silent);
}
} else {
- log::add('mobile', 'debug', '| [ERROR] ARN non configuré ');
+ if ($typeMobile == null) log::add('mobile', 'debug', '| [ERROR] Mobile type not configured');
+ else log::add('mobile', 'debug', '| [ERROR] ARN not configured');
}
log::add('mobile', 'debug', '└────────────────────');
}
diff --git a/core/template/mobile/cmd.info.numeric.arcSlider.html b/core/template/mobile/cmd.info.numeric.arcSlider.html
index 404d502d..750c1a11 100644
--- a/core/template/mobile/cmd.info.numeric.arcSlider.html
+++ b/core/template/mobile/cmd.info.numeric.arcSlider.html
@@ -40,7 +40,7 @@
.css("transform", "scale(0.94) rotate(" + angle + "deg)");
cmd.find(".state strong").first().text(_options.display_value);
});
-
+
if (is_numeric("#state#")) {
jeedom.cmd.refreshValue([
{
diff --git a/desktop/css/notification.css b/desktop/css/notification.css
new file mode 100644
index 00000000..75786447
--- /dev/null
+++ b/desktop/css/notification.css
@@ -0,0 +1,129 @@
+.notification-box {
+ padding: 32px;
+}
+
+.notification-step {
+ display: flex;
+ margin-bottom: 32px;
+ position: relative;
+}
+
+.notification-step:last-child {
+ margin-bottom: 0px;
+}
+
+.notification-line {
+ position: absolute;
+ left: 114px;
+ top: 40px;
+ bottom: -32px;
+ width: 2px;
+ background-color: var(--logo-primary-color);
+ z-index: 1;
+}
+
+.notification-date {
+ display: flex;
+ height: 40px;
+ align-items: center;
+ margin-right: 16px;
+ width: 79px;
+ font-size: 12px;
+ padding: 5px;
+ text-align: center;
+ border-radius: var(--border-radius) var(--border-radius) var(--border-radius) var(--border-radius) !important;
+ background-color: var(--form-bg-color);
+ /* z-index: 1;*/
+}
+
+.notification-step:last-child .notification-line {
+ display: none;
+}
+
+.notification-circle {
+ width: 40px;
+ height: 40px;
+ border-radius: 50%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ margin-right: 16px;
+ background-color: var(--form-bg-color);
+ border: 2px solid var(--txt-color);
+ z-index: 2;
+}
+
+.ask-timeout .notification-circle {
+ color: var(--linkHoverLight-color) !important;
+ background-color: var(--al-info-color) !important;
+ border: none;
+}
+
+.ask-success .notification-circle {
+ color: var(--linkHoverLight-color) !important;
+ background-color: var(--al-success-color) !important;
+ border: none;
+}
+
+.ask-in-progress .notification-circle {
+ color: var(--linkHoverLight-color) !important;
+ background-color: var(--al-warning-color) !important;
+ border: none;
+}
+
+.stepper-critical .notification-circle {
+ border: 1px solid red;
+}
+
+.notification-content {
+ flex: 1;
+ padding: 10px;
+ border-radius: var(--border-radius) var(--border-radius) var(--border-radius) var(--border-radius);
+ background-color: var(--form-bg-color);
+}
+
+.notification-img {
+ margin-top: 10px;
+}
+
+.notification-img img {
+ max-width: 250px;
+}
+
+.notification-title {
+ font-weight: 600;
+ margin-bottom: 4px;
+ font-size: 18px;
+}
+
+.notification-status {
+ font-size: 13px;
+ display: inline-block;
+ padding: 2px 8px;
+ border-radius: 12px;
+ margin-top: 4px;
+}
+
+.ask-success .notification-status {
+ color: var(--linkHoverLight-color) !important;
+ background-color: var(--al-success-color) !important;
+ border: none;
+}
+
+.ask-timeout .notification-status {
+ color: var(--linkHoverLight-color) !important;
+ background-color: var(--al-info-color) !important;
+ border: none;
+}
+
+.ask-in-progress .notification-status {
+ color: var(--linkHoverLight-color) !important;
+ background-color: var(--al-warning-color) !important;
+ border: none;
+}
+
+.notification-button {
+ display: flex;
+ margin-bottom: 32px;
+ justify-content: end;
+}
\ No newline at end of file
diff --git a/desktop/css/wizard.css b/desktop/css/wizard.css
new file mode 100644
index 00000000..13612994
--- /dev/null
+++ b/desktop/css/wizard.css
@@ -0,0 +1,372 @@
+body {
+ padding-top: unset;
+}
+
+#jeedomMenuBar {
+ display: none;
+}
+
+#div_mainContainer {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+}
+
+#div_pageContainer {
+ background-color: rgba(var(--eq-bg-color), var(--opacity));
+ border-radius: var(--border-radius);
+}
+
+#mobile_wizard .flex-evenly {
+ width: 100%;
+ height: 100%;
+ display: flex;
+ justify-content: space-evenly;
+ align-items: center;
+}
+
+#mobile_wizard .flex-column {
+ width: 100%;
+ height: 100%;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+}
+
+#bt_quitmobile {
+ position: absolute;
+ top: 5%;
+ right: 5%;
+}
+
+/* #wizard_container {
+ height: 600px;
+ display: grid;
+ justify-items: center;
+ align-items: center;
+ grid-template-columns: 100%;
+ grid-template-rows: 50px 225px 0 25px auto;
+} */
+
+#wizard_container {
+ height: 600px;
+ display: flex;
+ flex-direction: column;
+ justify-items: center;
+ align-items: center;
+}
+
+
+#wizard_container>h3 {
+ grid-row-start: 1
+}
+
+#wizard_container>img {
+ max-width: 350px;
+ max-height: 500px;
+ grid-row-start: 2
+}
+
+#wizard_container>.logo {
+ grid-row-start: 2
+}
+
+#wizard_container .input-group {
+ max-width: 450px;
+ margin: auto;
+}
+
+#wizard_container .form-control {
+ font-weight: bold;
+ text-align-last: center;
+}
+
+.bold {
+ font-weight: bold;
+}
+
+/*** OBJECTS ***/
+#wizard_container>.step_father .sel_father,
+#wizard_container>.step_childs .sel_child {
+ border-radius: var(--border-radius);
+ background-color: var(--el-defaultColor);
+ overflow: hidden;
+}
+
+#wizard_container>.step_father .sel_father:hover,
+#wizard_container>.step_father .sel_father.selected {
+ transform: scale(1.2);
+}
+
+#wizard_container>.step_childs .sel_child {
+ opacity: .25;
+}
+
+#wizard_container>.step_childs .sel_child:hover {
+ opacity: 1;
+}
+
+#wizard_container>.step_childs .sel_child.selected {
+ opacity: 1;
+ border: solid 3px var(--logo-primary-color);
+}
+
+#wizard_container>.step_father img {
+ width: 250px;
+ max-width: 100%;
+ max-height: 150px;
+}
+
+#wizard_container>.step_childs .panel {
+ width: 100%;
+ max-width: 1000px;
+}
+
+#wizard_container>.step_childs .panel-body {
+ padding: 12px 0 10px 10px;
+}
+
+#wizard_container>.step_childs img {
+ width: 180px;
+ max-width: 100%;
+ max-height: 100px;
+}
+
+#wizard_container>.step_father .object_name,
+#wizard_container>.step_childs .object_name {
+ font-weight: bold;
+ color: white;
+ padding: 2px;
+ background-color: var(--al-info-color);
+}
+
+/*** PLUGINS ***/
+#wizard_container>#plugins {
+ min-height: 250px;
+}
+
+#wizard_container>#plugins>.plugin {
+ max-height: 50%;
+ min-width: 10%;
+ opacity: .5;
+ border: solid 3px var(--linkHover-color);
+ border-radius: var(--border-radius);
+ padding: 6px 0;
+}
+
+#wizard_container>#plugins>.plugin:hover {
+ opacity: 1;
+}
+
+#wizard_container>#plugins>.plugin.selected {
+ opacity: 1;
+ border: solid 3px var(--logo-primary-color);
+}
+
+#wizard_container>#plugins>.plugin.selected[data-installed="true"] {
+ border: solid 3px var(--al-info-color);
+}
+
+#wizard_container>#plugins>.plugin>img {
+ max-height: 95px;
+ max-width: 85%;
+}
+
+/*** NAVIGATION ***/
+#wizard_navigation {
+ margin: 15px auto;
+}
+
+#wizard_navigation>div {
+ margin: auto 10px;
+ min-width: 50px;
+}
+
+.navBtn,
+#bt_jeedom_ready {
+ font-size: 45px;
+ cursor: pointer !important;
+ color: #F18D15;
+}
+
+.navDot {
+ width: 25px;
+ height: 25px;
+ margin: 5px;
+ border-radius: 50%;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ color: white;
+ background-color: rgb(var(--contrast-color), .7);
+ user-select: none;
+}
+
+.navDot:hover,
+.navDot.active {
+ transform: scale(1.5);
+}
+
+.navDot.active {
+ margin: 0 10px;
+}
+
+.navDot.blocked {
+ opacity: .5;
+}
+
+
+
+/*
+
+@media (max-width: 768px) {
+ #wizard_container {
+ height: auto;
+ grid-template-rows: auto auto auto auto auto;
+ padding: 10px;
+ }
+
+ #wizard_container>img {
+ max-width: 250px;
+ max-height: 150px;
+ }
+
+ #wizard_navigation {
+ flex-direction: row;
+ justify-content: center;
+ position: fixed;
+ bottom: 10px;
+ width: 100%;
+ padding-bottom: 10px;
+ background-color: rgba(var(--panel-bg-color), 0.9);
+ }
+
+ #wizard_navigation>div {
+ margin: 0 5px;
+ }
+
+ .navBtn,
+ #bt_jeedom_ready {
+ font-size: 30px;
+ }
+
+ .navDot {
+ width: 20px;
+ height: 20px;
+ margin: 3px;
+ }
+
+ .navDot:hover,
+ .navDot.active {
+ transform: scale(1.2);
+ }
+
+ #wizard_container>#updates>.update,
+ #wizard_container>#plugins>.plugin {
+ width: 70px;
+ height: auto;
+ }
+
+ #wizard_container>#updates>.update>img,
+ #wizard_container>#plugins>.plugin>img {
+ width: 60px;
+ }
+
+ #wizard_container>.services .service {
+ height: 150px;
+ max-width: 100%;
+ }
+} */
+
+
+
+/* TABLETS (portrait) */
+@media (max-width: 1024px) {
+ #div_mainContainer {
+ flex-direction: column;
+ padding: 10px;
+ }
+
+ #wizard_container {
+ height: auto;
+ grid-template-rows: auto auto auto auto auto;
+ }
+
+ #wizard_container>img,
+ #wizard_container>.logo {
+ max-width: 250px;
+ max-height: 180px;
+ }
+
+ #wizard_container .input-group {
+ width: 90%;
+ }
+
+ #wizard_container>#plugins>.plugin {
+ max-height: 120px;
+ min-width: 25%;
+ }
+}
+
+/* PHONES */
+@media (max-width: 768px) {
+ #wizard_container .input-group {
+ width: 100%;
+ flex-direction: column;
+ align-items: stretch;
+ }
+
+ #wizard_container .input-group label {
+ display: block;
+ margin-bottom: 5px;
+ width: 100%;
+ text-align: left;
+ font-size: 14px;
+ }
+
+ #wizard_container .input-group select,
+ #wizard_container .input-group input,
+ #wizard_container .form-control {
+ width: 100%;
+ box-sizing: border-box;
+ }
+ #bt_quitJeeasyWizard {
+ top: 10px;
+ right: 10px;
+ }
+
+ #wizard_container {
+ padding: 10px;
+ grid-template-rows: auto auto auto auto auto;
+ text-align: center;
+ }
+
+ #wizard_container>img,
+ #wizard_container>.logo {
+ max-width: 200px;
+ max-height: 150px;
+ }
+
+ #wizard_container .form-control {
+ font-size: 16px;
+ }
+
+ #wizard_container>#plugins>.plugin {
+ min-width: 40%;
+ margin-bottom: 10px;
+ }
+
+ .navBtn,
+ #bt_jeedom_ready {
+ font-size: 30px;
+ }
+
+ .navDot {
+ width: 18px;
+ height: 18px;
+ margin: 3px;
+ }
+}
+
+
+
diff --git a/desktop/js/mobile.js b/desktop/js/mobile.js
index 3dfa1d0b..5861fb3f 100755
--- a/desktop/js/mobile.js
+++ b/desktop/js/mobile.js
@@ -14,13 +14,7 @@
* along with Jeedom. If not, see
++
++
++
++
++
++
++
| {{Id Cmd}} | +{{Nom de la Commande}} | +{{Type Générique}} | +
|---|---|---|
| '; + echo '' . $cmd->getId() . ''; + echo ' | '; + echo '';
+ echo $cmd->getName();
+ $display_icon = 'none';
+ $icon = '';
+ if (in_array($cmd->getGeneric_type(), ['GENERIC_INFO', 'GENERIC_ACTION'])) {
+ $display_icon = 'block';
+ $icon = $cmd->getDisplay('icon');
+ }
+ echo '
+ ';
+ echo '
+ ' . $icon . '
+ {{Icône}}
+
+ | ';
+ echo ''; + ?> + + '; + echo ' |
| {{Id Cmd}} | +{{Nom de la Commande}} | +{{Type Générique}} | +
|---|---|---|
| '; + echo '' . $cmd->getId() . ''; + echo ' | '; + echo '';
+ echo $cmd->getName();
+ $display_icon = 'none';
+ $icon = '';
+ if (in_array($cmd->getGeneric_type(), ['GENERIC_INFO', 'GENERIC_ACTION'])) {
+ $display_icon = 'block';
+ $icon = $cmd->getDisplay('icon');
+ }
+ echo '
+ ';
+ echo '
+ ' . $icon . '
+ {{Icône}}
+
+ | ';
+ echo ''; + ?> + + '; + echo ' |