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

Update code so that the battery information is also updated in the sp… #22

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 17 additions & 2 deletions core/class/ajaxSystem.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,11 +459,26 @@ public function refreshData() {
}
$this->checkAndUpdateCmd($cmd, $value);
}

//Refresh batterie depuis trame de synchronisation / refresh
$batteryChargeLevel = '-1';
if (isset($datas['batteryChargeLevelPercentage'])) {
$this->batteryStatus($datas['batteryChargeLevelPercentage']);
$batteryChargeLevel = $datas['batteryChargeLevelPercentage'];
}
if (isset($datas['battery']) && isset($datas['battery']['chargeLevelPercentage'])) {
$this->batteryStatus($datas['battery']['chargeLevelPercentage']);
$batteryChargeLevel = $datas['battery']['chargeLevelPercentage'];
}

//Si niveau de charge numérique disponible, mise à jour de l'information
if($batteryChargeLevel != '-1'){
//Au niveau de l'équipement
$this->batteryStatus($batteryChargeLevel);

//Au niveau de la commande spécifique si elle existe
$batteryCmd = $this->getCmd('info', 'battery::chargeLevelPercentage');
if(is_object($batteryCmd)){
$this->checkAndUpdateCmd('battery::chargeLevelPercentage', $value);
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions core/php/jeeAjaxSystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,15 @@
}
foreach ($data['updates'] as $key => &$value) {
if ($key == 'batteryCharge') {
//Actualisation de la charge de la batterie au niveau de l'équipement jeedom
$ajaxSystem->batteryStatus($value);

//Actualisation de la commande batterie si elle existe si l'équipement
//Cette commande existe actuellement sur les HUB2, HUB2_4G, et HUB2_PLUS
$batteryCmd = $ajaxSystem->getCmd('info', 'battery::chargeLevelPercentage');
if(is_object($batteryCmd)){
$ajaxSystem->checkAndUpdateCmd('battery::chargeLevelPercentage', $value);
}
}
if (in_array($data['type'], array('HUB', 'GROUP')) && $key == 'state') {
if ($value == 0) {
Expand Down