From c5fe58ae39ac196197f7cf990375750a7393ca52 Mon Sep 17 00:00:00 2001 From: "Julien C." Date: Fri, 11 Jul 2025 11:20:55 +0200 Subject: [PATCH 01/58] add v1 methods --- core/api/mobile.api.php | 244 +++++++++++--- core/class/mobile.class.php | 635 +++++++++++++++++++++++++++++++++++- 2 files changed, 831 insertions(+), 48 deletions(-) diff --git a/core/api/mobile.api.php b/core/api/mobile.api.php index 07995210..30c7b5ae 100755 --- a/core/api/mobile.api.php +++ b/core/api/mobile.api.php @@ -43,6 +43,13 @@ } log::add('mobile', 'debug', '└───────────────────────────────────────────'); + + + + + + +// APP V2 // /** * Create a new equipment * Call by api setConfigs @@ -773,44 +780,203 @@ 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') { + if (jeedom::version() >= '3.2.0') { + log::add('mobile', 'debug', 'SYNC'); + 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'])) { + $mobile->setConfiguration('notificationArn', substr($params['notificationProvider'], 1, -1)); + } + if (isset($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'] != '' || isset($params['notificationRegistrationToken']) || $params['notificationRegistrationToken'] != 'nok') { + log::add('mobile', 'debug', 'notificationProvider Disponible'); + log::add('mobile', 'debug', 'EqLogic dispo'); + $arn = $mobile->getConfiguration('notificationArn', null); + $token = $mobile->getConfiguration('notificationRegistrationToken', null); + $arnMobile = substr($params['notificationProvider'], 1, -1); + $tokenMobile = $params['notificationRegistrationToken']; + if ($arn == null) { + log::add('mobile', 'debug', 'arn null dans la configuration > ' . $arn); + $mobile->setConfiguration('notificationArn', $arnMobile); + $mobile->save(); + } else { + log::add('mobile', 'debug', 'arn NON null dans la configuration > ' . $arn); + if ($arn != $arnMobile) { + $mobile->setConfiguration('notificationArn', $arnMobile); + $mobile->save(); + } + } + if ($token == 'nok'){ + log::add('mobile', 'debug', 'token null dans la configuration > ' . $token); + $mobile->setConfiguration('notificationRegistrationToken', $tokenMobile); + $mobile->save(); + }else{ + log::add('mobile', 'debug', 'Token dans la configuration > ' . $token); + if ($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'])); + $jsonrpc->makeSuccess($return); +} + +if ($jsonrpc->getMethod() == 'cmdsbyEqlogicID') { + log::add('mobile', 'debug', 'Interogation du module id:' . $params['id'] . ' Pour les 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', 'Commande > ' . 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() == 'askText') { + log::add('mobile', 'debug', 'TESTAPIASK'); + log::add('mobile', 'debug', 'Arrivée reponse ask Textuel depuis le mobile > ' . $params['Iq']); + /*$configs = $params['configs']; + $menu = $configs['menu']; + $notification = $configs['notification'];*/ + $mobile = eqLogic::byLogicalId($params['Iq'], 'mobile'); + log::add('mobile', 'debug', 'mobile >' . json_encode($mobile)); + if (is_object($mobile)) { + $askCasse = config::byKey('askCasse', 'mobile', false); + $textCasse = $params['text']; + if ($askCasse == false) { + $textCasse = strtolower($params['text']); + } + log::add('mobile', 'debug', 'Mobile bien trouvé casse -> ' . $askCasse . ' text : ' . $textCasse); + $cmd = $mobile->getCmd(null, 'notif'); + log::add('mobile', 'debug', 'IQ > ' . $params['Iq'] . ' demande cmd > ' . $cmd->getId()); + if ($cmd->askResponse($textCasse)) { + log::add('mobile', 'debug', 'ask bien trouvé : Réponse validée'); + $jsonrpc->makeSuccess(); + }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); + log::add('mobile', 'debug', $output); + $jsonrpc->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(); +} + +if ($jsonrpc->getMethod() == 'getMobile'){ + log::add('mobile', 'debug', 'Demande de recuperation '. $params['type'] .' > ' . $params['Iq'] .'('.mobile::whoIsIq($params['Iq']).') recuperation save du > ' . $params['IqRestore'] . ' ('. mobile::whoIsIq($params['IqRestore']) .')'); + $jsonrpc->makeSuccess(mobile::getSaveJson($params['IqRestore'], $params['type'])); +} + +if ($jsonrpc->getMethod() == 'geoloc'){ + log::add('mobile', 'debug', 'Geoloc '. $params['id'] .' > ' . $params['name'] .' > ' .$params['value']); + mobile::EventGeoloc($params); + $jsonrpc->makeSuccess(); +} + +if ($jsonrpc->getMethod() == 'geolocSave'){ + log::add('mobile', 'debug', 'Geoloc SAVE '. $params['id'] .' > ' . $params['name']); + if($params['id'] != '' || $params['id'] != null){ + mobile::SaveGeoloc($params); + $jsonrpc->makeSuccess(); + }else{ + throw new Exception(__('pas d\'id : ', __FILE__) . $params['name']); + } +} + +if ($jsonrpc->getMethod() == 'geolocDel'){ + log::add('mobile', 'debug', 'Geoloc DEL '. $params['id'] .' > ' . $params['name']); + mobile::delGeoloc($params); + $jsonrpc->makeSuccess(); +} throw new Exception(__('Aucune demande', __FILE__)); diff --git a/core/class/mobile.class.php b/core/class/mobile.class.php index 89223525..b507fda8 100755 --- a/core/class/mobile.class.php +++ b/core/class/mobile.class.php @@ -24,12 +24,24 @@ class mobile extends eqLogic { + + 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*************************** */ public static function cronDaily() { foreach (eqLogic::byType('mobile') as $mobile) { - $mobile->cleaningNotifications(); + if($mobile->getConfiguration('appVersion', 1) == 2) { + $mobile->cleaningNotifications(); + } + } } @@ -68,6 +80,9 @@ public static function getConfigForCommunity() return $res; } + /******************** APP V1 *************************/ + + /** * find eq based on iq * @@ -83,6 +98,603 @@ public static function whoIsIq($iq) } } + 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() + { + $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)); + $event_cmd = array(); + foreach ($data['cmds'] as $cmd) { + $event_cmd[] = $cmd['id']; + } + cache::set('mobile::event', $event_cmd); + } + + 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 ($_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; + } + + public function getQrCode() + { + require_once dirname(__FILE__) . '/../../3rdparty/phpqrcode/qrlib.php'; + $interne = network::getNetworkAccess('internal'); + $externe = network::getNetworkAccess('external'); + if ($interne == null || $interne == 'http://:80' || $interne == 'https://:80') { + return 'internalError'; + } + if ($externe == null || $externe == 'http://:80' || $externe == 'https://:80') { + return 'externalError'; + } + if ($this->getConfiguration('affect_user') == '') { + return 'UserError'; + } + $key = $this->getLogicalId(); + $request_qrcode = array( + 'eqLogic_id' => $this->getId(), + 'url_internal' => $interne, + 'url_external' => $externe, + 'Iq' => $key, + ); + if ($this->getConfiguration('affect_user') != '') { + $username = user::byId($this->getConfiguration('affect_user')); + if (is_object($username)) { + $request_qrcode['username'] = $username->getLogin(); + $request_qrcode['apikey'] = $username->getHash(); + } + } + ob_start(); + QRcode::png(json_encode($request_qrcode)); + $imageString = base64_encode(ob_get_contents()); + ob_end_clean(); + return $imageString; + } + + public function SaveGeoloc($geoloc) + { + log::add('mobile', 'debug', '|-----------------------------------'); + log::add('mobile', 'debug', '|--debut de la fonction SaveGeoLoc--'); + log::add('mobile', 'debug', '|-----------------------------------'); + log::add('mobile', 'debug', '|'); + $eqLogicMobile = eqLogic::byLogicalId($geoloc['Iq'], 'mobile'); + log::add('mobile', 'debug', '| Iq = ' . $geoloc['Iq']); + if (is_object($eqLogicMobile)) { + log::add('mobile', 'debug', '| Mobile bien trouvé dans cette Jeedom'); + log::add('mobile', 'debug', '| Objet > ' . $eqLogicMobile->getId()); + $cmdgeoloc = cmd::byEqLogicIdAndLogicalId($eqLogicMobile->getId(), 'geoId_' . $geoloc['id']); + if (!is_object($cmdgeoloc)) { + $cmdgeoloc = new mobileCmd(); + $cmdgeoloc->setLogicalId('geoId_' . $geoloc['id']); + $cmdgeoloc->setEqLogic_id($eqLogicMobile->getId()); + $cmdgeoloc->setType('info'); + $cmdgeoloc->setSubType('binary'); + $cmdgeoloc->setGeneric_type('PRESENCE'); + $cmdgeoloc->setIsVisible(1); + } + $cmdgeoloc->setName(__($geoloc['id'] . '-' . $geoloc['name'], __FILE__)); + $cmdgeoloc->setConfiguration('latitude', $geoloc['latitude']); + $cmdgeoloc->setConfiguration('longitude', $geoloc['longitude']); + $cmdgeoloc->setConfiguration('subtitle', $geoloc['subtitle']); + $cmdgeoloc->setConfiguration('radius', $geoloc['radius']); + $cmdgeoloc->save(); + $cmdgeoloc->event($geoloc['value']); + } + } + + public function delGeoloc($geoloc) + { + log::add('mobile', 'debug', 'Geoloc lancement DEL du mobile > ' . $geoloc['Iq'] . ' pour ' . $geoloc['id']); + $eqLogicMobile = eqLogic::byLogicalId($geoloc['Iq'], 'mobile'); + $cmdgeoloc = cmd::byEqLogicIdAndLogicalId($eqLogicMobile->getId(), 'geoId_' . $geoloc['id']); + if (isset($cmdgeoloc)) { + $cmdgeoloc->remove(); + } + } + + + public function EventGeoloc($geoloc) + { + log::add('mobile', 'debug', 'Geoloc Event du mobile > ' . $geoloc['Iq'] . ' pour ' . $geoloc['id']); + $eqLogicMobile = eqLogic::byLogicalId($geoloc['Iq'], 'mobile'); + $cmdgeoloc = cmd::byEqLogicIdAndLogicalId($eqLogicMobile->getId(), 'geoId_' . $geoloc['id']); + $cmdgeolocv2 = cmd::byEqLogicIdAndLogicalId($eqLogicMobile->getId(), 'geoloc_' . $geoloc['id']); + if (is_object($cmdgeoloc)) { + log::add('mobile', 'debug', 'commande trouvé'); + if ($geoloc['value'] !== $cmdgeoloc->execCmd()) { + log::add('mobile', 'debug', 'Valeur non pareille.'); + $cmdgeoloc->event($geoloc['value']); + } else { + log::add('mobile', 'debug', 'Valeur pareille. >' . $geoloc['value'] . ' / ' . $cmdgeoloc->execCmd()); + } + } + if (is_object($cmdgeolocv2)) { + log::add('mobile', 'debug', 'commande trouvé'); + if ($geoloc['value'] !== $cmdgeolocv2->execCmd()) { + log::add('mobile', 'debug', 'Valeur non pareille.'); + $cmdgeolocv2->event($geoloc['value']); + } else { + log::add('mobile', 'debug', 'Valeur pareille. >' . $geoloc['value'] . ' / ' . $cmdgeolocv2->execCmd()); + } + } + } + + + public static function deleteFileImg() + { + $directory = dirname(__FILE__) . '/../../data/images'; // Chemin vers le répertoire contenant les fichiers + // Récupérer la liste des fichiers dans le répertoire + $files = glob($directory . '/*'); + // Date actuelle + $currentDate = time(); + // Parcourir tous les fichiers + foreach ($files as $file) { + // Vérifier la date de modification du fichier + $modifiedDate = filemtime($file); + $differenceInDays = floor(($currentDate - $modifiedDate) / (60 * 60 * 24)); + // Vérifier si le fichier a plus de 30 jours + if ($differenceInDays > 30) { + // Supprimer le fichier + unlink($file); + } + } + } + + + + + + /******************** APP V2 *************************/ + /** * get json for notification * Call by class notification @@ -971,7 +1583,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(); } @@ -1081,14 +1695,17 @@ public function postSave() - $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(); + } } + } /** From de67f48b96c4c52227c7c4243b87a5f10feb5c39 Mon Sep 17 00:00:00 2001 From: "Julien C." Date: Fri, 11 Jul 2025 15:06:54 +0200 Subject: [PATCH 02/58] fix 500 --- core/class/mobile.class.php | 34 ---------------------------------- desktop/js/mobile.js | 17 +++++++++++++++++ desktop/php/mobile.php | 12 +++++------- 3 files changed, 22 insertions(+), 41 deletions(-) diff --git a/core/class/mobile.class.php b/core/class/mobile.class.php index b507fda8..f99099e8 100755 --- a/core/class/mobile.class.php +++ b/core/class/mobile.class.php @@ -565,40 +565,6 @@ public static function delete_object_eqlogic_null($objects, $eqLogics) return $return; } - public function getQrCode() - { - require_once dirname(__FILE__) . '/../../3rdparty/phpqrcode/qrlib.php'; - $interne = network::getNetworkAccess('internal'); - $externe = network::getNetworkAccess('external'); - if ($interne == null || $interne == 'http://:80' || $interne == 'https://:80') { - return 'internalError'; - } - if ($externe == null || $externe == 'http://:80' || $externe == 'https://:80') { - return 'externalError'; - } - if ($this->getConfiguration('affect_user') == '') { - return 'UserError'; - } - $key = $this->getLogicalId(); - $request_qrcode = array( - 'eqLogic_id' => $this->getId(), - 'url_internal' => $interne, - 'url_external' => $externe, - 'Iq' => $key, - ); - if ($this->getConfiguration('affect_user') != '') { - $username = user::byId($this->getConfiguration('affect_user')); - if (is_object($username)) { - $request_qrcode['username'] = $username->getLogin(); - $request_qrcode['apikey'] = $username->getHash(); - } - } - ob_start(); - QRcode::png(json_encode($request_qrcode)); - $imageString = base64_encode(ob_get_contents()); - ob_end_clean(); - return $imageString; - } public function SaveGeoloc($geoloc) { diff --git a/desktop/js/mobile.js b/desktop/js/mobile.js index 3dfa1d0b..c4df68b6 100755 --- a/desktop/js/mobile.js +++ b/desktop/js/mobile.js @@ -40,6 +40,23 @@ document.querySelector("#bt_qrCodev2")?.addEventListener("click", function (even }) function printEqLogic(_eqLogic) { + let appVersion = _eqLogic.configuration.appVersion; + if(appVersion != 2){ + setTimeout(function() { + let formGroupIq = document.getElementById('formGroupIq'); + if (formGroupIq) { + let qrDiv = document.createElement('div'); + qrDiv.className = 'col-lg-6'; + qrDiv.innerHTML = ` + {{QRCode}} +
+
+
+ `; + formGroupIq.parentNode.insertBefore(qrDiv, formGroupIq); + } + }, 300); + } domUtils.ajax({ type: "POST", url: "plugins/mobile/core/ajax/mobile.ajax.php", diff --git a/desktop/php/mobile.php b/desktop/php/mobile.php index 4f7db9c3..6b508fbd 100755 --- a/desktop/php/mobile.php +++ b/desktop/php/mobile.php @@ -26,7 +26,7 @@
- {{App V2 - (VERSION BETA SEULEMENT)}} + {{App V2}}

@@ -95,14 +95,12 @@
- = 1) { // AppV1 + = 0) { // AppV1 ?>
{{App V1}} +
-
- {{Attention, en beta il n'est plus possible d'utiliser l'APP V1}}
-
{{Mes Téléphones Mobiles}}
-
+
-
+
From adb608f1306c64b003097af63b359c358508fde9 Mon Sep 17 00:00:00 2001 From: David <79108364+Phpvarious@users.noreply.github.com> Date: Tue, 15 Jul 2025 00:05:26 +0200 Subject: [PATCH 03/58] addV1 --- core/ajax/mobile.ajax.php | 39 +++- core/api/mobile.api.php | 32 +-- core/class/mobile.class.php | 117 +++++++--- desktop/js/mobile.js | 212 ++++++++++++++--- desktop/modal/AppV1Object.mobile.php | 277 ++++++++++++++++++++++ desktop/modal/AppV1Piece.php | 64 ++++++ desktop/modal/AppV1Plugin.mobile.php | 332 +++++++++++++++++++++++++++ desktop/modal/AppV1Plugin.php | 206 +++++++++++++++++ desktop/modal/AppV1Scenario.php | 112 +++++++++ desktop/php/mobile.php | 212 +++++++++++++---- plugin_info/install.php | 10 +- 11 files changed, 1468 insertions(+), 145 deletions(-) create mode 100644 desktop/modal/AppV1Object.mobile.php create mode 100644 desktop/modal/AppV1Piece.php create mode 100644 desktop/modal/AppV1Plugin.mobile.php create mode 100644 desktop/modal/AppV1Plugin.php create mode 100644 desktop/modal/AppV1Scenario.php diff --git a/core/ajax/mobile.ajax.php b/core/ajax/mobile.ajax.php index 08459a87..5401b1e2 100755 --- a/core/ajax/mobile.ajax.php +++ b/core/ajax/mobile.ajax.php @@ -60,7 +60,44 @@ ajax::success($return); } + // 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()); -} +} \ No newline at end of file diff --git a/core/api/mobile.api.php b/core/api/mobile.api.php index 30c7b5ae..ecd02e02 100755 --- a/core/api/mobile.api.php +++ b/core/api/mobile.api.php @@ -43,12 +43,6 @@ } log::add('mobile', 'debug', '└───────────────────────────────────────────'); - - - - - - // APP V2 // /** * Create a new equipment @@ -514,17 +508,6 @@ function saveMenuFromAppV2($menu, $mobile) $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 * @@ -780,13 +763,8 @@ function saveMenuFromAppV2($menu, $mobile) $jsonrpc->makeSuccess($return); } - - - - // APP V1 // - if ($jsonrpc->getMethod() == 'sync') { if (jeedom::version() >= '3.2.0') { log::add('mobile', 'debug', 'SYNC'); @@ -829,7 +807,7 @@ function saveMenuFromAppV2($menu, $mobile) $mobile->save(); $params['Iq'] = $mobile->getLogicalId(); } - if (isset($params['notificationProvider']) || $params['notificationProvider'] != '' || isset($params['notificationRegistrationToken']) || $params['notificationRegistrationToken'] != 'nok') { + if (isset($params['notificationProvider']) && $params['notificationProvider'] != '' || isset($params['notificationRegistrationToken']) && $params['notificationRegistrationToken'] != 'nok') { log::add('mobile', 'debug', 'notificationProvider Disponible'); log::add('mobile', 'debug', 'EqLogic dispo'); $arn = $mobile->getConfiguration('notificationArn', null); @@ -847,11 +825,11 @@ function saveMenuFromAppV2($menu, $mobile) $mobile->save(); } } - if ($token == 'nok'){ - log::add('mobile', 'debug', 'token null dans la configuration > ' . $token); + if ($token == 'nok') { + log::add('mobile', 'debug', 'token null dans la configuration > ' . $token); $mobile->setConfiguration('notificationRegistrationToken', $tokenMobile); $mobile->save(); - }else{ + } else { log::add('mobile', 'debug', 'Token dans la configuration > ' . $token); if ($token != $tokenMobile) { $mobile->setConfiguration('notificationRegistrationToken', $tokenMobile); @@ -947,7 +925,7 @@ function saveMenuFromAppV2($menu, $mobile) } if ($jsonrpc->getMethod() == 'saveMobile'){ - log::add('mobile', 'debug', 'Demande de sauvegarde '. $params['type'] .' > ' . $params['Iq'] .' > '. mobile::whoIsIq($params['Iq'])); + 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(); } diff --git a/core/class/mobile.class.php b/core/class/mobile.class.php index f99099e8..707a0162 100755 --- a/core/class/mobile.class.php +++ b/core/class/mobile.class.php @@ -24,7 +24,6 @@ class mobile extends eqLogic { - 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'); @@ -43,6 +42,8 @@ public static function cronDaily() } } + // App V1 + mobile::makeTemplateJsonV1(); } /** @@ -389,12 +390,12 @@ public static function change_cmdAndeqLogic($_cmds, $_eqLogics) $_cmds[$plage_cmd]['eqLogic_id'] = $new_eqLogic_id; $keys = array_keys(array_column($_cmds, 'eqLogic_id'), $eqLogic_id); foreach ($keys as $key) { - if ($_cmds[$key]['value'] == $_cmds[$plage_cmd]['id'] && $_cmds[$key]['type'] == 'action') { + 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++; + //$i++; } $column_eqlogic = array_column($eqLogics, 'id'); foreach ($eqLogic_array as $eqlogic_array_one) { @@ -566,7 +567,7 @@ public static function delete_object_eqlogic_null($objects, $eqLogics) } - public function SaveGeoloc($geoloc) + public function SaveGeoloc($geoloc) { log::add('mobile', 'debug', '|-----------------------------------'); log::add('mobile', 'debug', '|--debut de la fonction SaveGeoLoc--'); @@ -597,7 +598,7 @@ public function SaveGeoloc($geoloc) } } - public function delGeoloc($geoloc) + public function delGeoloc($geoloc) { log::add('mobile', 'debug', 'Geoloc lancement DEL du mobile > ' . $geoloc['Iq'] . ' pour ' . $geoloc['id']); $eqLogicMobile = eqLogic::byLogicalId($geoloc['Iq'], 'mobile'); @@ -608,7 +609,7 @@ public function delGeoloc($geoloc) } - public function EventGeoloc($geoloc) + public function EventGeoloc($geoloc) { log::add('mobile', 'debug', 'Geoloc Event du mobile > ' . $geoloc['Iq'] . ' pour ' . $geoloc['id']); $eqLogicMobile = eqLogic::byLogicalId($geoloc['Iq'], 'mobile'); @@ -698,6 +699,7 @@ public static function jsonPublish($os, $titre, $message, $type, $idNotif, $answ } else if ($os == 'microsoft') { } } else { + //App V2 if ($version == 2) { if ($addAsk != '') { $askParams = [ @@ -866,6 +868,46 @@ public static function jsonPublish($os, $titre, $message, $type, $idNotif, $answ log::add('mobile', 'debug', '||| [INFO] Notification enregistrée : ' . 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)); @@ -881,8 +923,8 @@ 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 ($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'); @@ -940,9 +982,9 @@ public static function notification($arn, $os, $titre, $message, $type, $idNotif throw new Exception(__('Echec de l\'envoi de la notification :', __FILE__) . json_encode($result)); } } - } else { - log::add('mobile', 'error', __("Échec de l'envoi de notification : la version 1 de l'app n'est plus prise en charge !", __FILE__)); - } + //} else { + //log::add('mobile', 'error', __("Échec de l'envoi de notification : la version 1 de l'app n'est plus prise en charge !", __FILE__)); + //} log::add('mobile', 'debug', '|└────────────────────'); } @@ -1549,7 +1591,7 @@ public function postInsert() $key = config::genKey(32); $this->setLogicalId($key); } - if($this->getConfiguration('appVersion', 1) == 2) { + if ($this->getConfiguration('appVersion', 1) == 2) { $this->setConfiguration('defaultIdMobile', $this->getId()); } $this->save(); @@ -1560,15 +1602,36 @@ public function postInsert() */ public function postSave() { + $order = count($this->getCmd()); + + // Commande notification + $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'); + // Commande notification Critique + $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); @@ -1582,21 +1645,6 @@ 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'); if (!is_object($cmd)) { $cmd = new mobileCmd(); @@ -1659,8 +1707,6 @@ public function postSave() if ($cmd->getChanged() === true) $cmd->save(); } - - if ($this->getConfiguration('appVersion', 1) != 2) { $cmdaskText = $this->getCmd(null, 'ask_Text'); if (is_object($cmdaskText)) { @@ -1802,7 +1848,6 @@ public function execute($_options = array()) log::add('mobile', 'debug', '└────────────────────'); } - if ($this->getLogicalId() == 'notif' || $this->getLogicalId() == 'notifCritical' || $this->getLogicalId() == 'notifSpecific' || $this->getLogicalId() == 'notifSilent') { $critical = false; $silent = false; @@ -1905,4 +1950,4 @@ public function execute($_options = array()) } /* * **********************Getteur Setteur*************************** */ -} +} \ No newline at end of file diff --git a/desktop/js/mobile.js b/desktop/js/mobile.js index c4df68b6..1e9fc5d6 100755 --- a/desktop/js/mobile.js +++ b/desktop/js/mobile.js @@ -14,6 +14,8 @@ * along with Jeedom. If not, see . */ +// AppV2 \\\ + document.querySelector("#info_app")?.addEventListener("click", function (event) { jeeDialog.dialog({ id: "infosApp", @@ -39,50 +41,204 @@ document.querySelector("#bt_qrCodev2")?.addEventListener("click", function (even }) }) -function printEqLogic(_eqLogic) { - let appVersion = _eqLogic.configuration.appVersion; - if(appVersion != 2){ - setTimeout(function() { - let formGroupIq = document.getElementById('formGroupIq'); - if (formGroupIq) { - let qrDiv = document.createElement('div'); - qrDiv.className = 'col-lg-6'; - qrDiv.innerHTML = ` - {{QRCode}} -
-
-
- `; - formGroupIq.parentNode.insertBefore(qrDiv, formGroupIq); - } - }, 300); - } +// AppV1 \\ + +document.querySelector("#bt_pluginmobile")?.addEventListener("click", function (event) { + jeeDialog.dialog({ + id: "pluginsCompatibles", + title: "{{Plugins compatibles - Application V1}}", + contentUrl: "index.php?v=d&plugin=mobile&modal=AppV1Plugin", + }); +}); +document.querySelector("#bt_piecemobile")?.addEventListener("click", function (event) { + jeeDialog.dialog({ + id: "objectsModal", + title: "{{Objets / Pièces - Application V1}}", + contentUrl: "index.php?v=d&plugin=mobile&modal=AppV1Piece", + }); +}); +document.querySelector("#bt_scenariomobile")?.addEventListener("click", function (event) { + jeeDialog.dialog({ + id: "scenariosModal", + title: "{{Scénarios - Application V1}}", + contentUrl: "index.php?v=d&plugin=mobile&modal=AppV1Scenario", + }); +}); +document.querySelector("#bt_regenConfig")?.addEventListener("click", function (event) { domUtils.ajax({ type: "POST", url: "plugins/mobile/core/ajax/mobile.ajax.php", data: { - action: "getAffectUserByEqlogic", - id: _eqLogic.id, + action: "AppV1RegenConfig", }, dataType: "json", - global: false, error: function (request, status, error) { - domUtils.handleAjaxError(request, status, error) + domUtils.handleAjaxError(request, status, error) }, success: function (data) { if (data.state != "ok") { jeedomUtils.showAlert({ message: data.result, level: "danger" }) return } - let el = document.querySelector(".affect_user") - if (el != null) { - el.innerHTML = data.result + jeedomUtils.showAlert({ message: "{{Configuration mise à jour}}", level: "success"}); + }, + }); +}); + +// Copie pour monitoring +var toCopy = document.getElementById("to-copy-monitoring"); +var arnComplet = document.getElementById("arnComplet"); +document.getElementById("copy-monitoring")?.addEventListener("click", function () { + if (arnComplet.jeeValue() != '') { + var fichier = arnComplet.jeeValue(); + var fichierCouper = fichier.substr(44); + toCopy.value = fichierCouper; + toCopy.select(); + document.execCommand("copy"); + return false; + } +}); + +///////////////// + + +function printEqLogic(_eqLogic) { + let appVersion = _eqLogic.configuration.appVersion; + console.log(appVersion) + if (appVersion == 2) { + document.querySelectorAll(".paramV1").unseen() + document.querySelectorAll(".paramV2").seen() + } else { + document.querySelectorAll(".paramV2").unseen() + document.querySelectorAll(".paramV1").seen() + + } + + // AppV1 + if (appVersion != 2) { + domUtils.ajax({ + type: "POST", + url: "plugins/mobile/core/ajax/mobile.ajax.php", + data: { + action: "getQrCode", + id: _eqLogic.id, + }, + dataType: "json", + global: false, + error: function (request, status, error) { + domUtils.handleAjaxError(request, status, error) + }, + success: function (data) { + if (data.state != "ok") { + jeedomUtils.showAlert({ message: data.result, level: "danger" }) + return + } + let el = document.querySelector(".qrCodeImg"); + el.innerHTML = ""; + if (data.result == "internalError") { + el.innerHTML = "{{Erreur pas d'adresse interne (voir configuration de votre Jeedom !)}}"; + } else if (data.result == "externalError") { + el.innerHTML = "{{Erreur pas d'adresse externe (voir configuration de votre Jeedom !)}}"; + } else if (data.result == "UserError") { + el.innerHTML = "{{Erreur pas d'utilisateur selectionné}}"; + } else { + el.innerHTML = ''; + } + }, + }); + + domUtils.ajax({ + type: "POST", + url: "plugins/mobile/core/ajax/mobile.ajax.php", + data: { + action: "AppV2GetSaveFavDash", + iq: _eqLogic.logicalId, + }, + dataType: "json", + global: false, + error: function (request, status, error) { + domUtils.handleAjaxError(request, status, error) + }, + success: function (data) { + if (data.state != "ok") { + jeedomUtils.showAlert({ message: data.result, level: "danger" }) + return + } + let saveFav = document.querySelector("#SaveFav") + if (is_object(saveFav)) { + if (data.result == true) { + saveFav.removeClass('danger').addClass('success') + saveFav.innerHTML = "OK" + } else if (data.result == false) { + saveFav.removeClass('success').addClass('danger') + saveFav.innerHTML = "NOK" + } + } } + }); + + domUtils.ajax({ + type: "POST", + url: "plugins/mobile/core/ajax/mobile.ajax.php", + data: { + action: "AppV2GetSaveDashboard", + iq: _eqLogic.logicalId, + }, + dataType: "json", + global: false, + error: function (request, status, error) { + domUtils.handleAjaxError(request, status, error) + }, + success: function (data) { + if (data.state != "ok") { + jeedomUtils.showAlert({ message: data.result, level: "danger" }) + return + } + let savedash = document.querySelector("#SaveDash"); + if (is_object(savedash)) { + if (data.result == true) { + savedash.removeClass('danger').addClass('success') + savedash.innerHTML = "OK"; + } else if (data.result == false) { + savedash.removeClass('success').addClass('danger') + savedash.innerHTML = "NOK"; + } + } + }, + }); + + document.getElementById("copy-monitoring")?.click() + } + + /// if delete code appV1 in mobile.php into Paramètres spécifiques -> + /// change by + if (_eqLogic.configuration.type_mobile) { + let el = document.querySelector(".type_mobile") + if (is_object(el)) { + let select = document.querySelector('.eqLogicAttr[data-l1key="configuration"][data-l2key="type_mobile"]') + if (is_object(select)) el.innerHTML = select.options[select.selectedIndex].text } - }) + } + /// if delete code appV1 in mobile.php into Paramètres spécifiques -> + /// change by + if (_eqLogic.configuration.affect_user) { + let el = document.querySelector(".affect_user") + if (is_object(el)) { + let select = document.querySelector('.eqLogicAttr[data-l1key="configuration"][data-l2key="affect_user"]') + if (is_object(select)) el.innerHTML = select.options[select.selectedIndex].text + } + } + // AppV1 + if (_eqLogic.configuration.notificationRegistrationToken) { + let el = document.getElementById("notificationRegistrationToken") + if (is_object(el)) { + el.value = _eqLogic.configuration.notificationRegistrationToken + } + } } function addCmdToTable(_cmd) { + console.log('addCmdToTable') if (document.getElementById('table_cmd') == null) return if (!isset(_cmd)) { var _cmd = { configuration: {} } @@ -123,7 +279,7 @@ function addCmdToTable(_cmd) { } tr += "" tr += "" - if (init(_cmd.logicalId) !== "notif" && init(_cmd.logicalId) !== "notifCritical") { + if (init(_cmd.logicalId) !== "notif" && init(_cmd.logicalId) !== "notifCritical" && init(_cmd.logicalId) !== "notifSilent") { tr += '' } tr += "" @@ -144,4 +300,4 @@ function addCmdToTable(_cmd) { jeedom.cmd.changeType(newRow, init(_cmd.subType)) } }) -} +} \ No newline at end of file diff --git a/desktop/modal/AppV1Object.mobile.php b/desktop/modal/AppV1Object.mobile.php new file mode 100644 index 00000000..75b7e4b5 --- /dev/null +++ b/desktop/modal/AppV1Object.mobile.php @@ -0,0 +1,277 @@ +. + */ + +ini_set('display_errors', 0); +if (!isConnect('admin')) { + throw new Exception('{{401 - Accès non autorisé}}'); +} + +$object = jeeObject::byId($_GET['object_id']); +sendVarToJS('object', $_GET['object_id']); +?> + + +
+'; +echo '{{Envoyer cette pièce vers l\'application}}'; +$check = 'checked'; +if ($object->getDisplay('sendToApp', 1) == 0) { + $check = 'unchecked'; +} +echo ''; +?> + + + +
+ {{Type Générique de cet objet}} + {{Sauvegarder}} + + +
+ getEqLogic(); + $checkHomebridge = ''; + echo '
'; + foreach ($eqLogics as $eqLogic) { + echo '
'; + echo ' '; + echo '
'; + echo '
'; + $cmds = null; + $cmds = cmd::byEqLogicId($eqLogic->getId()); + echo ''; + echo ' + + + + '; + foreach ($cmds as $cmd) { + array_push($tableau_cmd, $cmd->getId()); + echo ''; + echo ''; + echo ''; + echo ''; + } + echo '
{{Id Cmd}}{{Nom de la Commande}}{{Type Générique}}
'; + echo '' . $cmd->getId() . ''; + 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 '
+
+ ' . $icon . ' + {{Icône}} +
+
'; + echo '
'; + ?> + + '; + echo '
'; + echo '
'; + echo '
'; + echo '
'; + } + echo '
'; + ?> + {{Sauvegarder}} + + '; + ?> +
+ + \ No newline at end of file diff --git a/desktop/modal/AppV1Piece.php b/desktop/modal/AppV1Piece.php new file mode 100644 index 00000000..6645fe32 --- /dev/null +++ b/desktop/modal/AppV1Piece.php @@ -0,0 +1,64 @@ +. + */ + +if (!isConnect('admin')) { + throw new Exception('{{401 - Accès non autorisé}}'); +} +sendVarToJS('eqType', 'mobile'); +$eqLogics = eqLogic::byType('mobile'); +$plugins = plugin::listPlugin(true); +$plugin_compatible = mobile::$_pluginSuported; +$plugin_widget = mobile::$_pluginWidget; +?> + + {{Les Pièces - Application V1}} +
+ getDisplay('sendToApp', 1) == 0) { + $opacity = 'opacity:0.3;'; + } + $_echo .= '
'; + $_echo .= $object->getDisplay('icon', ''); + $_echo .= '
' . $object->getName() . '
'; + $_echo .= '
'; + } + echo $_echo; + ?> +
+ + + \ No newline at end of file diff --git a/desktop/modal/AppV1Plugin.mobile.php b/desktop/modal/AppV1Plugin.mobile.php new file mode 100644 index 00000000..9f0d031b --- /dev/null +++ b/desktop/modal/AppV1Plugin.mobile.php @@ -0,0 +1,332 @@ +. + */ +ini_set('display_errors', 0); +if (!isConnect('admin')) { + throw new Exception('{{401 - Accès non autorisé}}'); +} + +$plugin_compatible = mobile::$_pluginSuported; +$plugin_widget = mobile::$_pluginWidget; +$plugin = plugin::byId($_GET['plugin_id']); +sendVarToJS('pluginId', $_GET['plugin_id']); +?> + + + + +
+ {{Envoi auprès de l'app mobile}} + getId(), $plugin_widget)) { + $div = ''; + $div .= '
'; + $path = dirname(__FILE__) . '/../../core/template/images/' . $plugin->getId(); + if (file_exists($path)) { + $files = scandir($path); + foreach ($files as $imgname) { + if (!in_array($imgname, ['.', '..'])) { + $div .= ''; + } + } + } + $div .= '
'; + echo $div; + $generique_ok = false; + } else if (in_array($plugin->getId(), $plugin_compatible)) { + $div = ''; + echo $div; + $generique_ok = true; + } else { + $div = ''; + echo $div; + $generique_ok = true; + } + ?> +
+'; + echo ' {{Type Générique du Plugin}} {{Sauvegarder}}'; +?> +
+ '; + foreach ($eqLogics as $eqLogic) { + echo '
'; + if ($eqLogic->getEqType_name() != $_GET['plugin_id']) { + $subClassName = ' (' . $eqLogic->getEqType_name() . ') '; + } else { + $subClassName = ''; + } + $eqLogicId = $eqLogic->getId(); + echo ' '; + echo '
'; + echo '
'; + $cmds = null; + $cmds = cmd::byEqLogicId($eqLogicId); + echo ''; + echo ' + + + + '; + foreach ($cmds as $cmd) { + array_push($tableau_cmd, $cmd->getId()); + echo ''; + echo ''; + echo ''; + echo ''; + } + echo '
{{Id Cmd}}{{Nom de la Commande}}{{Type Générique}}
'; + echo '' . $cmd->getId() . ''; + 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 '
+
+ ' . $icon . ' + {{Icône}} +
+
'; + echo '
'; + ?> + + '; + echo '
'; + echo '
'; + echo '
'; + echo '
'; + } + echo '
'; + ?> + {{Sauvegarder}} +'; +} +?> +
+ + + + \ No newline at end of file diff --git a/desktop/modal/AppV1Plugin.php b/desktop/modal/AppV1Plugin.php new file mode 100644 index 00000000..fc80709c --- /dev/null +++ b/desktop/modal/AppV1Plugin.php @@ -0,0 +1,206 @@ +. + */ + +if (!isConnect('admin')) { + throw new Exception('{{401 - Accès non autorisé}}'); +} +sendVarToJS('eqType', 'mobile'); +$eqLogics = eqLogic::byType('mobile'); +$plugins = plugin::listPlugin(true); +$plugin_compatible = mobile::$_pluginSuported; +$plugin_widget = mobile::$_pluginWidget; +?> + +{{Plugins Spéciaux Compatibles}} + + +
+ getId() != 'mobile' && $plugin->getId() != 'homebridge') { + if (in_array($plugin->getId(), $plugin_compatible)) { + if (in_array($plugin->getId(), $plugin_widget)) { + $_echo .= '
'; + $_echo .= '
'; + $_echo .= ''; + $_echo .= '
'; + $_echo .= '' . $plugin->getName() . ''; + $_echo .= '
'; + $num++; + } + } + } + } + echo $_echo; + if ($num == 0) { + echo ''; + } + ?> +
+ +{{Plugins Validés Type générique}} + + +
+ getId() != 'mobile' && $plugin->getId() != 'homebridge') { + if (in_array($plugin->getId(), $plugin_compatible)) { + if (config::byKey('sendToApp', $plugin->getId(), 1) == 1 && !in_array($plugin->getId(), $plugin_widget)) { + $_echo .= '
'; + $_echo .= '
'; + $_echo .= ''; + $_echo .= '
'; + $_echo .= '' . $plugin->getName() . ''; + $_echo .= '
'; + $num++; + } + } + } + } + echo $_echo; + if ($num == 0) { + echo ''; + } + ?> +
+ +{{Plugins compatibles non transmis}} + + +
+ getId() != 'mobile' && $plugin->getId() != 'homebridge') { + if (in_array($plugin->getId(), $plugin_compatible)) { + if (config::byKey('sendToApp', $plugin->getId(), 1) != 1 && !in_array($plugin->getId(), $plugin_widget)) { + $opacity = jeedom::getConfiguration('eqLogic:style:noactive'); + $_echo .= '
'; + $_echo .= '
'; + $_echo .= ''; + $_echo .= '
'; + $_echo .= '' . $plugin->getName() . ''; + $_echo .= '
'; + $num++; + } + } + } + } + echo $_echo; + if ($num == 0) { + echo ''; + } + ?> +
+ +{{Plugins non testés transmis}} + + +
+ getId() != 'mobile' && $plugin->getId() != 'homebridge') { + if (!in_array($plugin->getId(), $plugin_compatible)) { + if (config::byKey('sendToApp', $plugin->getId(), 0) == 1) { + $_echo .= '
'; + $_echo .= '
'; + $_echo .= ''; + $_echo .= '
'; + $_echo .= '' . $plugin->getName() . ''; + $_echo .= '
'; + $num++; + } + } + } + } + echo $_echo; + if ($num == 0) { + echo ''; + } + ?> +
+ +{{Plugins non testés et non transmis}} + + +
+ getId() != 'mobile' && $plugin->getId() != 'homebridge') { + if (!in_array($plugin->getId(), $plugin_compatible)) { + if (config::byKey('sendToApp', $plugin->getId(), 0) != 1) { + //$opacity = ''; jeedom::getConfiguration('eqLogic:style:noactive') + $_echo .= '
'; + $_echo .= '
'; + $_echo .= ''; + $_echo .= '
'; + $_echo .= '' . $plugin->getName() . ''; + $_echo .= '
'; + $num++; + } + } + } + } + echo $_echo; + if ($num == 0) { + echo ''; + } + ?> +
+ + + \ No newline at end of file diff --git a/desktop/modal/AppV1Scenario.php b/desktop/modal/AppV1Scenario.php new file mode 100644 index 00000000..e8d8c417 --- /dev/null +++ b/desktop/modal/AppV1Scenario.php @@ -0,0 +1,112 @@ +. + */ + +ini_set('display_errors', 0); +if (!isConnect('admin')) { + throw new Exception('{{401 - Accès non autorisé}}'); +} +?> +
+ {{Scénarios}} + + + +
+ + + + + + + + + + + getId(); + if ($scenario->getDisplay('sendToApp', 0) == 1) { + $check = 'checked'; + } + $tr = ''; + $tr .= ''; + $tr .= ''; + /*$tr .= ''; + echo $tr; + } + ?> + +
{{ID}}{{Scénario}}{{Transmis}}
' . $scenario_id . '' . $scenario->getHumanName() . '';*/ + $tr .= '
+
+
+ + \ No newline at end of file diff --git a/desktop/php/mobile.php b/desktop/php/mobile.php index 6b508fbd..46be856d 100755 --- a/desktop/php/mobile.php +++ b/desktop/php/mobile.php @@ -25,6 +25,8 @@ ?>
+ +
{{App V2}}
@@ -53,38 +55,36 @@ = 1) { // AppV2 foreach ($eqLogicsV2 as $eqLogic) { - if ($eqLogic->getConfiguration('appVersion', '1') == '2') { - $opacity = ($eqLogic->getIsEnable()) ? '' : 'disableCard'; - echo '
'; - /* getImage : - core 4.4 - returns plugin image - core 4.5 - returns the custom image if exist or else the plugin image - */ - if ($eqLogic->getImage() != 'plugins/mobile/plugin_info/mobile_icon.png') $logoV2 = $eqLogic->getImage(); - else if (file_exists('plugins/mobile/plugin_info/mobileV2_icon.png')) $logoV2 = 'plugins/mobile/plugin_info/mobileV2_icon.png'; - else $logoV2 = $eqLogic->getImage(); - echo ''; - echo ''; - if ($eqLogic->getConfiguration('type_mobile') == 'android') { - echo ''; - } else { - echo ''; - } - echo ''; - echo '
'; - echo '' . $eqLogic->getHumanName(true, true) . ''; - echo ''; - echo '
'; + $opacity = ($eqLogic->getIsEnable()) ? '' : 'disableCard'; + echo '
'; + /* getImage : + core 4.4 - returns plugin image + core 4.5 - returns the custom image if exist or else the plugin image + */ + if ($eqLogic->getImage() != 'plugins/mobile/plugin_info/mobile_icon.png') $logoV2 = $eqLogic->getImage(); + else if (file_exists('plugins/mobile/plugin_info/mobileV2_icon.png')) $logoV2 = 'plugins/mobile/plugin_info/mobileV2_icon.png'; + else $logoV2 = $eqLogic->getImage(); + echo ''; + echo ''; + if ($eqLogic->getConfiguration('type_mobile') == 'android') { + echo ''; + } else { + echo ''; } + echo ''; + echo '
'; + echo '' . $eqLogic->getHumanName(true, true) . ''; + echo ''; + echo '
'; } } else { echo '
'; @@ -95,15 +95,35 @@
- = 0) { // AppV1 - ?> -
- {{App V1}} + +
+ {{App V1}} +
+
+
+ {{Ajouter}} +
+
+
+ {{Plugins}} +
+
+
+ {{Objets/Pièces}} +
+
+
+ {{Scénarios}} +
+
+
+ {{Régénérer la configuration}} +
-
- {{Mes Téléphones Mobiles}} -
- {{Mes Téléphones Mobiles}} +
+ = 0) { // AppV1 foreach ($eqLogicsV1 as $eqLogic) { if ($eqLogic->getConfiguration('appVersion', '1') != '2') { $opacity = ($eqLogic->getIsEnable()) ? '' : 'disableCard'; @@ -135,10 +155,10 @@ echo '
'; } } - ?> -
+ } + ?>
- +
- - -
- - -
-
-
-
- {{Notifications}} - -
- -
- + {{Vérification en Cours}}
-
- +
+
- + {{Vérification en Cours}}
-
- +
- - -
-
-
-
-
-
-
-
-
-
- {{Sauvegarde}} -
- -
- {{Vérification en Cours}} -
-
-
- -
- {{Vérification en Cours}} + {{QRCode}} (V1) +
+
+
-
From ea83820000d6f0970edc0d02ffd122f49ce094f7 Mon Sep 17 00:00:00 2001 From: "Julien C." Date: Tue, 15 Jul 2025 13:08:21 +0200 Subject: [PATCH 05/58] add wizardDoc --- core/class/mobile.class.php | 9 + desktop/css/wizard.css | 363 ++++++++++++++++++++++++++++++++++++ desktop/js/mobile.js | 208 ++++++++++++++++++++- desktop/modal/doc2.php | 15 ++ desktop/modal/doc3.php | 15 ++ desktop/modal/welcome.php | 15 ++ desktop/php/mobile.php | 4 + desktop/php/wizard.php | 81 ++++++++ 8 files changed, 709 insertions(+), 1 deletion(-) create mode 100644 desktop/css/wizard.css create mode 100644 desktop/modal/doc2.php create mode 100644 desktop/modal/doc3.php create mode 100644 desktop/modal/welcome.php create mode 100644 desktop/php/wizard.php diff --git a/core/class/mobile.class.php b/core/class/mobile.class.php index 707a0162..b4685a9d 100755 --- a/core/class/mobile.class.php +++ b/core/class/mobile.class.php @@ -46,6 +46,15 @@ public static function cronDaily() mobile::makeTemplateJsonV1(); } + + public static function getWizardSteps(): array { + + $wizard['welcome'] = __('Accueil', __FILE__); + $wizard['doc2'] = __('Page2', __FILE__); + $wizard['doc3'] = __('Page3', __FILE__); + return $wizard; + } + /** * Core callback to provide additional information for a new Community post * diff --git a/desktop/css/wizard.css b/desktop/css/wizard.css new file mode 100644 index 00000000..5052e716 --- /dev/null +++ b/desktop/css/wizard.css @@ -0,0 +1,363 @@ +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>h3 { + grid-row-start: 1 +} + +#wizard_container>img { + max-width: 350px; + max-height: 225px; + 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 4be39e09..6f06457d 100755 --- a/desktop/js/mobile.js +++ b/desktop/js/mobile.js @@ -41,6 +41,11 @@ document.querySelector("#bt_qrCodev2")?.addEventListener("click", function (even }) }) + +document.querySelector("#bt_doc")?.addEventListener("click", function (event) { + jeedomUtils.loadPage('index.php?v=d&m=mobile&p=wizard') +}); + // AppV1 \\ document.querySelector("#bt_pluginmobile")?.addEventListener("click", function (event) { @@ -294,4 +299,205 @@ function addCmdToTable(_cmd) { jeedom.cmd.changeType(newRow, init(_cmd.subType)) } }) -} \ No newline at end of file +} + + + + +// WIZARD + + +var _contentContainer = document.getElementById('wizard_container'); +var currentStep = getUrlVars('step'); + +if (!currentStep) { + currentStep = localStorage.getItem('wizardStep') || document.querySelector('.navDot')?.dataset.step; +} +document.querySelector('.navDot[data-step="' + currentStep + '"]')?.classList.add('active'); +if (window.updateQuitButtonVisibility) window.updateQuitButtonVisibility(); +loadStep(currentStep); + +var slideOut = { + opacity: [1, 0], + transform: ['translateX(0)', 'translateX(-10%)'] +} +var slideIn = { + opacity: [0, 1], + transform: ['translateX(10%)', 'translateX(0)'] +} +var slideOutReverse = { + opacity: [1, 0], + transform: ['translateX(0)', 'translateX(10%)'] +} +var slideInReverse = { + opacity: [0, 1], + transform: ['translateX(-10%)', 'translateX(0)'] +} + +document.querySelectorAll('.navDot').forEach(_dot => { + _dot.addEventListener('click', function() { + let current = document.querySelector('.navDot.active') + + if (this == current || this.classList.contains('blocked')) { + return false + } + if (current.nextElementSibling?.classList.contains('blocked')) { + allowNavigation() + } + + let outAnimation = slideOut + let inAnimation = slideIn + if (Number(this.innerText) < Number(current.innerText)) { + outAnimation = slideOutReverse + inAnimation = slideInReverse + } + + _contentContainer.animate(outAnimation, { + duration: 500 + }) + setTimeout(() => { + document.querySelector('.navDot.active').classList.remove('active') + this.classList.add('active') + _contentContainer.empty() + localStorage.setItem('wizardStep', this.dataset.step); + loadStep(this.dataset.step) + _contentContainer.animate(inAnimation, { + duration: 500 + }) + if (window.updateQuitButtonVisibility) window.updateQuitButtonVisibility(); + }, 450) + }) +}) + +document.querySelectorAll('.navBtn').forEach(_navBtn => { + _navBtn.addEventListener('click', function() { + let activeNavDot = document.querySelector('.navDot.active') + if (this.classList.value.includes('bt_next')) { + activeNavDot.nextElementSibling.triggerEvent('click') + } else if (this.classList.value.includes('bt_prev')) { + activeNavDot.previousElementSibling.triggerEvent('click') + } + }) +}) + + +var quitBtn = document.getElementById('bt_quitmobileWizard'); +if (quitBtn) { + quitBtn.addEventListener('click', function() { + let confirm + confirm = "{{Voulez-vous vraiment fermer la documentation ?}}" + confirm += '

' + + bootbox.confirm(confirm, function(result) { + if (result) { + exitWizard() + } + }) + }) +} + +var readyBtn = document.getElementById('bt_jeedom_ready'); +if (readyBtn) { + readyBtn.addEventListener('click', function() { + exitWizard() + }) +} + +function loadStep(_step) { + updateNavigation(_step); + updateContent('index.php?v=d&plugin=mobile&modal=' + _step); +} + +function updateContent(_url) { + if (!_contentContainer) return; + _contentContainer.style.visibility = 'hidden'; + fetch(_url) + .then(response => response.text()) + .then(data => { + if (!_contentContainer) return; + _contentContainer.innerHTML = data; + + _contentContainer.querySelectorAll('script').forEach(_script => { + let newScript = document.createElement('script'); + if (_script.src) { + newScript.src = _script.src; + } else { + newScript.textContent = _script.textContent; + } + _contentContainer.appendChild(newScript); + _contentContainer.removeChild(newScript); + }); + + _contentContainer.style.visibility = 'visible'; + jeedomUtils.initTooltips(_contentContainer); + const stepOrder = Array.from(document.querySelectorAll('.navDot')).map(dot => dot.dataset.step); + }) + .catch(error => { + console.error('{{Erreur au chargement de la page}}:', error); + domUtils.hideLoading(); + if (_contentContainer) { + _contentContainer.style.visibility = 'visible'; + } + }); +} + + + +function updateNavigation(_step) { + let current = document.querySelector('.navDot[data-step="' + _step + '"]'); + if (!current) { + return; + } + document.querySelector('.navBtn.bt_next').dataset.step = _step + if (!current.previousElementSibling) { + document.querySelector('.navBtn.bt_prev')?.classList.add('hidden') + } else { + document.querySelector('.navBtn.bt_prev').title = current.previousElementSibling.dataset.title + document.querySelector('.navBtn.bt_prev.hidden')?.classList.remove('hidden') + } + if (!current.nextElementSibling) { + document.querySelector('.navBtn.bt_next')?.classList.add('hidden') + if (_step == 'ready') { + document.getElementById('bt_jeedom_ready')?.classList.remove('hidden') + } + } else { + document.getElementById('bt_jeedom_ready')?.classList.add('hidden') + document.querySelector('.navBtn.bt_next').title = current.nextElementSibling.dataset.title + document.querySelector('.navBtn.bt_next.hidden')?.classList.remove('hidden') + } + jeedomUtils.addOrUpdateUrl('step', _step); + localStorage.setItem('wizardStep', _step); + if (window.updateQuitButtonVisibility) window.updateQuitButtonVisibility(); +} + +function allowNavigation(_direction = 'both', _allowed = true) { + let current = document.querySelector('.navDot.active'); + if (_direction != 'next') { + let prevDot = current.previousElementSibling; + while (prevDot) { + if (!_allowed) { + prevDot.classList.add('blocked'); + } else { + prevDot.classList.remove('blocked'); + } + prevDot = prevDot.previousElementSibling; + } + } + if (_direction != 'prev') { + let nextDot = current.nextElementSibling; + while (nextDot) { + if (!_allowed) { + nextDot.classList.add('blocked'); + } else { + nextDot.classList.remove('blocked'); + } + nextDot = nextDot.nextElementSibling; + } + } +} + +function exitWizard() { + window.location.href = 'index.php?v=d&m=mobile&p=mobile'; +} + + diff --git a/desktop/modal/doc2.php b/desktop/modal/doc2.php new file mode 100644 index 00000000..4a312a7c --- /dev/null +++ b/desktop/modal/doc2.php @@ -0,0 +1,15 @@ + +

{{Documentation}}

+ Product Image + + \ No newline at end of file diff --git a/desktop/modal/doc3.php b/desktop/modal/doc3.php new file mode 100644 index 00000000..4a312a7c --- /dev/null +++ b/desktop/modal/doc3.php @@ -0,0 +1,15 @@ + +

{{Documentation}}

+ Product Image + + \ No newline at end of file diff --git a/desktop/modal/welcome.php b/desktop/modal/welcome.php new file mode 100644 index 00000000..4a312a7c --- /dev/null +++ b/desktop/modal/welcome.php @@ -0,0 +1,15 @@ + +

{{Documentation}}

+ Product Image + + \ No newline at end of file diff --git a/desktop/php/mobile.php b/desktop/php/mobile.php index ce3ee1d3..8f06cce1 100755 --- a/desktop/php/mobile.php +++ b/desktop/php/mobile.php @@ -42,6 +42,10 @@
{{QR Code}}
+
+
+ {{Documentation}} +
{{Mes Téléphones Mobiles}}
diff --git a/desktop/php/wizard.php b/desktop/php/wizard.php new file mode 100644 index 00000000..f69c4a6e --- /dev/null +++ b/desktop/php/wizard.php @@ -0,0 +1,81 @@ + + + + + +
+ +
+
+ +
+
+ $title) { + $finalAttr = ($step == 'finalization') ? ' data-finalization="1"' : ''; + echo ''; + echo $i; + echo ''; + $i++; + } + ?> +
+
+ + +
+
+
+ + + + + + From 7f6fe05a079d528e9e66e9debcfec1de9efcf998 Mon Sep 17 00:00:00 2001 From: David <79108364+Phpvarious@users.noreply.github.com> Date: Tue, 15 Jul 2025 15:02:57 +0200 Subject: [PATCH 06/58] notificationProvider --- core/api/mobile.api.php | 49 ++++---- desktop/js/mobile.js | 216 ++++++++++++++++++++++++++++++++++-- desktop/modal/AppV1Info.php | 68 ++++++++++++ desktop/php/mobile.php | 9 +- 4 files changed, 302 insertions(+), 40 deletions(-) create mode 100644 desktop/modal/AppV1Info.php diff --git a/core/api/mobile.api.php b/core/api/mobile.api.php index ecd02e02..f01696db 100755 --- a/core/api/mobile.api.php +++ b/core/api/mobile.api.php @@ -795,48 +795,39 @@ function saveMenuFromAppV2($menu, $mobile) $mobile->setConfiguration('type_mobile', $params['platform']); $mobile->setConfiguration('affect_user', $userId); $mobile->setConfiguration('validate', 'no'); - if (isset($params['notificationProvider'])) { + if (isset($params['notificationProvider']) && $params['notificationProvider'] != '') { $mobile->setConfiguration('notificationArn', substr($params['notificationProvider'], 1, -1)); } - if (isset($params['notificationRegistrationToken'])) { - if($params['notificationRegistrationToken'] != 'nok'){ - $mobile->setConfiguration('notificationRegistrationToken', $params['notificationRegistrationToken']); - } - } + 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'] != '' || isset($params['notificationRegistrationToken']) && $params['notificationRegistrationToken'] != 'nok') { - log::add('mobile', 'debug', 'notificationProvider Disponible'); - log::add('mobile', 'debug', 'EqLogic dispo'); - $arn = $mobile->getConfiguration('notificationArn', null); - $token = $mobile->getConfiguration('notificationRegistrationToken', null); + + if (isset($params['notificationProvider']) && $params['notificationProvider'] != '') { + log::add('mobile', 'debug', 'notificationProvider disponible'); + $arn = $mobile->getConfiguration('notificationArn', ''); $arnMobile = substr($params['notificationProvider'], 1, -1); - $tokenMobile = $params['notificationRegistrationToken']; - if ($arn == null) { - log::add('mobile', 'debug', 'arn null dans la configuration > ' . $arn); + if ($arn != $arnMobile) { $mobile->setConfiguration('notificationArn', $arnMobile); $mobile->save(); - } else { - log::add('mobile', 'debug', 'arn NON null dans la configuration > ' . $arn); - if ($arn != $arnMobile) { - $mobile->setConfiguration('notificationArn', $arnMobile); - $mobile->save(); - } } - if ($token == 'nok') { - log::add('mobile', 'debug', 'token null dans la configuration > ' . $token); + } + + if (isset($params['notificationRegistrationToken']) && $params['notificationRegistrationToken'] != 'nok' && $params['notificationRegistrationToken'] != '') { + log::add('mobile', 'debug', 'notificationRegistrationToken disponible'); + $token = $mobile->getConfiguration('notificationRegistrationToken', ''); + $tokenMobile = $params['notificationRegistrationToken']; + if ($arn != $arnMobile && $arnMobile != null) { $mobile->setConfiguration('notificationRegistrationToken', $tokenMobile); $mobile->save(); - } else { - log::add('mobile', 'debug', 'Token dans la configuration > ' . $token); - if ($token != $tokenMobile) { - $mobile->setConfiguration('notificationRegistrationToken', $tokenMobile); - $mobile->save(); - } - } + } } + if (isset($params['gen_json']) && $params['gen_json'] == 1) { mobile::makeTemplateJson(); } diff --git a/desktop/js/mobile.js b/desktop/js/mobile.js index 4be39e09..69f42cea 100755 --- a/desktop/js/mobile.js +++ b/desktop/js/mobile.js @@ -16,14 +16,6 @@ // AppV2 \\\ -document.querySelector("#info_app")?.addEventListener("click", function (event) { - jeeDialog.dialog({ - id: "infosApp", - title: "{{Informations envoyées à l'app}}", - contentUrl: "index.php?v=d&plugin=mobile&modal=info_app.mobile" - }) -}) - document.querySelector("#bt_handlePhones")?.addEventListener("click", function (event) { jeeDialog.dialog({ id: "menuCustom", @@ -41,8 +33,20 @@ document.querySelector("#bt_qrCodev2")?.addEventListener("click", function (even }) }) +document.querySelector("#bt_doc")?.addEventListener("click", function (event) { + jeedomUtils.loadPage('index.php?v=d&m=mobile&p=wizard') +}); + // AppV1 \\ +document.querySelector("#info_app")?.addEventListener("click", function (event) { + jeeDialog.dialog({ + id: "infosApp", + title: "{{Informations envoyées - Application V1}}", + contentUrl: "index.php?v=d&plugin=mobile&modal=AppV1Info" + }) +}) + document.querySelector("#bt_pluginmobile")?.addEventListener("click", function (event) { jeeDialog.dialog({ id: "pluginsCompatibles", @@ -98,7 +102,6 @@ document.getElementById("copy-monitoring")?.addEventListener("click", function ( return false; } }); - ///////////////// @@ -294,4 +297,199 @@ function addCmdToTable(_cmd) { jeedom.cmd.changeType(newRow, init(_cmd.subType)) } }) +} + +// WIZARD + +var _contentContainer = document.getElementById('wizard_container'); +var currentStep = getUrlVars('step'); + +if (!currentStep) { + currentStep = localStorage.getItem('wizardStep') || document.querySelector('.navDot')?.dataset.step; +} +document.querySelector('.navDot[data-step="' + currentStep + '"]')?.classList.add('active'); +if (window.updateQuitButtonVisibility) window.updateQuitButtonVisibility(); +loadStep(currentStep); + +var slideOut = { + opacity: [1, 0], + transform: ['translateX(0)', 'translateX(-10%)'] +} +var slideIn = { + opacity: [0, 1], + transform: ['translateX(10%)', 'translateX(0)'] +} +var slideOutReverse = { + opacity: [1, 0], + transform: ['translateX(0)', 'translateX(10%)'] +} +var slideInReverse = { + opacity: [0, 1], + transform: ['translateX(-10%)', 'translateX(0)'] +} + +document.querySelectorAll('.navDot').forEach(_dot => { + _dot.addEventListener('click', function() { + let current = document.querySelector('.navDot.active') + + if (this == current || this.classList.contains('blocked')) { + return false + } + if (current.nextElementSibling?.classList.contains('blocked')) { + allowNavigation() + } + + let outAnimation = slideOut + let inAnimation = slideIn + if (Number(this.innerText) < Number(current.innerText)) { + outAnimation = slideOutReverse + inAnimation = slideInReverse + } + + _contentContainer.animate(outAnimation, { + duration: 500 + }) + setTimeout(() => { + document.querySelector('.navDot.active').classList.remove('active') + this.classList.add('active') + _contentContainer.empty() + localStorage.setItem('wizardStep', this.dataset.step); + loadStep(this.dataset.step) + _contentContainer.animate(inAnimation, { + duration: 500 + }) + if (window.updateQuitButtonVisibility) window.updateQuitButtonVisibility(); + }, 450) + }) +}) + +document.querySelectorAll('.navBtn').forEach(_navBtn => { + _navBtn.addEventListener('click', function() { + let activeNavDot = document.querySelector('.navDot.active') + if (this.classList.value.includes('bt_next')) { + activeNavDot.nextElementSibling.triggerEvent('click') + } else if (this.classList.value.includes('bt_prev')) { + activeNavDot.previousElementSibling.triggerEvent('click') + } + }) +}) + + +var quitBtn = document.getElementById('bt_quitmobileWizard'); +if (quitBtn) { + quitBtn.addEventListener('click', function() { + let confirm + confirm = "{{Voulez-vous vraiment fermer la documentation ?}}" + confirm += '

' + + bootbox.confirm(confirm, function(result) { + if (result) { + exitWizard() + } + }) + }) +} + +var readyBtn = document.getElementById('bt_jeedom_ready'); +if (readyBtn) { + readyBtn.addEventListener('click', function() { + exitWizard() + }) +} + +function loadStep(_step) { + updateNavigation(_step); + updateContent('index.php?v=d&plugin=mobile&modal=' + _step); +} + +function updateContent(_url) { + if (!_contentContainer) return; + _contentContainer.style.visibility = 'hidden'; + fetch(_url) + .then(response => response.text()) + .then(data => { + if (!_contentContainer) return; + _contentContainer.innerHTML = data; + + _contentContainer.querySelectorAll('script').forEach(_script => { + let newScript = document.createElement('script'); + if (_script.src) { + newScript.src = _script.src; + } else { + newScript.textContent = _script.textContent; + } + _contentContainer.appendChild(newScript); + _contentContainer.removeChild(newScript); + }); + + _contentContainer.style.visibility = 'visible'; + jeedomUtils.initTooltips(_contentContainer); + const stepOrder = Array.from(document.querySelectorAll('.navDot')).map(dot => dot.dataset.step); + }) + .catch(error => { + console.error('{{Erreur au chargement de la page}}:', error); + domUtils.hideLoading(); + if (_contentContainer) { + _contentContainer.style.visibility = 'visible'; + } + }); +} + + + +function updateNavigation(_step) { + let current = document.querySelector('.navDot[data-step="' + _step + '"]'); + if (!current) { + return; + } + document.querySelector('.navBtn.bt_next').dataset.step = _step + if (!current.previousElementSibling) { + document.querySelector('.navBtn.bt_prev')?.classList.add('hidden') + } else { + document.querySelector('.navBtn.bt_prev').title = current.previousElementSibling.dataset.title + document.querySelector('.navBtn.bt_prev.hidden')?.classList.remove('hidden') + } + if (!current.nextElementSibling) { + document.querySelector('.navBtn.bt_next')?.classList.add('hidden') + if (_step == 'ready') { + document.getElementById('bt_jeedom_ready')?.classList.remove('hidden') + } + } else { + document.getElementById('bt_jeedom_ready')?.classList.add('hidden') + document.querySelector('.navBtn.bt_next').title = current.nextElementSibling.dataset.title + document.querySelector('.navBtn.bt_next.hidden')?.classList.remove('hidden') + } + jeedomUtils.addOrUpdateUrl('step', _step); + localStorage.setItem('wizardStep', _step); + if (window.updateQuitButtonVisibility) window.updateQuitButtonVisibility(); +} + +function allowNavigation(_direction = 'both', _allowed = true) { + let current = document.querySelector('.navDot.active'); + if (_direction != 'next') { + let prevDot = current.previousElementSibling; + while (prevDot) { + if (!_allowed) { + prevDot.classList.add('blocked'); + } else { + prevDot.classList.remove('blocked'); + } + prevDot = prevDot.previousElementSibling; + } + } + if (_direction != 'prev') { + let nextDot = current.nextElementSibling; + while (nextDot) { + if (!_allowed) { + nextDot.classList.add('blocked'); + } else { + nextDot.classList.remove('blocked'); + } + nextDot = nextDot.nextElementSibling; + } + } +} + +function exitWizard() { + window.location.href = 'index.php?v=d&m=mobile&p=mobile'; } \ No newline at end of file diff --git a/desktop/modal/AppV1Info.php b/desktop/modal/AppV1Info.php new file mode 100644 index 00000000..d58f00b6 --- /dev/null +++ b/desktop/modal/AppV1Info.php @@ -0,0 +1,68 @@ +. + */ +if (!isConnect('admin')) { + throw new Exception('{{401 - Accès non autorisé}}'); +} +mobile::makeTemplateJson(); +$data = mobile::getTemplateJson(); +$data['messages'] = mobile::discovery_message(); +$data['config'] = array('datetime' => getmicrotime()); +$replace = array(' '\<\i'); +?> +{{JSON valide}} () + + + + +
+
+

+		
+
+
+

+		
+
+
+

+		
+
+
+

+		
+
+
+

+		
+
+
+

+		
+
+
+

+	
+
+
\ No newline at end of file diff --git a/desktop/php/mobile.php b/desktop/php/mobile.php index ce3ee1d3..ead82a54 100755 --- a/desktop/php/mobile.php +++ b/desktop/php/mobile.php @@ -42,6 +42,10 @@
{{QR Code}}
+
+
+ {{Documentation}} +
{{Mes Téléphones Mobiles}}
@@ -164,6 +168,7 @@
{{Configuration avancée}} + {{Infos envoyées à l'app}} {{Sauvegarder}} {{Supprimer}} @@ -275,7 +280,7 @@
- +
@@ -310,7 +315,7 @@
- +
From 530a8acaac06959494b8242741aa01ab2b56ea8e Mon Sep 17 00:00:00 2001 From: "Julien C." Date: Tue, 15 Jul 2025 15:21:40 +0200 Subject: [PATCH 07/58] improve wizars --- core/class/mobile.class.php | 2 +- desktop/css/wizard.css | 13 +++++++++++-- desktop/modal/doc1.php | 13 +++++++++++++ desktop/modal/doc2.php | 16 +++++++--------- desktop/modal/doc3.php | 16 +++++++--------- desktop/modal/welcome.php | 15 --------------- 6 files changed, 39 insertions(+), 36 deletions(-) create mode 100644 desktop/modal/doc1.php delete mode 100644 desktop/modal/welcome.php diff --git a/core/class/mobile.class.php b/core/class/mobile.class.php index b4685a9d..807292c7 100755 --- a/core/class/mobile.class.php +++ b/core/class/mobile.class.php @@ -49,7 +49,7 @@ public static function cronDaily() public static function getWizardSteps(): array { - $wizard['welcome'] = __('Accueil', __FILE__); + $wizard['doc1'] = __('Accueil', __FILE__); $wizard['doc2'] = __('Page2', __FILE__); $wizard['doc3'] = __('Page3', __FILE__); return $wizard; diff --git a/desktop/css/wizard.css b/desktop/css/wizard.css index 5052e716..13612994 100644 --- a/desktop/css/wizard.css +++ b/desktop/css/wizard.css @@ -39,22 +39,31 @@ body { right: 5%; } -#wizard_container { +/* #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: 225px; + max-height: 500px; grid-row-start: 2 } diff --git a/desktop/modal/doc1.php b/desktop/modal/doc1.php new file mode 100644 index 00000000..5e070e52 --- /dev/null +++ b/desktop/modal/doc1.php @@ -0,0 +1,13 @@ + + + + +Pour connecter votre téléphone, deux méthodes sont disponibles : +Sur le premier écran de l'application, vous pouvez soit connecter votre compte Market pour retrouver toutes les Box associées à ce compte, soit ajouter une Box manuellement. + diff --git a/desktop/modal/doc2.php b/desktop/modal/doc2.php index 4a312a7c..5e070e52 100644 --- a/desktop/modal/doc2.php +++ b/desktop/modal/doc2.php @@ -1,15 +1,13 @@ -

{{Documentation}}

- Product Image - - \ No newline at end of file diff --git a/desktop/modal/doc3.php b/desktop/modal/doc3.php index 4a312a7c..5e070e52 100644 --- a/desktop/modal/doc3.php +++ b/desktop/modal/doc3.php @@ -1,15 +1,13 @@ -

{{Documentation}}

- Product Image - - \ No newline at end of file diff --git a/desktop/modal/welcome.php b/desktop/modal/welcome.php deleted file mode 100644 index 4a312a7c..00000000 --- a/desktop/modal/welcome.php +++ /dev/null @@ -1,15 +0,0 @@ - -

{{Documentation}}

- Product Image - - \ No newline at end of file From bdb15d590506b43a8da5f058f11b2854d326b938 Mon Sep 17 00:00:00 2001 From: David <79108364+Phpvarious@users.noreply.github.com> Date: Tue, 15 Jul 2025 16:32:10 +0200 Subject: [PATCH 08/58] add log --- core/api/mobile.api.php | 13 +++++++------ desktop/js/mobile.js | 18 +++++++++++++----- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/core/api/mobile.api.php b/core/api/mobile.api.php index f01696db..e83c7e56 100755 --- a/core/api/mobile.api.php +++ b/core/api/mobile.api.php @@ -766,9 +766,9 @@ function saveMenuFromAppV2($menu, $mobile) // APP V1 // if ($jsonrpc->getMethod() == 'sync') { + log::add('mobile', 'debug', '┌─────▶︎ Sync App V1 ───────────────'); if (jeedom::version() >= '3.2.0') { - log::add('mobile', 'debug', 'SYNC'); - log::add('mobile', 'debug', 'Demande du RDK'); + log::add('mobile', 'debug', '| Demande du RDK'); $registerDevice = $_USER_GLOBAL->getOptions('registerDevice', array()); if (!is_array($registerDevice)) { $registerDevice = array(); @@ -780,7 +780,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); } $mobile = null; if (isset($params['Iq'])) { @@ -809,7 +809,7 @@ function saveMenuFromAppV2($menu, $mobile) } if (isset($params['notificationProvider']) && $params['notificationProvider'] != '') { - log::add('mobile', 'debug', 'notificationProvider disponible'); + log::add('mobile', 'debug', '| notificationProvider disponible'); $arn = $mobile->getConfiguration('notificationArn', ''); $arnMobile = substr($params['notificationProvider'], 1, -1); if ($arn != $arnMobile) { @@ -819,7 +819,7 @@ function saveMenuFromAppV2($menu, $mobile) } if (isset($params['notificationRegistrationToken']) && $params['notificationRegistrationToken'] != 'nok' && $params['notificationRegistrationToken'] != '') { - log::add('mobile', 'debug', 'notificationRegistrationToken disponible'); + log::add('mobile', 'debug', '| notificationRegistrationToken disponible'); $token = $mobile->getConfiguration('notificationRegistrationToken', ''); $tokenMobile = $params['notificationRegistrationToken']; if ($arn != $arnMobile && $arnMobile != null) { @@ -840,7 +840,8 @@ function saveMenuFromAppV2($menu, $mobile) if (isset($rdk)) { $return['config']['rdk'] = $rdk; } - log::add('mobile', 'debug', 'Return $discovery_summaryValue > ' . json_encode($return['summaryValue'])); + log::add('mobile', 'debug', '| Return $discovery_summaryValue > ' . json_encode($return['summaryValue'])); + log::add('mobile', 'debug', '└───────────────────────────────────────────'); $jsonrpc->makeSuccess($return); } diff --git a/desktop/js/mobile.js b/desktop/js/mobile.js index c0fb4e0d..21e385eb 100755 --- a/desktop/js/mobile.js +++ b/desktop/js/mobile.js @@ -219,9 +219,13 @@ function printEqLogic(_eqLogic) { let select_type = document.querySelector('.eqLogicAttr[data-l1key="configuration"][data-l2key="type_mobile"]') let value_type = '' if (is_object(select_type)) { - value_type = select_type.options[select_type.selectedIndex].text + value_type = select_type.options[select_type.selectedIndex]?.text || 'INCONNU' + } + if (is_object(el_type)) { + el_type.innerHTML = value_type + if (value_type == 'INCONNU') el_type.removeClass('label-primary').addClass('label-danger') + else el_type.removeClass('label-danger').addClass('label-primary') } - if (is_object(el_type)) el_type.innerHTML = value_type /// if delete code AppV1 in mobile.php into Paramètres spécifiques -> /// change by @@ -229,9 +233,13 @@ function printEqLogic(_eqLogic) { let select_affect_user = document.querySelector('.eqLogicAttr[data-l1key="configuration"][data-l2key="affect_user"]') let value_affect_user = '' if (is_object(select_affect_user)) { - value_affect_user = select_affect_user.options[select_affect_user.selectedIndex].text + value_affect_user = select_affect_user.options[select_affect_user.selectedIndex]?.text || 'INCONNU' + } + if (is_object(el_affect_user)) { + el_affect_user.innerHTML = value_affect_user + if (value_affect_user == 'INCONNU' || value_affect_user == 'Aucun') el_affect_user.removeClass('label-primary').addClass('label-danger') + else el_affect_user.removeClass('label-danger').addClass('label-primary') } - if (is_object(el_affect_user)) el_affect_user.innerHTML = value_affect_user } function addCmdToTable(_cmd) { @@ -492,4 +500,4 @@ function allowNavigation(_direction = 'both', _allowed = true) { function exitWizard() { window.location.href = 'index.php?v=d&m=mobile&p=mobile'; -} +} \ No newline at end of file From 962b1989e629411b72da0bc7acf77dfd7ec5d9d0 Mon Sep 17 00:00:00 2001 From: David <79108364+Phpvarious@users.noreply.github.com> Date: Tue, 15 Jul 2025 16:38:38 +0200 Subject: [PATCH 09/58] add log suite --- core/class/mobile.class.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/core/class/mobile.class.php b/core/class/mobile.class.php index 807292c7..a7dae070 100755 --- a/core/class/mobile.class.php +++ b/core/class/mobile.class.php @@ -46,13 +46,11 @@ public static function cronDaily() mobile::makeTemplateJsonV1(); } - - public static function getWizardSteps(): array { - - $wizard['doc1'] = __('Accueil', __FILE__); - $wizard['doc2'] = __('Page2', __FILE__); - $wizard['doc3'] = __('Page3', __FILE__); - return $wizard; + public static function getWizardSteps(): array { + $wizard['doc1'] = __('Accueil', __FILE__); + $wizard['doc2'] = __('Page2', __FILE__); + $wizard['doc3'] = __('Page3', __FILE__); + return $wizard; } /** @@ -137,6 +135,7 @@ public static function pluginToSend() 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); @@ -162,11 +161,14 @@ public static function makeTemplateJson() 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() From 418fab4cf7cda03e2f51ed5f88015948f32492f6 Mon Sep 17 00:00:00 2001 From: David <79108364+Phpvarious@users.noreply.github.com> Date: Tue, 15 Jul 2025 17:29:49 +0200 Subject: [PATCH 10/58] add log --- core/class/mobile.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/class/mobile.class.php b/core/class/mobile.class.php index a7dae070..80c10867 100755 --- a/core/class/mobile.class.php +++ b/core/class/mobile.class.php @@ -1954,7 +1954,8 @@ public function execute($_options = array()) 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); } } else { - log::add('mobile', 'debug', '| [ERROR] ARN non configuré '); + if ($eqLogic->getConfiguration('type_mobile', null) == null) log::add('mobile', 'debug', '| [ERROR] Type de Mobile non configuré '); + else log::add('mobile', 'debug', '| [ERROR] ARN non configuré '); } log::add('mobile', 'debug', '└────────────────────'); } From 837e93dc3b0d4b4360db46a5313b42dced95f672 Mon Sep 17 00:00:00 2001 From: David <79108364+Phpvarious@users.noreply.github.com> Date: Thu, 17 Jul 2025 11:16:44 +0200 Subject: [PATCH 11/58] makeTemplateJson --- core/class/mobile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/class/mobile.class.php b/core/class/mobile.class.php index 80c10867..c0abffc6 100755 --- a/core/class/mobile.class.php +++ b/core/class/mobile.class.php @@ -43,7 +43,7 @@ public static function cronDaily() } // App V1 - mobile::makeTemplateJsonV1(); + mobile::makeTemplateJson(); } public static function getWizardSteps(): array { From 9fe78f831dc019b43901cd109e25796bf3aacc61 Mon Sep 17 00:00:00 2001 From: David <79108364+Phpvarious@users.noreply.github.com> Date: Fri, 18 Jul 2025 10:54:40 +0200 Subject: [PATCH 12/58] notificationRegistrationToken --- core/api/mobile.api.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/core/api/mobile.api.php b/core/api/mobile.api.php index e83c7e56..bd381df8 100755 --- a/core/api/mobile.api.php +++ b/core/api/mobile.api.php @@ -818,13 +818,21 @@ function saveMenuFromAppV2($menu, $mobile) } } - if (isset($params['notificationRegistrationToken']) && $params['notificationRegistrationToken'] != 'nok' && $params['notificationRegistrationToken'] != '') { + if (isset($params['notificationRegistrationToken']) && $params['notificationRegistrationToken'] != '') { log::add('mobile', 'debug', '| notificationRegistrationToken disponible'); - $token = $mobile->getConfiguration('notificationRegistrationToken', ''); + $token = $mobile->getConfiguration('notificationRegistrationToken', 'nok'); $tokenMobile = $params['notificationRegistrationToken']; - if ($arn != $arnMobile && $arnMobile != null) { + if ($token == 'nok') { + log::add('mobile', 'debug', '| notificationRegistrationToken null dans la configuration > ' . $token); $mobile->setConfiguration('notificationRegistrationToken', $tokenMobile); $mobile->save(); + } else { + log::add('mobile', 'debug', '| Token dans la configuration > ' . $token); + if ($token != $tokenMobile) { + log::add('mobile', 'debug', '| Token config != Token mobile > ' . $token . ' != ' . $tokenMobile); + $mobile->setConfiguration('notificationRegistrationToken', $tokenMobile); + $mobile->save(); + } } } From d5a3110c4983ac9c7c69034e19766c4a40b10f5d Mon Sep 17 00:00:00 2001 From: David <79108364+Phpvarious@users.noreply.github.com> Date: Fri, 18 Jul 2025 18:52:38 +0200 Subject: [PATCH 13/58] static --- core/class/mobile.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/class/mobile.class.php b/core/class/mobile.class.php index c0abffc6..ce3d1dee 100755 --- a/core/class/mobile.class.php +++ b/core/class/mobile.class.php @@ -578,7 +578,7 @@ public static function delete_object_eqlogic_null($objects, $eqLogics) } - public function SaveGeoloc($geoloc) + public static function SaveGeoloc($geoloc) { log::add('mobile', 'debug', '|-----------------------------------'); log::add('mobile', 'debug', '|--debut de la fonction SaveGeoLoc--'); @@ -609,7 +609,7 @@ public function SaveGeoloc($geoloc) } } - public function delGeoloc($geoloc) + public static function delGeoloc($geoloc) { log::add('mobile', 'debug', 'Geoloc lancement DEL du mobile > ' . $geoloc['Iq'] . ' pour ' . $geoloc['id']); $eqLogicMobile = eqLogic::byLogicalId($geoloc['Iq'], 'mobile'); @@ -620,7 +620,7 @@ public function delGeoloc($geoloc) } - public function EventGeoloc($geoloc) + public static function EventGeoloc($geoloc) { log::add('mobile', 'debug', 'Geoloc Event du mobile > ' . $geoloc['Iq'] . ' pour ' . $geoloc['id']); $eqLogicMobile = eqLogic::byLogicalId($geoloc['Iq'], 'mobile'); From 7ad88df0e1f4d75e8964eead9265c4108106eb45 Mon Sep 17 00:00:00 2001 From: JEALG Date: Sun, 20 Jul 2025 09:01:00 +0200 Subject: [PATCH 14/58] =?UTF-8?q?Am=C3=A9lioration=20Log=20pour=20APP=20V1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/api/mobile.api.php | 51 +++--- core/class/mobile.class.php | 171 +++++++++--------- .../mobile/cmd.info.numeric.arcSlider.html | 2 +- desktop/modal/AppV1Piece.php | 30 +-- desktop/modal/AppV1Plugin.php | 27 +-- desktop/modal/menuCustom.php | 12 +- desktop/modal/qrcodev2.php | 4 +- docs/fr_FR/changelog.md | 4 + 8 files changed, 157 insertions(+), 144 deletions(-) diff --git a/core/api/mobile.api.php b/core/api/mobile.api.php index bd381df8..5ecb24a3 100755 --- a/core/api/mobile.api.php +++ b/core/api/mobile.api.php @@ -36,7 +36,7 @@ //createMobile($params, 3); log::add('mobile', 'debug', '| [WARNING] mobile non detecté !'); } else { - log::add('mobile', 'debug', '| Mobile demandeur > ' . mobile::whoIsIq($params['Iq'])); + log::add('mobile', 'debug', '| Mobile demandeur ' . mobile::whoIsIq($params['Iq'])); } } else { log::add('mobile', 'debug', '| [WARNING] Paramètre Iq inexistant !'); @@ -137,7 +137,7 @@ function saveMenuFromAppV2($menu, $mobile) $mobile = eqLogic::byLogicalId($params['Iq'], 'mobile'); } if (!is_object($mobile)) { - $mobile = createMobile($params,3); + $mobile = createMobile($params, 3); } $mobile->setConfiguration('type_mobile', $notification['platform']); if (isset($notification['token'])) { @@ -798,8 +798,8 @@ function saveMenuFromAppV2($menu, $mobile) if (isset($params['notificationProvider']) && $params['notificationProvider'] != '') { $mobile->setConfiguration('notificationArn', substr($params['notificationProvider'], 1, -1)); } - if (isset($params['notificationRegistrationToken']) && $params['notificationRegistrationToken'] != '') { - if ($params['notificationRegistrationToken'] != 'nok') { + if (isset($params['notificationRegistrationToken']) && $params['notificationRegistrationToken'] != '') { + if ($params['notificationRegistrationToken'] != 'nok') { $mobile->setConfiguration('notificationRegistrationToken', $params['notificationRegistrationToken']); } } @@ -816,7 +816,7 @@ function saveMenuFromAppV2($menu, $mobile) $mobile->setConfiguration('notificationArn', $arnMobile); $mobile->save(); } - } + } if (isset($params['notificationRegistrationToken']) && $params['notificationRegistrationToken'] != '') { log::add('mobile', 'debug', '| notificationRegistrationToken disponible'); @@ -826,7 +826,7 @@ function saveMenuFromAppV2($menu, $mobile) log::add('mobile', 'debug', '| notificationRegistrationToken null dans la configuration > ' . $token); $mobile->setConfiguration('notificationRegistrationToken', $tokenMobile); $mobile->save(); - } else { + } else { log::add('mobile', 'debug', '| Token dans la configuration > ' . $token); if ($token != $tokenMobile) { log::add('mobile', 'debug', '| Token config != Token mobile > ' . $token . ' != ' . $tokenMobile); @@ -841,7 +841,7 @@ function saveMenuFromAppV2($menu, $mobile) } $return = mobile::getTemplateJson(); $return['messages'] = mobile::discovery_message(); - $return['summaryValue'] = mobile::discovery_summaryValue($return['objects']); + $return['summaryValue'] = mobile::discovery_summaryValue($return['objects']); $return['config']['datetime'] = getmicrotime(); $return['config']['Iq'] = $params['Iq']; $return['config']['NameMobile'] = $mobile->getName(); @@ -893,9 +893,9 @@ function saveMenuFromAppV2($menu, $mobile) } if ($jsonrpc->getMethod() == 'askText') { - log::add('mobile', 'debug', 'TESTAPIASK'); + log::add('mobile', 'debug', 'TESTAPIASK'); log::add('mobile', 'debug', 'Arrivée reponse ask Textuel depuis le mobile > ' . $params['Iq']); - /*$configs = $params['configs']; + /*$configs = $params['configs']; $menu = $configs['menu']; $notification = $configs['notification'];*/ $mobile = eqLogic::byLogicalId($params['Iq'], 'mobile'); @@ -912,7 +912,7 @@ function saveMenuFromAppV2($menu, $mobile) if ($cmd->askResponse($textCasse)) { log::add('mobile', 'debug', 'ask bien trouvé : Réponse validée'); $jsonrpc->makeSuccess(); - }else{ + } else { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $cmd->generateAskResponseLink($params['text'])); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); @@ -924,35 +924,36 @@ function saveMenuFromAppV2($menu, $mobile) } } -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']); +if ($jsonrpc->getMethod() == 'saveMobile') { + log::add('mobile', 'debug', ':fg-success: ─────▶︎ Demande de sauvegarde ::/fg: ' . $params['type'] . ' ─▶︎ ' . $params['Iq'] . ' > ' . mobile::whoIsIq($params['Iq'])); + //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(); } -if ($jsonrpc->getMethod() == 'getMobile'){ - log::add('mobile', 'debug', 'Demande de recuperation '. $params['type'] .' > ' . $params['Iq'] .'('.mobile::whoIsIq($params['Iq']).') recuperation save du > ' . $params['IqRestore'] . ' ('. mobile::whoIsIq($params['IqRestore']) .')'); +if ($jsonrpc->getMethod() == 'getMobile') { + log::add('mobile', 'debug', ':fg-success: ─────▶︎ Demande de recuperation ::/fg: ' . $params['type'] . ' ─▶︎ ' . $params['Iq'] . '(' . mobile::whoIsIq($params['Iq']) . ') recuperation save du > ' . $params['IqRestore'] . ' (' . mobile::whoIsIq($params['IqRestore']) . ')'); $jsonrpc->makeSuccess(mobile::getSaveJson($params['IqRestore'], $params['type'])); } -if ($jsonrpc->getMethod() == 'geoloc'){ - log::add('mobile', 'debug', 'Geoloc '. $params['id'] .' > ' . $params['name'] .' > ' .$params['value']); +if ($jsonrpc->getMethod() == 'geoloc') { + log::add('mobile', 'debug', 'Geoloc ' . $params['id'] . ' > ' . $params['name'] . ' > ' . $params['value']); mobile::EventGeoloc($params); $jsonrpc->makeSuccess(); } -if ($jsonrpc->getMethod() == 'geolocSave'){ - log::add('mobile', 'debug', 'Geoloc SAVE '. $params['id'] .' > ' . $params['name']); - if($params['id'] != '' || $params['id'] != null){ +if ($jsonrpc->getMethod() == 'geolocSave') { + log::add('mobile', 'debug', ':fg-success: ─────▶︎ Geoloc SAVE ::/fg: ' . $params['id'] . ' ─▶︎ ' . $params['name']); + if ($params['id'] != '' || $params['id'] != null) { mobile::SaveGeoloc($params); $jsonrpc->makeSuccess(); - }else{ - throw new Exception(__('pas d\'id : ', __FILE__) . $params['name']); - } + } else { + throw new Exception(__('pas d\'id : ', __FILE__) . $params['name']); + } } -if ($jsonrpc->getMethod() == 'geolocDel'){ - log::add('mobile', 'debug', 'Geoloc DEL '. $params['id'] .' > ' . $params['name']); +if ($jsonrpc->getMethod() == 'geolocDel') { + log::add('mobile', 'debug', 'Geoloc DEL ' . $params['id'] . ' > ' . $params['name']); mobile::delGeoloc($params); $jsonrpc->makeSuccess(); } diff --git a/core/class/mobile.class.php b/core/class/mobile.class.php index ce3d1dee..c6365116 100755 --- a/core/class/mobile.class.php +++ b/core/class/mobile.class.php @@ -37,16 +37,16 @@ class mobile extends eqLogic public static function cronDaily() { foreach (eqLogic::byType('mobile') as $mobile) { - if($mobile->getConfiguration('appVersion', 1) == 2) { - $mobile->cleaningNotifications(); + if ($mobile->getConfiguration('appVersion', 1) == 2) { + $mobile->cleaningNotifications(); } - } // App V1 mobile::makeTemplateJson(); } - public static function getWizardSteps(): array { + public static function getWizardSteps(): array + { $wizard['doc1'] = __('Accueil', __FILE__); $wizard['doc2'] = __('Page2', __FILE__); $wizard['doc3'] = __('Page3', __FILE__); @@ -67,11 +67,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 .= '|--- | --- | --- | --- | --- | --- | --- | ---|
'; @@ -197,7 +197,7 @@ public static function makeSaveJson($mobileID, $_data = array(), $type = 'dashbo public static function getSaveJson($mobileID, $type = 'dashboard') { if (!file_exists(dirname(__FILE__) . '/../../data/' . $mobileID . '/' . $type . '.json')) { - self::makeSaveJson($mobileID, array() , $type); + self::makeSaveJson($mobileID, array(), $type); } return json_decode(file_get_contents(dirname(__FILE__) . '/../../data/' . $mobileID . '/' . $type . '.json'), true); } @@ -580,15 +580,13 @@ public static function delete_object_eqlogic_null($objects, $eqLogics) public static function SaveGeoloc($geoloc) { - log::add('mobile', 'debug', '|-----------------------------------'); - log::add('mobile', 'debug', '|--debut de la fonction SaveGeoLoc--'); - log::add('mobile', 'debug', '|-----------------------------------'); - log::add('mobile', 'debug', '|'); $eqLogicMobile = eqLogic::byLogicalId($geoloc['Iq'], 'mobile'); - log::add('mobile', 'debug', '| Iq = ' . $geoloc['Iq']); if (is_object($eqLogicMobile)) { + log::add('mobile', 'debug', '┌──:fg-success: SaveGeoloc - V1 :/fg:──'); + log::add('mobile', 'debug', '| Iq = ' . $geoloc['Iq']); log::add('mobile', 'debug', '| Mobile bien trouvé dans cette Jeedom'); - log::add('mobile', 'debug', '| Objet > ' . $eqLogicMobile->getId()); + log::add('mobile', 'debug', '| Objet = ' . $eqLogicMobile->getId()); + log::add('mobile', 'debug', '└────────────────────'); $cmdgeoloc = cmd::byEqLogicIdAndLogicalId($eqLogicMobile->getId(), 'geoId_' . $geoloc['id']); if (!is_object($cmdgeoloc)) { $cmdgeoloc = new mobileCmd(); @@ -611,18 +609,22 @@ public static function SaveGeoloc($geoloc) public static function delGeoloc($geoloc) { - log::add('mobile', 'debug', 'Geoloc lancement DEL du mobile > ' . $geoloc['Iq'] . ' pour ' . $geoloc['id']); + log::add('mobile', 'debug', '|┌──:fg-success: Lancement DEL du mobile- V1 :/fg:──'); + log::add('mobile', 'debug', '| Mobile ' . $geoloc['Iq'] . ' pour ' . $geoloc['id']); $eqLogicMobile = eqLogic::byLogicalId($geoloc['Iq'], 'mobile'); $cmdgeoloc = cmd::byEqLogicIdAndLogicalId($eqLogicMobile->getId(), 'geoId_' . $geoloc['id']); if (isset($cmdgeoloc)) { $cmdgeoloc->remove(); } + log::add('mobile', 'debug', '||└────────────────────'); } public static function EventGeoloc($geoloc) { - log::add('mobile', 'debug', 'Geoloc Event du mobile > ' . $geoloc['Iq'] . ' pour ' . $geoloc['id']); + /******************** APP V1 *************************/ + log::add('mobile', 'debug', '|┌──:fg-success: jsonPublish :/fg:──'); + log::add('mobile', 'debug', '| Geoloc Event du mobile > ' . $geoloc['Iq'] . ' pour ' . $geoloc['id']); $eqLogicMobile = eqLogic::byLogicalId($geoloc['Iq'], 'mobile'); $cmdgeoloc = cmd::byEqLogicIdAndLogicalId($eqLogicMobile->getId(), 'geoId_' . $geoloc['id']); $cmdgeolocv2 = cmd::byEqLogicIdAndLogicalId($eqLogicMobile->getId(), 'geoloc_' . $geoloc['id']); @@ -632,7 +634,7 @@ public static function EventGeoloc($geoloc) log::add('mobile', 'debug', 'Valeur non pareille.'); $cmdgeoloc->event($geoloc['value']); } else { - log::add('mobile', 'debug', 'Valeur pareille. >' . $geoloc['value'] . ' / ' . $cmdgeoloc->execCmd()); + log::add('mobile', 'debug', '| Valeur pareille. ─▶︎ ' . $geoloc['value'] . ' / ' . $cmdgeoloc->execCmd()); } } if (is_object($cmdgeolocv2)) { @@ -641,9 +643,10 @@ public static function EventGeoloc($geoloc) log::add('mobile', 'debug', 'Valeur non pareille.'); $cmdgeolocv2->event($geoloc['value']); } else { - log::add('mobile', 'debug', 'Valeur pareille. >' . $geoloc['value'] . ' / ' . $cmdgeolocv2->execCmd()); + log::add('mobile', 'debug', '| Valeur pareille. ─▶︎ ' . $geoloc['value'] . ' / ' . $cmdgeolocv2->execCmd()); } } + log::add('mobile', 'debug', '|└────────────────────'); } @@ -681,7 +684,7 @@ public static function deleteFileImg() 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); + log::add('mobile', 'debug', '||┌──:fg-success: PARAMS :/fg:──' . $silent); if (isset($Iq)) log::add('mobile', 'debug', '||| IQ for jsonPublish > ' . $Iq); $dateNotif = date("Y-m-d H:i:s"); @@ -765,7 +768,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 = [ @@ -813,7 +816,7 @@ public static function jsonPublish($os, $titre, $message, $type, $idNotif, $answ ] ] ]; - + if ($photo != null) { @@ -880,7 +883,7 @@ public static function jsonPublish($os, $titre, $message, $type, $idNotif, $answ file_put_contents($filePath, json_encode($notifications)); } } else { - // APP V1 + // APP V1 if ($os == 'android' && $version == 1) { $android = [ 'notification' => [ @@ -935,66 +938,66 @@ public static function notification($arn, $os, $titre, $message, $type, $idNotif { 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'); + $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; - } 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'; } - - $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', '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 ($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; } - 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)); - } + $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'); + 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'; + } + + $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', '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)); } + } //} else { - //log::add('mobile', 'error', __("Échec de l'envoi de notification : la version 1 de l'app n'est plus prise en charge !", __FILE__)); + //log::add('mobile', 'error', __("Échec de l'envoi de notification : la version 1 de l'app n'est plus prise en charge !", __FILE__)); //} log::add('mobile', 'debug', '|└────────────────────'); } @@ -1469,7 +1472,7 @@ public function cmdForSpecificChannel($params = array(), $_trigger = 'location') $cmd->setIsVisible(0); $cmd->setOrder($order); $order++; - log::add('mobile', 'debug', 'Create cmd for phoneBattery'); + log::add('mobile', 'debug', 'Creation commande Batterie du téléphone'); } $cmd->setEqLogic_id($this->getId()); $cmd->setType('info'); @@ -1494,7 +1497,7 @@ public function cmdForSpecificChannel($params = array(), $_trigger = 'location') $cmd->setIsVisible(0); $cmd->setOrder($order); $order++; - log::add('mobile', 'debug', 'Create cmd for phoneCharging'); + log::add('mobile', 'debug', 'Creation commande En charge'); } $cmd->setEqLogic_id($this->getId()); $cmd->setType('info'); @@ -1604,7 +1607,7 @@ public function postInsert() } if ($this->getConfiguration('appVersion', 1) == 2) { $this->setConfiguration('defaultIdMobile', $this->getId()); - } + } $this->save(); } @@ -1656,7 +1659,7 @@ public function postSave() $cmd->setSubType('message'); if ($cmd->getChanged() === true) $cmd->save(); - $cmd = $this->getCmd(null, 'notifSilent'); + $cmd = $this->getCmd(null, 'notifSilent'); if (!is_object($cmd)) { $cmd = new mobileCmd(); $cmd->setIsVisible(1); @@ -1728,7 +1731,6 @@ public function postSave() $cmdaskYN->remove(); } } - } /** @@ -1810,7 +1812,6 @@ public static function fileInMessage($data) return $result; } else { log::add('mobile', 'debug', '|└────────────────────'); - //log::add('mobile', 'debug', '| null'); return null; } } @@ -1962,4 +1963,4 @@ public function execute($_options = array()) } /* * **********************Getteur Setteur*************************** */ -} \ No newline at end of file +} 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/modal/AppV1Piece.php b/desktop/modal/AppV1Piece.php index 6645fe32..b739228e 100644 --- a/desktop/modal/AppV1Piece.php +++ b/desktop/modal/AppV1Piece.php @@ -47,18 +47,20 @@ //include_file('desktop', 'mobile', 'js', 'mobile'); //include_file('core', 'plugin.template', 'js'); ?> - + \ No newline at end of file + function clickobject(id_object) { + if (typeof jeeDialog !== "undefined") { + jeeDialog.dialog({ + id: "configMobilePiece", + title: "{{Configuration Mobile de la Pièce - Application V1}}", + contentUrl: "index.php?v=d&plugin=mobile&modal=AppV1Object.mobile&object_id=" + id_object + }); + } else { + $("#md_modal").dialog({ + title: "{{Configuration Mobile de la Pièce - Application V1}}" + }); + $("#md_modal").load("index.php?v=d&plugin=mobile&modal=AppV1Object.mobile&object_id=" + id_object).dialog("open"); + } + } + \ No newline at end of file diff --git a/desktop/modal/AppV1Plugin.php b/desktop/modal/AppV1Plugin.php index fc80709c..11e11f40 100644 --- a/desktop/modal/AppV1Plugin.php +++ b/desktop/modal/AppV1Plugin.php @@ -189,18 +189,19 @@ $(window).resize(function() { $('.pluginListContainer').packery() }) - -function clickplugin(id_plugin, name_plugin) { - if (typeof jeeDialog !== "undefined") { - jeeDialog.dialog({ - id: "configMobile", - title: "{{Configuration Mobile du Plugin " + name_plugin + " - Application V1}}", - contentUrl: "index.php?v=d&plugin=mobile&modal=AppV1Plugin.mobile&plugin_id=" + id_plugin, - }); - } else { - $("#md_modal").dialog({ title: "{{Configuration Mobile du Plugin " + name_plugin + " - Application V1}}"}); - $("#md_modal").load("index.php?v=d&plugin=mobile&modal=AppV1Plugin.mobile&plugin_id=" + id_plugin).dialog("open"); - } -} + function clickplugin(id_plugin, name_plugin) { + if (typeof jeeDialog !== "undefined") { + jeeDialog.dialog({ + id: "configMobile", + title: "{{Configuration Mobile du Plugin " + name_plugin + " - Application V1}}", + contentUrl: "index.php?v=d&plugin=mobile&modal=AppV1Plugin.mobile&plugin_id=" + id_plugin, + }); + } else { + $("#md_modal").dialog({ + title: "{{Configuration Mobile du Plugin " + name_plugin + " - Application V1}}" + }); + $("#md_modal").load("index.php?v=d&plugin=mobile&modal=AppV1Plugin.mobile&plugin_id=" + id_plugin).dialog("open"); + } + } \ No newline at end of file diff --git a/desktop/modal/menuCustom.php b/desktop/modal/menuCustom.php index ceac7a1f..db635fdb 100755 --- a/desktop/modal/menuCustom.php +++ b/desktop/modal/menuCustom.php @@ -106,12 +106,18 @@ }, success: function(data) { if (data.state != 'ok') { - jeedomUtils.showAlert({ message: data.result, level: "danger"}) + jeedomUtils.showAlert({ + message: data.result, + level: "danger" + }) return } - jeedomUtils.showAlert({ message: '{{Configuration Menu Enregistrée}}', level: "success"}) + jeedomUtils.showAlert({ + message: '{{Configuration Menu Enregistrée}}', + level: "success" + }) } }) }) }) - + \ No newline at end of file diff --git a/desktop/modal/qrcodev2.php b/desktop/modal/qrcodev2.php index d3b32841..b89a2822 100755 --- a/desktop/modal/qrcodev2.php +++ b/desktop/modal/qrcodev2.php @@ -54,8 +54,6 @@
+ \ No newline at end of file diff --git a/docs/fr_FR/changelog.md b/docs/fr_FR/changelog.md index 1f2e31df..307e5c4e 100755 --- a/docs/fr_FR/changelog.md +++ b/docs/fr_FR/changelog.md @@ -4,6 +4,10 @@ > > Pour rappel s'il n'y a pas d'information sur la mise à jour, c'est que celle-ci concerne uniquement de la mise à jour de documentation, de traduction ou de texte +# xx/07/2025 + +- Intégration Application V1 + # 08/07/2025 From 4016748e62138d837a5a02a5221b4116c4715911 Mon Sep 17 00:00:00 2001 From: JEALG Date: Sun, 20 Jul 2025 09:01:19 +0200 Subject: [PATCH 15/58] =?UTF-8?q?suite=20log=20am=C3=A9lioration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/ajax/mobile.ajax.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/ajax/mobile.ajax.php b/core/ajax/mobile.ajax.php index 5401b1e2..893cfd2c 100755 --- a/core/ajax/mobile.ajax.php +++ b/core/ajax/mobile.ajax.php @@ -62,14 +62,14 @@ // APP V1 - if (init('action') == 'AppV1Savescenario'){ + if (init('action') == 'AppV1Savescenario') { $id = init('id'); $sendApp = init('valueSend'); $scenario = scenario::byId($id); - if(!is_object($scenario)){ + if (!is_object($scenario)) { throw new Exception(__('scenario non trouvé', __FILE__)); } - $scenario->setDisplay("sendToApp",$sendApp); + $scenario->setDisplay("sendToApp", $sendApp); $scenario->save(); ajax::success(); } @@ -77,7 +77,7 @@ mobile::makeTemplateJson(); ajax::success(); } - if (init('action') == 'AppV2GetSaveFavDash'){ + if (init('action') == 'AppV2GetSaveFavDash') { $iq = init('iq'); $jsonFavDash = mobile::getSaveJson($iq, 'favdash'); if ($jsonFavDash == "") { @@ -87,7 +87,7 @@ } ajax::success($reponse); } - if (init('action') == 'AppV2GetSaveDashboard'){ + if (init('action') == 'AppV2GetSaveDashboard') { $iq = init('iq'); $jsonDashboard = mobile::getSaveJson($iq, 'dashboard'); if ($jsonDashboard == "") { @@ -100,4 +100,4 @@ throw new Exception(__('Aucune methode correspondante à : ', __FILE__) . init('action')); } catch (Exception $e) { ajax::error(displayException($e), $e->getCode()); -} \ No newline at end of file +} From 471a172940f0cb71a90e2fca21f7938a2b2c8d95 Mon Sep 17 00:00:00 2001 From: JEALG Date: Sun, 20 Jul 2025 09:14:20 +0200 Subject: [PATCH 16/58] Log fonction ask V1 --- core/api/mobile.api.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/core/api/mobile.api.php b/core/api/mobile.api.php index 5ecb24a3..24bc836e 100755 --- a/core/api/mobile.api.php +++ b/core/api/mobile.api.php @@ -893,8 +893,8 @@ function saveMenuFromAppV2($menu, $mobile) } if ($jsonrpc->getMethod() == 'askText') { - log::add('mobile', 'debug', 'TESTAPIASK'); - log::add('mobile', 'debug', 'Arrivée reponse ask Textuel depuis le mobile > ' . $params['Iq']); + log::add('mobile', 'debug', '┌──:fg-success: TESTAPIASK :/fg:──'); + log::add('mobile', 'debug', '| Arrivée reponse ask Textuel depuis le mobile ─▶︎ ' . $params['Iq']); /*$configs = $params['configs']; $menu = $configs['menu']; $notification = $configs['notification'];*/ @@ -906,11 +906,11 @@ function saveMenuFromAppV2($menu, $mobile) if ($askCasse == false) { $textCasse = strtolower($params['text']); } - log::add('mobile', 'debug', 'Mobile bien trouvé casse -> ' . $askCasse . ' text : ' . $textCasse); + log::add('mobile', 'debug', '| Mobile bien trouvé casse ─▶︎ ' . $askCasse . ' text : ' . $textCasse); $cmd = $mobile->getCmd(null, 'notif'); - log::add('mobile', 'debug', 'IQ > ' . $params['Iq'] . ' demande cmd > ' . $cmd->getId()); + log::add('mobile', 'debug', '| IQ > ' . $params['Iq'] . ' demande cmd ─▶︎ ' . $cmd->getId()); if ($cmd->askResponse($textCasse)) { - log::add('mobile', 'debug', 'ask bien trouvé : Réponse validée'); + log::add('mobile', 'debug', '| ask bien trouvé ─▶︎ Réponse validée'); $jsonrpc->makeSuccess(); } else { $ch = curl_init(); @@ -918,10 +918,11 @@ function saveMenuFromAppV2($menu, $mobile) curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch); - log::add('mobile', 'debug', $output); + log::add('mobile', 'debug', '| ' . $output); $jsonrpc->makeSuccess(); } } + log::add('mobile', 'debug', '└────────────────────'); } if ($jsonrpc->getMethod() == 'saveMobile') { From 30dface58ea2af3928b49877bb2677b6936c6fce Mon Sep 17 00:00:00 2001 From: JEALG Date: Sun, 11 Jan 2026 19:52:11 +0100 Subject: [PATCH 17/58] typo log --- core/api/mobile.api.php | 28 ++++++++++++++-------------- core/class/mobile.class.php | 14 +++++++------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/core/api/mobile.api.php b/core/api/mobile.api.php index 24bc836e..1a2f6076 100755 --- a/core/api/mobile.api.php +++ b/core/api/mobile.api.php @@ -131,7 +131,7 @@ function saveMenuFromAppV2($menu, $mobile) 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] Notification ─▶︎ ' . json_encode($notification)); $mobile = null; if (isset($params['Iq'])) { $mobile = eqLogic::byLogicalId($params['Iq'], 'mobile'); @@ -142,7 +142,7 @@ function saveMenuFromAppV2($menu, $mobile) $mobile->setConfiguration('type_mobile', $notification['platform']); if (isset($notification['token'])) { if ($notification['token'] != '') { - log::add('mobile', 'debug', '| Token à ajouter > ' . $notification['token']); + log::add('mobile', 'debug', '| Token à ajouter ─▶︎ ' . $notification['token']); $mobile->setConfiguration('notificationRegistrationToken', $notification['token']); if ($notification['token'] == 'notifsBGDisabled') { message::removeAll("mobile", 'alertNotifs'); @@ -156,12 +156,12 @@ function saveMenuFromAppV2($menu, $mobile) $notifsTime = intval($notification['notifsTime']); if ($mobile->getConfiguration('notifsTime', 30) != $notifsTime) { $mobile->setConfiguration('notifsTime', $notifsTime); - log::add('mobile', 'debug', '| [INFO] New notifsTime > ' . intval($notification['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() . ')'); + log::add('mobile', 'debug', '| [INFO] affect_user ─▶︎ ' . $user->getLogin() . ' (' . $user->getId() . ')'); $mobile->setConfiguration('affect_user', $user->getId()); } $mobile->save(); @@ -195,8 +195,8 @@ function saveMenuFromAppV2($menu, $mobile) 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); @@ -255,7 +255,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] Retour vers App ─▶︎ ' . json_encode($return)); log::add('mobile', 'debug', '└───────────────────────────────────────────'); $jsonrpc->makeSuccess($return); } @@ -336,8 +336,8 @@ 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']); + 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(); @@ -367,15 +367,15 @@ function saveMenuFromAppV2($menu, $mobile) */ if ($jsonrpc->getMethod() == 'getCustomMenu') { log::add('mobile', 'debug', '┌─────◀︎ AppV2 getCustomMenu ────────────────────'); - log::add('mobile', 'debug', '| Recherche du mobile via sont Iq > ' . $params['Iq']); + 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', '| OK Mobile trouvé ─▶︎ ' . $mobile->getName()); $menu = $mobile->configMenuCustom(); } else { $menu = mobile::getMenuDefaultTab(); } - log::add('mobile', 'debug', '| [INFO] Retour vers App > ' . json_encode($menu)); + log::add('mobile', 'debug', '| [INFO] Retour vers App ─▶︎ ' . json_encode($menu)); log::add('mobile', 'debug', '└───────────────────────────────────────────'); $jsonrpc->makeSuccess($menu); } @@ -462,7 +462,7 @@ function saveMenuFromAppV2($menu, $mobile) $textCasse = strtolower($params['text']); } $cmd = $mobile->getCmd(null, 'notif'); - log::add('mobile', 'debug', '| Réponse : ' . $textCasse . ' - IQ > ' . $params['Iq'] . ' -- Demande cmd > ' . $cmd->getId()); + 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 { @@ -491,7 +491,7 @@ function saveMenuFromAppV2($menu, $mobile) $filePath = dirname(__FILE__) . '/../data/notifications/' . $Iq . '.json'; $idNotif = $params['idNotif']; $choiceAsk = $params['choiceAsk']; - log::add('mobile', 'debug', '| Réponse ASK > ' . $Iq . ' > ' . $idNotif . ' > ' . $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); diff --git a/core/class/mobile.class.php b/core/class/mobile.class.php index c6365116..3c1d0e08 100755 --- a/core/class/mobile.class.php +++ b/core/class/mobile.class.php @@ -624,26 +624,26 @@ public static function EventGeoloc($geoloc) { /******************** APP V1 *************************/ log::add('mobile', 'debug', '|┌──:fg-success: jsonPublish :/fg:──'); - log::add('mobile', 'debug', '| Geoloc Event du mobile > ' . $geoloc['Iq'] . ' pour ' . $geoloc['id']); + log::add('mobile', 'debug', '| Geoloc Event du mobile ─▶︎ ' . $geoloc['Iq'] . ' pour ' . $geoloc['id']); $eqLogicMobile = eqLogic::byLogicalId($geoloc['Iq'], 'mobile'); $cmdgeoloc = cmd::byEqLogicIdAndLogicalId($eqLogicMobile->getId(), 'geoId_' . $geoloc['id']); $cmdgeolocv2 = cmd::byEqLogicIdAndLogicalId($eqLogicMobile->getId(), 'geoloc_' . $geoloc['id']); if (is_object($cmdgeoloc)) { - log::add('mobile', 'debug', 'commande trouvé'); + log::add('mobile', 'debug', '| commande trouvé'); if ($geoloc['value'] !== $cmdgeoloc->execCmd()) { - log::add('mobile', 'debug', 'Valeur non pareille.'); + log::add('mobile', 'debug', '| Valeur non identique'); $cmdgeoloc->event($geoloc['value']); } else { - log::add('mobile', 'debug', '| Valeur pareille. ─▶︎ ' . $geoloc['value'] . ' / ' . $cmdgeoloc->execCmd()); + log::add('mobile', 'debug', '| Valeur identique ─▶︎ ' . $geoloc['value'] . ' / ' . $cmdgeoloc->execCmd()); } } if (is_object($cmdgeolocv2)) { - log::add('mobile', 'debug', 'commande trouvé'); + log::add('mobile', 'debug', '| commande trouvé'); if ($geoloc['value'] !== $cmdgeolocv2->execCmd()) { - log::add('mobile', 'debug', 'Valeur non pareille.'); + log::add('mobile', 'debug', '| Valeur non identique'); $cmdgeolocv2->event($geoloc['value']); } else { - log::add('mobile', 'debug', '| Valeur pareille. ─▶︎ ' . $geoloc['value'] . ' / ' . $cmdgeolocv2->execCmd()); + log::add('mobile', 'debug', '| Valeur identique ─▶︎ ' . $geoloc['value'] . ' / ' . $cmdgeolocv2->execCmd()); } } log::add('mobile', 'debug', '|└────────────────────'); From e9d68b9444bf7941be1d6938a891197bcab4e583 Mon Sep 17 00:00:00 2001 From: David <79108364+Phpvarious@users.noreply.github.com> Date: Wed, 15 Apr 2026 07:08:05 +0200 Subject: [PATCH 18/58] Update mobile.class.php backupExclude --- core/class/mobile.class.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/class/mobile.class.php b/core/class/mobile.class.php index 3c1d0e08..19a4fa3b 100755 --- a/core/class/mobile.class.php +++ b/core/class/mobile.class.php @@ -34,6 +34,16 @@ class mobile extends eqLogic /* * ***********************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']; + } + public static function cronDaily() { foreach (eqLogic::byType('mobile') as $mobile) { From d06cba9da911d19d7552355a2b694fa6344fb610 Mon Sep 17 00:00:00 2001 From: David <79108364+Phpvarious@users.noreply.github.com> Date: Fri, 17 Apr 2026 16:06:51 +0200 Subject: [PATCH 19/58] Add css file --- desktop/css/notification.css | 129 +++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 desktop/css/notification.css 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 From 72c40c943379c63348561cea3ef516d5b4c4e974 Mon Sep 17 00:00:00 2001 From: David <79108364+Phpvarious@users.noreply.github.com> Date: Fri, 17 Apr 2026 16:12:59 +0200 Subject: [PATCH 20/58] Update mobile.ajax.php --- core/ajax/mobile.ajax.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/core/ajax/mobile.ajax.php b/core/ajax/mobile.ajax.php index 893cfd2c..d67b0f5a 100755 --- a/core/ajax/mobile.ajax.php +++ b/core/ajax/mobile.ajax.php @@ -59,6 +59,20 @@ } 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::removeNotification(init('iq', ''), init('id', ''))); + } // APP V1 From 0e4509fb419a7d218d3a5b77386898743e674ad9 Mon Sep 17 00:00:00 2001 From: David <79108364+Phpvarious@users.noreply.github.com> Date: Fri, 17 Apr 2026 16:17:37 +0200 Subject: [PATCH 21/58] Update mobile.ajax.php change function name --- core/ajax/mobile.ajax.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/ajax/mobile.ajax.php b/core/ajax/mobile.ajax.php index d67b0f5a..378aca98 100755 --- a/core/ajax/mobile.ajax.php +++ b/core/ajax/mobile.ajax.php @@ -71,7 +71,7 @@ } if (init('action') == 'removeNotificationV2') { - ajax::success(mobile::removeNotification(init('iq', ''), init('id', ''))); + ajax::success(mobile::removeNotificationV2(init('iq', ''), init('id', ''))); } // APP V1 From 06f471e978fb2ef7ea314fcc5d6e60e745657c91 Mon Sep 17 00:00:00 2001 From: David <79108364+Phpvarious@users.noreply.github.com> Date: Fri, 17 Apr 2026 16:27:28 +0200 Subject: [PATCH 22/58] Update mobile.class.php --- core/class/mobile.class.php | 49 +++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/core/class/mobile.class.php b/core/class/mobile.class.php index 19a4fa3b..d063c501 100755 --- a/core/class/mobile.class.php +++ b/core/class/mobile.class.php @@ -1012,6 +1012,51 @@ public static function notification($arn, $os, $titre, $message, $type, $idNotif log::add('mobile', 'debug', '|└────────────────────'); } + /** + * Get all notifications from Iq + * Call by ajax getNotificationsV2 + * @return array + */ + public static function getNotificationsV2($Iq) + { + $return = ''; + $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)); + else $return = __('Aucune notifications.', __FILE__); + } else { + $return = __('Fichier de notifications non trouvé.', __FILE__); + } + 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 introuvable :', __FILE__) . ' ' . $_id); + } + } else { + throw new Exception(__('Fichier de notifications non trouvé : ', __FILE__) . $filePath); + } + } + /** * Create and update cmd geoloc * Call By api : setConfigs @@ -1851,7 +1896,7 @@ 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)); @@ -1860,7 +1905,7 @@ public function execute($_options = array()) 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'); From 6c3bd83b2d70202b76da6cfa6b33cf97be7d50f4 Mon Sep 17 00:00:00 2001 From: David <79108364+Phpvarious@users.noreply.github.com> Date: Fri, 17 Apr 2026 16:38:51 +0200 Subject: [PATCH 23/58] Update mobile.js --- desktop/js/mobile.js | 141 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 137 insertions(+), 4 deletions(-) diff --git a/desktop/js/mobile.js b/desktop/js/mobile.js index 21e385eb..1074c907 100755 --- a/desktop/js/mobile.js +++ b/desktop/js/mobile.js @@ -54,6 +54,7 @@ document.querySelector("#bt_pluginmobile")?.addEventListener("click", function ( contentUrl: "index.php?v=d&plugin=mobile&modal=AppV1Plugin", }); }); + document.querySelector("#bt_piecemobile")?.addEventListener("click", function (event) { jeeDialog.dialog({ id: "objectsModal", @@ -61,6 +62,7 @@ document.querySelector("#bt_piecemobile")?.addEventListener("click", function (e contentUrl: "index.php?v=d&plugin=mobile&modal=AppV1Piece", }); }); + document.querySelector("#bt_scenariomobile")?.addEventListener("click", function (event) { jeeDialog.dialog({ id: "scenariosModal", @@ -68,6 +70,7 @@ document.querySelector("#bt_scenariomobile")?.addEventListener("click", function contentUrl: "index.php?v=d&plugin=mobile&modal=AppV1Scenario", }); }); + document.querySelector("#bt_regenConfig")?.addEventListener("click", function (event) { domUtils.ajax({ type: "POST", @@ -89,6 +92,48 @@ document.querySelector("#bt_regenConfig")?.addEventListener("click", function (e }); }); +// NotificationsV2 +document.querySelector(".notification-box")?.addEventListener("click", function (event) { + var _target = null + if (_target = event.target.closest('.bt_removeNotification')) { + let notification = _target.closest('.notification-step') + let id = notification.getAttribute('data-id'); + let iq = notification.getAttribute('data-iq'); + domUtils.ajax({ + type: "POST", + url: "plugins/mobile/core/ajax/mobile.ajax.php", + data: { + action: "removeNotificationV2", + id: id, + iq: iq + }, + dataType: "json", + error: function (request, status, error) { + domUtils.handleAjaxError(request, status, error) + }, + success: function (data) { + if (data.state != "ok") { + jeedomUtils.showAlert({ message: data.result, level: "danger" }) + return + } + notification.remove() + if (data.result == '0' && is_object(el = document.querySelector(".notification-box"))) { + el.innerHTML = '
{{Aucune notifications}}
' + } + jeedomUtils.showAlert({ message: "{{Notification supprimées.}}", level: "success"}); + }, + }); + return + } + + if (_target = event.target.closest('.bt_refreshNotifications')) { + let iq = _target.getAttribute('data-iq') + printNotification(iq) + jeedomUtils.showAlert({ message: "{{Terminé.}}", level: "success"}); + return + } +}); + // Copie pour monitoring var toCopy = document.getElementById("to-copy-monitoring"); var arnComplet = document.getElementById("arnComplet"); @@ -107,14 +152,13 @@ document.getElementById("copy-monitoring")?.addEventListener("click", function ( function printEqLogic(_eqLogic) { let appVersion = _eqLogic.configuration.appVersion; - console.log(appVersion) if (appVersion == 2) { document.querySelectorAll(".paramV1").unseen() document.querySelectorAll(".paramV2").seen() + printNotification(_eqLogic.logicalId) } else { document.querySelectorAll(".paramV2").unseen() document.querySelectorAll(".paramV1").seen() - } // AppV1 @@ -243,7 +287,6 @@ function printEqLogic(_eqLogic) { } function addCmdToTable(_cmd) { - console.log('addCmdToTable') if (document.getElementById('table_cmd') == null) return if (!isset(_cmd)) { var _cmd = { configuration: {} } @@ -307,6 +350,96 @@ function addCmdToTable(_cmd) { }) } +function printNotification(_iq) { + domUtils.ajax({ + type: "POST", + url: "plugins/mobile/core/ajax/mobile.ajax.php", + data: { + action: "getNotificationsV2", + iq: _iq, + }, + dataType: "json", + global: false, + error: function (request, status, error) { + domUtils.handleAjaxError(request, status, error) + }, + success: function (data) { + if (data.state != "ok") { + jeedomUtils.showAlert({ message: data.result, level: "danger" }) + return + } + + let el = document.querySelector(".notification-box"); + + try { + var objectData = JSON.parse(data.result); + } catch { + el.innerHTML = '
' + data.result + '
' + return + } + + if (typeof objectData == "object") { + let notification = '' + notification += '' + moment.locale(jeeFrontEnd.language.substring(0, 2)) + for (var i in objectData) { + // ASK + let askStatus = '' + let askChoice = '' + if (isset(objectData[i].data.choiceAsk)) { + askStatus = 'ask-success' + askChoice = objectData[i].data.choiceAsk + } else if (objectData[i].data.askVariable != 'rien') { + let notifTime = moment(objectData[i].data.date, "YYYY-MM-DD hh:mm:ss").unix() + let currentTime = moment().unix() + try { + let askParams = (isset(objectData[i].data.askParams)) ? JSON.parse(objectData[i].data.askParams) : '' + if (isset(askParams.timeout)) { + let timeout = askParams.timeout / 1000 + if ((currentTime - notifTime) > timeout) { + askStatus = 'ask-timeout' + askChoice = '{{Timeout}}' + } else { + askStatus += 'ask-in-progress' + askChoice = '{{En cours...}}' + } + } + } catch { } + } + + notification += '
' + notification += '
' + objectData[i].data.date + '
' + if (objectData[i].data.askVariable != 'rien') { + notification += '
ASK
' + } else if (objectData[i].data.critical == 'true') { + notification += '
N
' + } else if (objectData[i].data.silent == 'true') { + notification += '
NS
' + } else { + notification += '
N
' + } + notification += '
' + notification += '
' + //notification += ' {{Supprimer}}' + notification += '' + notification += '
' + objectData[i].data.title + '
' + notification += '
' + objectData[i].data.body + '
' + if (isset(objectData[i].data.image)) { + notification += '
' + } + if (askChoice != '') notification += '
' + askChoice + '
' + notification += '
' + notification += '
' + //console.log(objectData[i]) + } + el.innerHTML = notification + jeedomUtils.initTooltips(el) + } + }, + }); + +} + // WIZARD var _contentContainer = document.getElementById('wizard_container'); @@ -500,4 +633,4 @@ function allowNavigation(_direction = 'both', _allowed = true) { function exitWizard() { window.location.href = 'index.php?v=d&m=mobile&p=mobile'; -} \ No newline at end of file +} From 4acb27f8794a5008f81436420e13ec205a11533f Mon Sep 17 00:00:00 2001 From: David <79108364+Phpvarious@users.noreply.github.com> Date: Fri, 17 Apr 2026 16:41:21 +0200 Subject: [PATCH 24/58] Update mobile.php --- desktop/php/mobile.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/desktop/php/mobile.php b/desktop/php/mobile.php index ead82a54..cf288f8f 100755 --- a/desktop/php/mobile.php +++ b/desktop/php/mobile.php @@ -178,6 +178,7 @@
  • {{Commandes}}
  • +
  • {{Notifications}}
  • @@ -362,8 +363,14 @@
    +
    +
    +
    Compatible AppV2 uniquement.
    +
    +
    + - \ No newline at end of file + From 047fa9995a451a032f6cee0048de5c28b04a9699 Mon Sep 17 00:00:00 2001 From: David <79108364+Phpvarious@users.noreply.github.com> Date: Sat, 18 Apr 2026 18:18:59 +0200 Subject: [PATCH 25/58] Update mobile.js --- desktop/js/mobile.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/desktop/js/mobile.js b/desktop/js/mobile.js index 1074c907..5861fb3f 100755 --- a/desktop/js/mobile.js +++ b/desktop/js/mobile.js @@ -159,6 +159,8 @@ function printEqLogic(_eqLogic) { } else { document.querySelectorAll(".paramV2").unseen() document.querySelectorAll(".paramV1").seen() + let el = document.querySelector(".notification-box"); + el.innerHTML = '
    Compatible AppV2 uniquement.
    ' } // AppV1 From 6a934df23c34f0dc70cd05b986c6fb65b7eaca9a Mon Sep 17 00:00:00 2001 From: David <79108364+Phpvarious@users.noreply.github.com> Date: Sat, 18 Apr 2026 18:25:01 +0200 Subject: [PATCH 26/58] Update mobile.class.php --- core/class/mobile.class.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/core/class/mobile.class.php b/core/class/mobile.class.php index d063c501..89dd8a4b 100755 --- a/core/class/mobile.class.php +++ b/core/class/mobile.class.php @@ -1019,14 +1019,11 @@ public static function notification($arn, $os, $titre, $message, $type, $idNotif */ public static function getNotificationsV2($Iq) { - $return = ''; + $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)); - else $return = __('Aucune notifications.', __FILE__); - } else { - $return = __('Fichier de notifications non trouvé.', __FILE__); } return $return; } From 96c113808974c78dabd98e014c6ce5cee50ffe02 Mon Sep 17 00:00:00 2001 From: David <79108364+Phpvarious@users.noreply.github.com> Date: Thu, 14 May 2026 14:29:48 +0200 Subject: [PATCH 27/58] Update mobile.class.php --- core/class/mobile.class.php | 189 ++++++++++++++++++++++-------------- 1 file changed, 117 insertions(+), 72 deletions(-) diff --git a/core/class/mobile.class.php b/core/class/mobile.class.php index 89dd8a4b..ec5b8293 100755 --- a/core/class/mobile.class.php +++ b/core/class/mobile.class.php @@ -694,7 +694,7 @@ public static function deleteFileImg() 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 ($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"); @@ -1027,7 +1027,7 @@ public static function getNotificationsV2($Iq) } return $return; } - + /** * remove notification from Id into filepath id * Call by ajax removeNotificationV2 @@ -1504,86 +1504,131 @@ public function cmdForSpecificChannel($params = array(), $_trigger = 'location') if (isset($params['Iq'])) { if (isset($params[$_trigger])) { $order = count($this->getCmd()); + $getDeviceInformations = (isset($params[$_trigger]['extras']) && isset($params[$_trigger]['extras']['method']) && $params[$_trigger]['extras']['method'] == 'getDeviceInformations'); // 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', 'Creation commande Batterie du téléphone'); + if ($getDeviceInformations) { + $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', '| Création de la commande Batterie du téléphone'); //PR + } + $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('phoneBattery', $params[$_trigger]['battery']['level'])) { + log::add('mobile', 'debug', '| ' . (__('Batterie du téléphone', __FILE__)) . ' = ' . $params[$_trigger]['battery']['level'] * 100 . '%'); + } + } else { + log::add('mobile', 'debug', '| ' . (__('Batterie du téléphone', __FILE__)) . ' : ' . 'Absence de donnée ─▶︎ ' . $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', 'Creation commande En charge'); + if ($getDeviceInformations) { + $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', '| ' . __('Création de la commande', __FILE__) . ' > ' . __('En charge', __FILE__)); //PR + } + $cmd->setEqLogic_id($this->getId()); + $cmd->setType('info'); + $cmd->setSubType('binary'); + if ($cmd->getChanged() === true) $cmd->save(); + } + if ($this->checkAndUpdateCmd('phoneCharging', intval($params[$_trigger]['battery']['is_charging']))) { + log::add('mobile', 'debug', '| ' . (__('En charge', __FILE__)) . ' = ' . 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', '| ' . __('Création de la commande', __FILE__) . ' > ' . __('Coordonnées', __FILE__)); //PR + } + $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', '| ' . (__('Coordonnées', __FILE__)) . ' = ' . $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', '| ' . __('Création de la commande', __FILE__) . ' > ' . __('Altitude', __FILE__)); //PR + } + $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', '| ' . (__('Altitude', __FILE__)) . ' = ' . $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']); } } } @@ -1598,7 +1643,7 @@ 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', '| Durée de rétention actuelle : ' . $notifsTime . ' jours'); // Images $retentionSeconds = intVal($notifsTime) * 24 * 60 * 60; $currentTime = time(); @@ -1610,7 +1655,7 @@ 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 de : ' . $image); } else { log::add('mobile', 'debug', '| ─▶︎ :fg-danger:suppression image:/fg: > ' . $image); } @@ -1885,7 +1930,7 @@ public function execute($_options = array()) switch ($valueUser) { case 1: file_put_contents($filePath, ''); - log::add('mobile', 'info', '| Suppression des notifications effectuée'); + log::add('mobile', 'info', '| Suppression des notifications réalisée'); break; case 2: $notifs = json_decode(file_get_contents($filePath), true); @@ -1897,7 +1942,7 @@ public function execute($_options = array()) 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', 'info', '| Suppression des asks expirés réalisée'); break; case 3: $notifs = json_decode(file_get_contents($filePath), true); @@ -1905,7 +1950,7 @@ public function execute($_options = array()) 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', 'info', '| Suppression des asks répondus réalisée'); break; } From 86e90f8921048d73d80fd5a95413fc126b01f043 Mon Sep 17 00:00:00 2001 From: David <79108364+Phpvarious@users.noreply.github.com> Date: Thu, 14 May 2026 14:30:08 +0200 Subject: [PATCH 28/58] Update mobile.api.php --- core/api/mobile.api.php | 93 +++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 45 deletions(-) diff --git a/core/api/mobile.api.php b/core/api/mobile.api.php index 1a2f6076..e1834be3 100755 --- a/core/api/mobile.api.php +++ b/core/api/mobile.api.php @@ -517,57 +517,60 @@ function saveMenuFromAppV2($menu, $mobile) 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') { - log::add('mobile', 'debug', '| OK Commande "' . $cmdgeoloc->getName() . '" passée à 1'); - $cmdgeoloc->event(1); - } else if ($geofence['action'] == 'EXIT') { - log::add('mobile', 'debug', '| OK Commande "' . $cmdgeoloc->getName() . '" passée à 0'); - $cmdgeoloc->event(0); - } else { - log::add('mobile', 'debug', '| Event -> ' . $geofence['action']); + log::add('mobile', 'debug', '| OK Mobile trouvé -> ' . $mobile->getName() . ' (' . $params['Iq'] . ')'); + if (isset($params['transmition'])) { + $mobile->cmdForSpecificChannel($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', '| Event > ' . 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', '| 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') { - log::add('mobile', 'debug', '| OK Commande "' . $cmdgeoloc->getName() . '" passée à 1'); - $cmdgeoloc->event(1); - } else if ($geofence['action'] == 'EXIT') { - log::add('mobile', 'debug', '| OK Commande "' . $cmdgeoloc->getName() . '" passée à 0'); - $cmdgeoloc->event(0); + } 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)); + $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'])); + log::add('mobile', 'debug', '| $eventAge > ' . $eventAge); + 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', '| [INFO] Event -> ' . $geofence['action']); + } } else { - log::add('mobile', 'debug', '| [INFO] Event -> ' . $geofence['action']); + log::add('mobile', 'debug', '| [ERROR] Commande geoloc_' . $geofence['identifier'] . ' inexistante.'); } } else { - log::add('mobile', 'debug', '| [ERROR] Commande geoloc_' . $geofence['identifier'] . ' inexistante.'); + $errorCount++; } - } else { - $errorCount++; } - } - if ($errorCount > 0) { - log::add('mobile', 'debug', __('| Pas de paramètre de geofencing', __FILE__)); + if ($errorCount > 0) { + log::add('mobile', 'debug', __('| Pas de paramètre de geofencing', __FILE__)); + } } } } else { From e33f7bc177bd45ab9cab34ca76cfdda23fa464bf Mon Sep 17 00:00:00 2001 From: David <79108364+Phpvarious@users.noreply.github.com> Date: Fri, 15 May 2026 00:29:57 +0200 Subject: [PATCH 29/58] Update mobile.ajax.php PR Jag --- core/ajax/mobile.ajax.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/ajax/mobile.ajax.php b/core/ajax/mobile.ajax.php index 378aca98..535bbbfb 100755 --- a/core/ajax/mobile.ajax.php +++ b/core/ajax/mobile.ajax.php @@ -59,7 +59,7 @@ } ajax::success($return); } - + if (init('action') == 'getNotificationsV2') { $return = ''; $iq = init('iq'); @@ -71,8 +71,8 @@ } if (init('action') == 'removeNotificationV2') { - ajax::success(mobile::removeNotificationV2(init('iq', ''), init('id', ''))); - } + ajax::success(mobile::removeNotificationV2(init('iq', ''), init('id', ''))); + } // APP V1 From 8cfd444a19cb7b18d7e4d613b3aaea938b165f3a Mon Sep 17 00:00:00 2001 From: David <79108364+Phpvarious@users.noreply.github.com> Date: Fri, 15 May 2026 00:32:43 +0200 Subject: [PATCH 30/58] Update mobile.api.php PR Jag --- core/api/mobile.api.php | 128 ++++++++++++++++++++-------------------- 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/core/api/mobile.api.php b/core/api/mobile.api.php index e1834be3..169f93d0 100755 --- a/core/api/mobile.api.php +++ b/core/api/mobile.api.php @@ -26,17 +26,17 @@ } $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:Appel API Mobile:/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', '| Paramètres passés ─▶︎ ' . 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é !'); } else { - log::add('mobile', 'debug', '| Mobile demandeur ' . mobile::whoIsIq($params['Iq'])); + log::add('mobile', 'debug', '| Mobile demandeur : ' . mobile::whoIsIq($params['Iq'])); } } else { log::add('mobile', 'debug', '| [WARNING] Paramètre Iq inexistant !'); @@ -123,14 +123,14 @@ function saveMenuFromAppV2($menu, $mobile) * @return string ok makeSuccess */ if ($jsonrpc->getMethod() == 'setConfigs') { - log::add('mobile', 'debug', '┌─────▶︎ AppV2 setConfigs ─────────────────'); + log::add('mobile', 'debug', '┌──────────▶︎ AppV2 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] 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'])) { @@ -192,7 +192,7 @@ 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)); @@ -214,7 +214,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 Infos ────────'); $idBox = jeedom::getHardwareKey(); $return = []; $arrayPlugins = []; @@ -267,7 +267,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(); @@ -342,7 +342,7 @@ function saveMenuFromAppV2($menu, $mobile) $return[$idBox]['configs'] = array(); $return[$idBox]['miscellanousParams'] = array(); if (is_object($mobile)) { - log::add('mobile', 'debug', '| OK Mobile trouvé > ' . $mobile->getName()); + log::add('mobile', 'debug', '| OK Mobile trouvé ─▶︎ ' . $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)); @@ -353,8 +353,8 @@ function saveMenuFromAppV2($menu, $mobile) $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] CustomENVOICONFIGSAPI GETJSON ─▶︎ ' . json_encode($return[$idBox]['configs'])); + log::add('mobile', 'debug', '| [INFO] Retour vers APP ─▶︎ ' . json_encode($return)); log::add('mobile', 'debug', '└───────────────────────────────────────────'); $jsonrpc->makeSuccess($return); @@ -366,8 +366,8 @@ 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']); + 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()); @@ -450,7 +450,7 @@ function saveMenuFromAppV2($menu, $mobile) * @return makeSuccess */ if ($jsonrpc->getMethod() == 'askText') { - log::add('mobile', 'debug', '┌─────▶︎ ASK ───────────────────────────────'); + log::add('mobile', 'debug', '┌──────────▶︎ ASK ───────────────────────────'); /*$configs = $params['configs']; $menu = $configs['menu']; $notification = $configs['notification'];*/ @@ -486,12 +486,12 @@ function saveMenuFromAppV2($menu, $mobile) * @return string ok */ if ($jsonrpc->getMethod() == 'getAskResponse') { - log::add('mobile', 'debug', '┌────▶︎ 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); + log::add('mobile', 'debug', '| Réponse ASK ─▶︎ ' . $Iq . ' > ' . $idNotif . ' ─▶︎ ' . $choiceAsk); if (file_exists($filePath)) { $notifications = file_get_contents($filePath); $notificationsArray = json_decode($notifications, true); @@ -514,16 +514,16 @@ function saveMenuFromAppV2($menu, $mobile) * @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)) { - log::add('mobile', 'debug', '| OK Mobile trouvé -> ' . $mobile->getName() . ' (' . $params['Iq'] . ')'); + log::add('mobile', 'debug', '| OK Mobile trouvé ─▶︎ ' . $mobile->getName() . ' (' . $params['Iq'] . ')'); if (isset($params['transmition'])) { $mobile->cmdForSpecificChannel($params, 'transmition'); if (isset($params['transmition']['event']) && $params['transmition']['event'] == 'geofence') { - log::add('mobile', 'debug', '| Event > ' . $params['transmition']['event']); + log::add('mobile', 'debug', '| Event ─▶︎ ' . $params['transmition']['event']); $geofence = $params['transmition']['geofence']; - log::add('mobile', 'debug', '| Event > ' . json_encode($geofence)); + log::add('mobile', 'debug', '| Event ─▶︎ ' . json_encode($geofence)); $cmdgeoloc = cmd::byEqLogicIdAndLogicalId($mobile->getId(), 'geoloc_' . $geofence['identifier']); if (is_object($cmdgeoloc)) { if ($geofence['action'] == 'ENTER' || $geofence['action'] == 'EXIT') { @@ -536,7 +536,7 @@ function saveMenuFromAppV2($menu, $mobile) $mobile->checkAndUpdateCmd('geoloc_' . $geofence['identifier'], $value); } } else { - log::add('mobile', 'debug', '| Event -> ' . $geofence['action']); + log::add('mobile', 'debug', '| Event ─▶︎ ' . $geofence['action']); } } } else { @@ -544,22 +544,22 @@ function saveMenuFromAppV2($menu, $mobile) $errorCount = 0; foreach ($transmitions as $transmition) { if (isset($transmition['event']) && $transmition['event'] == 'geofence') { - log::add('mobile', 'debug', '| Transmition :' . json_encode($params['transmition'])); + log::add('mobile', 'debug', '| Transmition : ' . json_encode($params['transmition'])); $geofence = $transmition['geofence']; - log::add('mobile', 'debug', '| Event > ' . json_encode($geofence)); + log::add('mobile', 'debug', '| Event ─▶︎ ' . 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'])); - log::add('mobile', 'debug', '| $eventAge > ' . $eventAge); + log::add('mobile', 'debug', '| $eventAge ─▶︎ ' . $eventAge); 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); + log::add('mobile', 'debug', '| OK Commande "' . $cmdgeoloc->getName() . '" ─▶︎ ' . $value); $mobile->checkAndUpdateCmd('geoloc_' . $geofence['identifier'], $value); } } else { - log::add('mobile', 'debug', '| [INFO] Event -> ' . $geofence['action']); + log::add('mobile', 'debug', '| [INFO] Event ─▶︎ ' . $geofence['action']); } } else { log::add('mobile', 'debug', '| [ERROR] Commande geoloc_' . $geofence['identifier'] . ' inexistante.'); @@ -587,7 +587,7 @@ 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'])); if (isset($params['appInfos']['qrCode']['displayValue'])) { @@ -595,8 +595,8 @@ function saveMenuFromAppV2($menu, $mobile) } else { mobile::cmdForApi($params['Iq'], "qrcodemethod", json_encode($params['appInfos']['qrCode']), "QrCode"); } - log::add('mobile', 'debug', '└───────────────────────────────────────────'); } + log::add('mobile', 'debug', '└───────────────────────────────────────────'); $jsonrpc->makeSuccess(); } @@ -606,8 +606,8 @@ 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'); @@ -620,7 +620,7 @@ function saveMenuFromAppV2($menu, $mobile) $jsonrpc->makeError('Paramètre Iq inexistant'); } } - log::add('mobile', 'debug', '└───────────────────────────────────────────'); + log::add('mobile', 'debug', '└─────────────────────────────────────────────────────────────'); $jsonrpc->makeSuccess(); } @@ -630,13 +630,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(); } @@ -647,8 +647,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', '└───────────────────────────────────────────'); } @@ -658,7 +658,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:Recuperation des Notifications:/fg: ──────────'); $Iq = $params['Iq']; $filePath = dirname(__FILE__) . '/../data/notifications/' . $Iq . '.json'; $notifications = 'noNotifications'; @@ -668,8 +668,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); } @@ -679,7 +679,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']; @@ -695,7 +695,7 @@ function saveMenuFromAppV2($menu, $mobile) file_put_contents($filePath, $notifications); } } - log::add('mobile', 'debug', '└───────────────────────────────────────────'); + log::add('mobile', 'debug', '└───────────────────────────────────────────────'); $jsonrpc->makeSuccess('ok'); } @@ -705,7 +705,7 @@ function saveMenuFromAppV2($menu, $mobile) * @return string ok */ if ($jsonrpc->getMethod() == 'deleteGeolocCommand') { - log::add('mobile', 'debug', '┌────▶︎ Commande suppression GeoLoc ───────'); + log::add('mobile', 'debug', '┌──────────▶︎ Commande suppression GeoLoc ───────'); $geolocId = $params['geoloc_id']; $eqLogic = eqLogic::byLogicalId($params['Iq'], 'mobile'); if (is_object($eqLogic)) { @@ -717,7 +717,7 @@ function saveMenuFromAppV2($menu, $mobile) } else { log::add('mobile', 'debug', __('| [ERROR] EqLogic inconnu : ', __FILE__) . $params['Iq']); } - log::add('mobile', 'debug', '└───────────────────────────────────────────'); + log::add('mobile', 'debug', '└───────────────────────────────────────────────'); $jsonrpc->makeSuccess('ok'); } @@ -727,14 +727,14 @@ function saveMenuFromAppV2($menu, $mobile) * @return array */ if ($jsonrpc->getMethod() == 'getScenarios') { - log::add('mobile', 'debug', '┌────◀︎ Get Scénarios ─────────────────────'); + log::add('mobile', 'debug', '┌──────────◀︎ Get Scénarios ─────────────────'); $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', '| Scénarios ─▶︎ Aucun groupe de scénario'); $emptyListGroup = true; } if (is_array($scenarioListGroup)) { @@ -748,15 +748,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', '| Scénarios ─▶︎ Aucun "sans groupe" de scénario'); $emptyNoGroup = true; } - log::add('mobile', 'debug', '| Scénarios > ' . json_encode($scenarios)); + log::add('mobile', 'debug', '| Scénarios ─▶︎ ' . 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 { @@ -769,7 +769,7 @@ function saveMenuFromAppV2($menu, $mobile) // APP V1 // if ($jsonrpc->getMethod() == 'sync') { - log::add('mobile', 'debug', '┌─────▶︎ Sync App V1 ───────────────'); + 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()); @@ -783,7 +783,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); } $mobile = null; if (isset($params['Iq'])) { @@ -826,13 +826,13 @@ function saveMenuFromAppV2($menu, $mobile) $token = $mobile->getConfiguration('notificationRegistrationToken', 'nok'); $tokenMobile = $params['notificationRegistrationToken']; if ($token == 'nok') { - log::add('mobile', 'debug', '| notificationRegistrationToken null dans la configuration > ' . $token); + log::add('mobile', 'debug', '| notificationRegistrationToken null dans la configuration ─▶︎ ' . $token); $mobile->setConfiguration('notificationRegistrationToken', $tokenMobile); $mobile->save(); } else { log::add('mobile', 'debug', '| Token dans la configuration > ' . $token); if ($token != $tokenMobile) { - log::add('mobile', 'debug', '| Token config != Token mobile > ' . $token . ' != ' . $tokenMobile); + log::add('mobile', 'debug', '| Token config != Token mobile ─▶︎ ' . $token . ' != ' . $tokenMobile); $mobile->setConfiguration('notificationRegistrationToken', $tokenMobile); $mobile->save(); } @@ -851,13 +851,13 @@ function saveMenuFromAppV2($menu, $mobile) if (isset($rdk)) { $return['config']['rdk'] = $rdk; } - log::add('mobile', 'debug', '| Return $discovery_summaryValue > ' . json_encode($return['summaryValue'])); + 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', 'Interogation du module id:' . $params['id'] . ' Pour les cmds'); + log::add('mobile', 'debug', 'Interogation du module id :' . $params['id'] . ' Pour les cmds'); $PluginToSend = mobile::PluginToSend(); $discover_eqLogic = mobile::discovery_eqLogic($PluginToSend); $sync_new = mobile::change_cmdAndeqLogic(mobile::discovery_cmd($PluginToSend, $discover_eqLogic, true), $discover_eqLogic); @@ -873,7 +873,7 @@ function saveMenuFromAppV2($menu, $mobile) } $i++; } - log::add('mobile', 'debug', 'Commande > ' . json_encode($cmdAPI)); + log::add('mobile', 'debug', 'Commande ─▶︎ ' . json_encode($cmdAPI)); $jsonrpc->makeSuccess($cmdAPI); } @@ -896,13 +896,13 @@ function saveMenuFromAppV2($menu, $mobile) } if ($jsonrpc->getMethod() == 'askText') { - log::add('mobile', 'debug', '┌──:fg-success: TESTAPIASK :/fg:──'); + log::add('mobile', 'debug', '┌──────────▶︎ :fg-success:TESTAPIASK:/fg: ────────────────────'); log::add('mobile', 'debug', '| Arrivée reponse ask Textuel depuis le mobile ─▶︎ ' . $params['Iq']); /*$configs = $params['configs']; $menu = $configs['menu']; $notification = $configs['notification'];*/ $mobile = eqLogic::byLogicalId($params['Iq'], 'mobile'); - log::add('mobile', 'debug', 'mobile >' . json_encode($mobile)); + log::add('mobile', 'debug', 'mobile ─▶︎ ' . json_encode($mobile)); if (is_object($mobile)) { $askCasse = config::byKey('askCasse', 'mobile', false); $textCasse = $params['text']; @@ -925,7 +925,7 @@ function saveMenuFromAppV2($menu, $mobile) $jsonrpc->makeSuccess(); } } - log::add('mobile', 'debug', '└────────────────────'); + log::add('mobile', 'debug', '└───────────────────────────────────────────'); } if ($jsonrpc->getMethod() == 'saveMobile') { @@ -936,12 +936,12 @@ function saveMenuFromAppV2($menu, $mobile) } if ($jsonrpc->getMethod() == 'getMobile') { - log::add('mobile', 'debug', ':fg-success: ─────▶︎ Demande de recuperation ::/fg: ' . $params['type'] . ' ─▶︎ ' . $params['Iq'] . '(' . mobile::whoIsIq($params['Iq']) . ') recuperation save du > ' . $params['IqRestore'] . ' (' . mobile::whoIsIq($params['IqRestore']) . ')'); + log::add('mobile', 'debug', ':fg-success: ─────▶︎ Demande de recuperation ::/fg: ' . $params['type'] . ' ─▶︎ ' . $params['Iq'] . '(' . mobile::whoIsIq($params['Iq']) . ') recuperation save du ─▶︎ ' . $params['IqRestore'] . ' (' . mobile::whoIsIq($params['IqRestore']) . ')'); $jsonrpc->makeSuccess(mobile::getSaveJson($params['IqRestore'], $params['type'])); } if ($jsonrpc->getMethod() == 'geoloc') { - log::add('mobile', 'debug', 'Geoloc ' . $params['id'] . ' > ' . $params['name'] . ' > ' . $params['value']); + log::add('mobile', 'debug', 'Geoloc ' . $params['id'] . ' > ' . $params['name'] . ' ─▶︎ ' . $params['value']); mobile::EventGeoloc($params); $jsonrpc->makeSuccess(); } @@ -957,7 +957,7 @@ function saveMenuFromAppV2($menu, $mobile) } if ($jsonrpc->getMethod() == 'geolocDel') { - log::add('mobile', 'debug', 'Geoloc DEL ' . $params['id'] . ' > ' . $params['name']); + log::add('mobile', 'debug', 'Geoloc DEL ' . $params['id'] . ' ─▶︎ ' . $params['name']); mobile::delGeoloc($params); $jsonrpc->makeSuccess(); } From 064be568c97ee24bc663c18acd31c499d3617dce Mon Sep 17 00:00:00 2001 From: David <79108364+Phpvarious@users.noreply.github.com> Date: Fri, 15 May 2026 00:34:53 +0200 Subject: [PATCH 31/58] Update mobile.php PR Jag --- desktop/php/mobile.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/desktop/php/mobile.php b/desktop/php/mobile.php index cf288f8f..36f4bfeb 100755 --- a/desktop/php/mobile.php +++ b/desktop/php/mobile.php @@ -15,17 +15,16 @@ } } $isApi = config::byKey('api::mobile::mode'); -if($isApi == 'whiteip' || $isApi == 'disable'){ +if ($isApi == 'whiteip' || $isApi == 'disable') { message::add('mobile', 'L\'API mobile est désactivée ou en mode whitelist IP'); } $isCoreApi = config::byKey('api::core::mode'); -if($isCoreApi == 'whiteip' || $isCoreApi == 'disable'){ +if ($isCoreApi == 'whiteip' || $isCoreApi == 'disable') { message::add('mobile', 'L\'API core est désactivée ou en mode whitelist IP'); } ?>
    -
    {{App V2}} @@ -94,7 +93,7 @@ echo '
    '; echo '{{Pour ajouter un téléphone, il y a 2 méthodes possible :}}
    {{Sur le premier écran de l\'application, il vous est proposé de connecter votre compte market, et ainsi de retrouver toutes les boxs associées à ce compte, ou bien simplement ajouter une box.}}'; echo '
    '; - } + } ?>
    @@ -125,6 +124,9 @@
    {{Mes Téléphones Mobiles}} +
    + {{Attention, l'APP V1 ne sera plus mise à jour}} +
    = 0) { // AppV1 @@ -237,13 +239,13 @@
    - +
    - +