Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ajout des commandes pour allumer et éteindre la batterie #42

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion core/ajax/luna.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@
ajax::success(luna::configurationPortSms());
}


throw new Exception(__('Aucune méthode correspondante à : ', __FILE__) . init('action'));
/* * *********Catch exeption*************** */
} catch (Exception $e) {
Expand Down
72 changes: 72 additions & 0 deletions core/class/luna.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -1211,6 +1232,49 @@ 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();
$activationBatteryId = $activationBattery->getId();

$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() {
Expand Down Expand Up @@ -1241,6 +1305,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());
}
Expand Down
1 change: 0 additions & 1 deletion desktop/js/luna.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ $('#saveLuna').off('click').on('click', function() {
}else{
location.reload();
}

}
})
jeedom.eqLogic.save({
Expand Down
3 changes: 1 addition & 2 deletions desktop/php/luna.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,7 @@
?>

<div role="tabpanel" class="tab-pane" id="commandtab">
<legend><i class="fa fa-list"></i> {{Commandes}}</legend>


<div class="table-responsive">
<table id="table_cmd" class="table table-bordered table-condensed">
<thead>
Expand Down
4 changes: 4 additions & 0 deletions docs/fr_FR/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading