Skip to content

Commit

Permalink
begin remote mode on zwavejs
Browse files Browse the repository at this point in the history
  • Loading branch information
zoic21 authored Oct 30, 2024
1 parent fca6a23 commit b698424
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
41 changes: 41 additions & 0 deletions core/class/zwavejs.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ public static function cron() {
}

public static function cronHourly() {
if(config::byKey('zwavejs::mode', 'zwavejs') == 'distant'){
self::getNodes('health');
return;
}
$deamon_info = self::deamon_info();
if ($deamon_info['state'] != 'ok') {
return;
Expand All @@ -146,6 +150,9 @@ public static function cronHourly() {
}

public static function configureSettings($_path) {
if(config::byKey('zwavejs::mode', 'zwavejs') == 'distant'){
return;
}
$file = $_path . '/settings.json';
$settings = array();
if (file_exists($file)) {
Expand Down Expand Up @@ -250,6 +257,24 @@ public static function getFile($_type, $_nodeId) {
return $data;
}

public static function postConfig_zwavejs_mode($_value) {
$plugin = plugin::byId('zwavejs');
if ($_value == 'local') {
$plugin->dependancy_changeAutoMode(1);
$plugin->deamon_info(1);
$dependancy_info = $plugin->dependancy_info(true);
if ($dependancy_info['state'] == 'nok' && config::byKey('dependancyAutoMode', $plugin->getId(), 1) == 1) {
try {
$plugin->dependancy_install();
} catch (Exception $e) {
}
}
} else {
$plugin->dependancy_changeAutoMode(0);
$plugin->deamon_info(0);
}
}

public static function additionnalDependancyCheck() {
$return = array();
$return['state'] = 'ok';
Expand All @@ -274,6 +299,13 @@ public static function dependancy_info() {
}

public static function deamon_info() {
if(config::byKey('zwavejs::mode', 'zwavejs') == 'distant'){
$return = array();
$return['log'] = __CLASS__;
$return['launchable'] = 'ok';
$return['state'] = 'ok';
return $return;
}
$return = array();
$return['log'] = __CLASS__;
$return['launchable'] = 'ok';
Expand Down Expand Up @@ -311,13 +343,19 @@ public static function deamon_info() {
}

public static function isRunning() {
if(config::byKey('zwavejs::mode', 'zwavejs') == 'distant'){
return true;
}
if (!empty(system::ps('server/bin/www.js'))) {
return true;
}
return false;
}

public static function deamon_start($_debug = false) {
if(config::byKey('zwavejs::mode', 'zwavejs') == 'distant'){
return;
}
// log::add(__CLASS__, 'debug', '[' . __FUNCTION__ . '] ' . 'Inscription au plugin mqtt2');
config::save('controllerStatus', 'none', __CLASS__);
config::save('driverStatus', 0, __CLASS__);
Expand Down Expand Up @@ -379,6 +417,9 @@ public static function deamon_start($_debug = false) {
}

public static function deamon_stop() {
if(config::byKey('zwavejs::mode', 'zwavejs') == 'distant'){
return;
}
log::add(__CLASS__, 'info', __('Arrêt du démon ZwaveJS', __FILE__));
config::save('controllerStatus', 'none', __CLASS__);
$find = 'server/bin/www.js';
Expand Down
2 changes: 2 additions & 0 deletions docs/fr_FR/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
>
>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.
- Ajout du mode distant (en beta et attention cela réduit les fonctions du plugins)

# 27/09/2024

- Changement des versions minimum, core 4.4 et OS Debian 11 minimum
Expand Down
9 changes: 9 additions & 0 deletions plugin_info/configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@
echo '<div class="alert alert-warning">{{Le plugin jMQTT est installé, veuillez vérifier la configuration du broker dans le plugin jMQTT et la reporter, si nécessaire, dans le plugin MQTT Manager.}}</div>';
}
?>
<div class="form-group">
<label class="col-md-4 control-label">{{Mode}}</label>
<div class="col-md-3">
<select class="configKey form-control" data-l1key="zwavejs::mode" id="sel_z2mMode">
<option value="distant">{{Distant}}</option>
<option value="local">{{Local}}</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">{{Port du contrôleur Z-Wave}}
<sup><i class="fas fa-question-circle tooltips" title="{{Renseigner le port utilisé par le contrôleur Z-Wave}}"></i></sup>
Expand Down

0 comments on commit b698424

Please sign in to comment.