diff --git a/core/ajax/luna.ajax.php b/core/ajax/luna.ajax.php index 6ed5500..e68ebfc 100644 --- a/core/ajax/luna.ajax.php +++ b/core/ajax/luna.ajax.php @@ -124,7 +124,6 @@ ajax::success(luna::configurationPortSms()); } - throw new Exception(__('Aucune méthode correspondante à : ', __FILE__) . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { diff --git a/core/class/luna.class.php b/core/class/luna.class.php index a452713..9db9bd4 100644 --- a/core/class/luna.class.php +++ b/core/class/luna.class.php @@ -238,6 +238,7 @@ public static function cron5() { $ssid2 = $luna->getConfiguration('wifi2Ssid', null); $luna->checkAndUpdateCmd('battery', luna::batteryPourcentage()); $luna->checkAndUpdateCmd('status', luna::batteryStatusLuna()); + $luna->checkAndUpdateCmd('activationBattery', luna::activationBattery()); $luna->checkAndUpdateCmd('tempBattery', luna::batteryTemp()); $luna->checkAndUpdateCmd('ssid', $luna->getConfiguration('wifi1Ssid')); if ($ssid != null) { @@ -542,6 +543,26 @@ public static function batteryPresent() { return exec('sudo cat /sys/class/power_supply/bq27546-0/present'); } + public static function activationBattery() { + $battery = exec('sudo i2cget -f -y 0 0x6a 0x09'); + if($battery == '0x44') { + // ON + return 1; + } + else if($battery == '0x20') { + // OFF + return 0; + } + } + + public static function onBattery() { + return exec('sudo i2cset -f -y 0 0x6a 0x09 0x44'); + } + + public static function offBattery() { + return exec('sudo i2cset -f -y 0 0x6a 0x09 0x20'); + } + /* ----- FIN BATTERY ----- */ /* root etc Patch */ @@ -1211,6 +1232,48 @@ public function postSave() { $tempBattery->setType('info'); $tempBattery->setSubType('string'); $tempBattery->save(); + + $activationBattery = $this->getCmd(null, 'activationBattery'); + if (!is_object($activationBattery)) { + $activationBattery = new lunaCmd(); + $activationBattery->setName(__('Etat batterie', __FILE__)); + $activationBattery->setOrder(1); + } + $activationBattery->setEqLogic_id($this->getId()); + $activationBattery->setLogicalId('activationBattery'); + $activationBattery->setType('info'); + $activationBattery->setSubType('binary'); + $activationBattery->save(); + + $onBattery = $this->getCmd(null, 'onBattery'); + if (!is_object($onBattery)) { + $onBattery = new lunaCmd(); + $onBattery->setName(__('Allumer la batterie', __FILE__)); + $onBattery->setOrder(1); + } + $onBattery->setIsVisible(1); + $onBattery->setEqLogic_id($this->getId()); + $onBattery->setLogicalId('onBattery'); + $onBattery->setType('action'); + $onBattery->setSubType('other'); + $onBattery->save(); + + + $offBattery = $this->getCmd(null, 'offBattery'); + if (!is_object($offBattery)) { + $offBattery = new lunaCmd(); + $offBattery->setName(__('Eteindre la batterie', __FILE__)); + $offBattery->setOrder(1); + } + $offBattery->setIsVisible(1); + $offBattery->setEqLogic_id($this->getId()); + $offBattery->setLogicalId('offBattery'); + $offBattery->setType('action'); + $offBattery->setSubType('other'); + $offBattery->save(); + + + } public function postAjax() { @@ -1241,6 +1304,14 @@ public function execute($_options = array()) { case 'dsled': luna::dsLed($_options['select']); break; + case 'onBattery': + luna::onBattery(); + break; + case 'offBattery': + luna::offBattery(); + break; + default: + break; } luna::cron5($eqLogic->getId()); } diff --git a/desktop/js/luna.js b/desktop/js/luna.js index 3d689d0..85a7c4e 100644 --- a/desktop/js/luna.js +++ b/desktop/js/luna.js @@ -268,7 +268,6 @@ $('#saveLuna').off('click').on('click', function() { }else{ location.reload(); } - } }) jeedom.eqLogic.save({ diff --git a/desktop/php/luna.php b/desktop/php/luna.php index 0783b4a..341feab 100644 --- a/desktop/php/luna.php +++ b/desktop/php/luna.php @@ -224,8 +224,7 @@ ?>
- {{Commandes}} - +
diff --git a/docs/fr_FR/changelog.md b/docs/fr_FR/changelog.md index a429538..1ceb8bb 100644 --- a/docs/fr_FR/changelog.md +++ b/docs/fr_FR/changelog.md @@ -6,6 +6,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. +# 02/05/2024 + +- Ajout des commandes pour allumer et éteindre la batterie + # 05/02/2024 - Correction double Ip