Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
65 changes: 42 additions & 23 deletions core/class/zwavejs.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public static function cron() {
}

public static function cronHourly() {
if (config::byKey('zwavejs::mode', 'zwavejs') == 'distant') {
if (config::byKey('zwavejs::mode', __CLASS__) == 'distant') {
self::getNodes('health');
return;
}
Expand All @@ -150,7 +150,7 @@ public static function cronHourly() {
}

public static function configureSettings($_path) {
if (config::byKey('zwavejs::mode', 'zwavejs') == 'distant') {
if (config::byKey('zwavejs::mode', __CLASS__) == 'distant') {
return;
}
$file = $_path . '/settings.json';
Expand Down Expand Up @@ -281,7 +281,7 @@ public static function postConfig_zwavejs_mode($_value) {
}

public static function additionnalDependancyCheck() {
if (config::byKey('zwavejs::mode', 'zwavejs') == 'distant') {
if (config::byKey('zwavejs::mode', __CLASS__) == 'distant') {
$return = array();
$return['state'] = 'ok';
return $return;
Expand All @@ -297,7 +297,7 @@ public static function additionnalDependancyCheck() {
}

public static function dependancy_info() {
if (config::byKey('zwavejs::mode', 'zwavejs') == 'distant') {
if (config::byKey('zwavejs::mode', __CLASS__) == 'distant') {
$return = array();
$return['state'] = 'ok';
return $return;
Expand All @@ -314,29 +314,34 @@ 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';
$return['state'] = 'nok';
switch (config::byKey('zwavejs::mode', __CLASS__)) {
case 'local':
break;
case 'distant':
break;
default:
$return['launchable'] = 'nok';
$return['launchable_message'] = __("Veuillez sélectionner le mode d'installation", __FILE__);
return $return;
}
if (self::isRunning()) {
$return['state'] = 'ok';
}
$port = config::byKey('port', __CLASS__);
if ($port == 'none') {
$return['launchable'] = 'nok';
$return['launchable_message'] = __("Le port n'est pas configuré", __FILE__);
} else {
$port = jeedom::getUsbMapping($port);
if (is_array($port) || @!file_exists($port)) {
if (config::byKey('zwavejs::mode', __CLASS__) == 'local') {
$port = config::byKey('port', __CLASS__);
if ($port == 'none') {
$return['launchable'] = 'nok';
$return['launchable_message'] = __("Le port n'est pas configuré", __FILE__);
} else {
$port = jeedom::getUsbMapping($port);
if (is_array($port) || @!file_exists($port)) {
$return['launchable'] = 'nok';
$return['launchable_message'] = __("Le port n'est pas configuré", __FILE__);
}
}
}
if (!class_exists('mqtt2')) {
Expand All @@ -358,24 +363,38 @@ public static function deamon_info() {
}

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

public static function postConfig_mqtt_topic($_value = null) {
log::add(__CLASS__, 'debug', '[' . __FUNCTION__ . '] ' . 'Inscription au plugin mqtt2');
if (!class_exists('mqtt2')) {
return;
}
if (method_exists('mqtt2', 'removePluginTopicByPlugin')) {
mqtt2::removePluginTopicByPlugin(__CLASS__);
config::save('mqtt2Registered', 0, __CLASS__);
}
mqtt2::addPluginTopic(__CLASS__, config::byKey('prefix', __CLASS__, 'zwave'));
config::save('mqtt2Registered', 1, __CLASS__);
}

public static function deamon_start($_debug = false) {
if (config::byKey('zwavejs::mode', 'zwavejs') == 'distant') {
if (config::byKey('zwavejs::mode', __CLASS__) == 'distant') {
self::postConfig_mqtt_topic();
return;
}
// log::add(__CLASS__, 'debug', '[' . __FUNCTION__ . '] ' . 'Inscription au plugin mqtt2');
config::save('controllerStatus', 'none', __CLASS__);
config::save('driverStatus', 0, __CLASS__);
self::deamon_stop();
mqtt2::addPluginTopic(__CLASS__, config::byKey('prefix', __CLASS__, 'zwave'));
self::postConfig_mqtt_topic();
$deamon_info = self::deamon_info();
if ($deamon_info['launchable'] != 'ok') {
throw new Exception(__('Veuillez vérifier la configuration', __FILE__));
Expand Down Expand Up @@ -432,7 +451,7 @@ public static function deamon_start($_debug = false) {
}

public static function deamon_stop() {
if (config::byKey('zwavejs::mode', 'zwavejs') == 'distant') {
if (config::byKey('zwavejs::mode', __CLASS__) == 'distant') {
return;
}
log::add(__CLASS__, 'info', __('Arrêt du démon ZwaveJS', __FILE__));
Expand Down
1 change: 1 addition & 0 deletions core/i18n/de_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"ZwaveJs UI": "ZwaveJs-Benutzeroberfläche",
"Interface ZwaveJs UI": "ZwaveJs UI-Schnittstelle",
"Mode": "Mode",
"A configurer": "Zum Konfigurieren",
"Distant": "Fernbedienung",
"Local": "Lokal",
"Port du contrôleur Z-Wave": "Z-Wave-Controller-Port",
Expand Down
3 changes: 2 additions & 1 deletion core/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
"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.": "The jMQTT plugin is installed, please check the configuration of the broker in the jMQTT plugin and report it, if necessary, in the MQTT Manager plugin",
"ZwaveJs UI": "ZwaveJs UI",
"Interface ZwaveJs UI": "ZwaveJs UI Interface",
"Mode": "Fashion",
"Mode": "Mode",
"A configurer": "To configure",
"Distant": "Distant",
"Local": "Local",
"Port du contrôleur Z-Wave": "Z-Wave controller port",
Expand Down
1 change: 1 addition & 0 deletions core/i18n/es_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"ZwaveJs UI": "Interfaz de usuario de ZwaveJs",
"Interface ZwaveJs UI": "Interfaz de usuario de ZwaveJs",
"Mode": "Moda",
"A configurer": "Para configurar",
"Distant": "Remoto",
"Local": "Local",
"Port du contrôleur Z-Wave": "Puerto del controlador Z-Wave",
Expand Down
1 change: 1 addition & 0 deletions core/i18n/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"ZwaveJs UI": "ZwaveJs UI",
"Interface ZwaveJs UI": "Interface ZwaveJs UI",
"Mode": "Mode",
"A configurer": "A configurer",
"Distant": "Distant",
"Local": "Local",
"Port du contrôleur Z-Wave": "Port du contrôleur Z-Wave",
Expand Down
1 change: 1 addition & 0 deletions core/i18n/id_ID.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"ZwaveJs UI": "ZwaveJs UI",
"Interface ZwaveJs UI": "Interface ZwaveJs UI",
"Mode": "Mode",
"A configurer": "A configurer",
"Distant": "Distant",
"Local": "Local",
"Port du contrôleur Z-Wave": "Port du contrôleur Z-Wave",
Expand Down
1 change: 1 addition & 0 deletions core/i18n/it_IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"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.": "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",
"ZwaveJs UI": "ZwaveJs UI",
"Interface ZwaveJs UI": "Interface ZwaveJs UI",
"A configurer": "A configurer",
"Mode": "Mode",
"Distant": "Distant",
"Local": "Local",
Expand Down
1 change: 1 addition & 0 deletions core/i18n/ja_JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"ZwaveJs UI": "ZwaveJs UI",
"Interface ZwaveJs UI": "Interface ZwaveJs UI",
"Mode": "Mode",
"A configurer": "A configurer",
"Distant": "Distant",
"Local": "Local",
"Port du contrôleur Z-Wave": "Port du contrôleur Z-Wave",
Expand Down
1 change: 1 addition & 0 deletions core/i18n/pt_PT.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"ZwaveJs UI": "IU do ZwaveJs",
"Interface ZwaveJs UI": "Interface de IU do ZwaveJs",
"Mode": "Moda",
"A configurer": "Para configurar",
"Distant": "Remoto",
"Local": "Local",
"Port du contrôleur Z-Wave": "Porta do controlador Z-Wave",
Expand Down
1 change: 1 addition & 0 deletions core/i18n/ru_RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"ZwaveJs UI": "ZwaveJs UI",
"Interface ZwaveJs UI": "Interface ZwaveJs UI",
"Mode": "Mode",
"A configurer": "A configurer",
"Distant": "Distant",
"Local": "Local",
"Port du contrôleur Z-Wave": "Port du contrôleur Z-Wave",
Expand Down
1 change: 1 addition & 0 deletions core/i18n/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"ZwaveJs UI": "ZwaveJs UI",
"Interface ZwaveJs UI": "Interface ZwaveJs UI",
"Mode": "Mode",
"A configurer": "A configurer",
"Distant": "Distant",
"Local": "Local",
"Port du contrôleur Z-Wave": "Port du contrôleur Z-Wave",
Expand Down
3 changes: 2 additions & 1 deletion desktop/php/zwavejs.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
$eqLogics = eqLogic::byType($plugin->getId());
$controllerStatus = config::byKey('controllerStatus', 'zwavejs', 'none');
$driverStatus = config::byKey('driverStatus', 'zwavejs', 0);
$pluginMode = config::byKey('zwavejs::mode', 'zwavejs', 'local');
if (!zwavejs::isRunning()) {
echo '<div id="div_driverStatus"><div class="alert alert-danger" role="alert">';
echo "{{Le démon Z-Wave n'est pas démarré.}}</div></div>";
} else if ($driverStatus != 1) {
} else if ($pluginMode == 'local' && $driverStatus != 1) {
echo '<div id="div_driverStatus"><div class="alert alert-warning" role="alert">';
echo "{{Le driver Z-Wave n'est pas initialisé, veuillez patienter. Si le message reste trop longtemps, veuillez vérifier la configuration du démon}}</div></div>";
} else {
Expand Down
4 changes: 3 additions & 1 deletion docs/fr_FR/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ Le reste des dépendances consiste au téléchargement, à la compilation et à

## Configuration du plugin

Concernant la configuration du plugin, le point primordial est la bonne sélection du **port du contrôleur Z-Wave** correspondant à l'interface physique sur laquelle le contrôleur est connecté.
Il existe 2 modes pour le plugin : local, tout est sur votre Jeedom, c'est le mode recommandé. Pour les utilisateurs avancés, il est possible d'utiliser le mode distant; dans ce cas Jeedom ne gère pas Zigbee2MQTT, celui doit etre installé par vos soins (en général sur un docker sur jeedom ou sur une autre machine). Attention en mode distant il faut que Mqtt manager et ZwaveJS soient connectés au même broker mqtt (mosquitto)

Concernant la configuration du plugin, si vous etes en mode local, le point primordial est la bonne sélection du **port du contrôleur Z-Wave** correspondant à l'interface physique sur laquelle le contrôleur est connecté.

Les autres paramétrages possibles sont :

Expand Down
5 changes: 3 additions & 2 deletions plugin_info/configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,16 @@
<a class="btn btn-danger controller_action" target="_blank" href="http://<?php echo network::getNetworkAccess('internal', 'ip') ?>:8091" title="Aucun support ne sera fait en cas de changement d'un réglage du menu configuration de ZwaveJS UI. Vous pouvez changez le mot de passe utilisateur si vous le souhaitez. Vous pouvez utiliser les fonctionnalités. Mais ne changez aucun réglage. Les identifiants par défaut sont : admin/zwave"><i class="fas fa-external-link-square-alt "></i> {{Interface ZwaveJs UI}}</a></td>
</div>
</div>
<!-- <div class="form-group">
<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_zwavejsMode">
<option value="">{{A configurer}}</option>
<option value="distant">{{Distant}}</option>
<option value="local">{{Local}}</option>
</select>
</div>
</div> -->
</div>
<div class="form-group zwavejs_mode local">
<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
18 changes: 16 additions & 2 deletions plugin_info/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,25 @@
*/

function zwavejs_install() {

$plugin = plugin::byId('zwavejs');
if (config::byKey('zwavejs::mode', 'zwavejs', 'local') == 'local') {
$plugin->dependancy_changeAutoMode(1);
$plugin->deamon_info(1);
} else {
$plugin->dependancy_changeAutoMode(0);
$plugin->deamon_info(0);
}
}

function zwavejs_update() {

$plugin = plugin::byId('zwavejs');
if (config::byKey('zwavejs::mode', 'zwavejs', 'local') == 'local') {
$plugin->dependancy_changeAutoMode(1);
$plugin->deamon_info(1);
} else {
$plugin->dependancy_changeAutoMode(0);
$plugin->deamon_info(0);
}
}

function zwavejs_remove() {
Expand Down