diff --git a/core/class/zwavejs.class.php b/core/class/zwavejs.class.php index 228f148..d421aef 100644 --- a/core/class/zwavejs.class.php +++ b/core/class/zwavejs.class.php @@ -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; } @@ -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'; @@ -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; @@ -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; @@ -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')) { @@ -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__)); @@ -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__)); diff --git a/core/i18n/de_DE.json b/core/i18n/de_DE.json index 236658d..be2548c 100644 --- a/core/i18n/de_DE.json +++ b/core/i18n/de_DE.json @@ -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", diff --git a/core/i18n/en_US.json b/core/i18n/en_US.json index 9ad8fbb..5fdc878 100644 --- a/core/i18n/en_US.json +++ b/core/i18n/en_US.json @@ -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", diff --git a/core/i18n/es_ES.json b/core/i18n/es_ES.json index e223162..7361b96 100644 --- a/core/i18n/es_ES.json +++ b/core/i18n/es_ES.json @@ -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", diff --git a/core/i18n/fr_FR.json b/core/i18n/fr_FR.json index d2ac376..367d619 100644 --- a/core/i18n/fr_FR.json +++ b/core/i18n/fr_FR.json @@ -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", diff --git a/core/i18n/id_ID.json b/core/i18n/id_ID.json index 53bb222..be2cfc3 100644 --- a/core/i18n/id_ID.json +++ b/core/i18n/id_ID.json @@ -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", diff --git a/core/i18n/it_IT.json b/core/i18n/it_IT.json index 53bb222..37ca8db 100644 --- a/core/i18n/it_IT.json +++ b/core/i18n/it_IT.json @@ -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", diff --git a/core/i18n/ja_JP.json b/core/i18n/ja_JP.json index 53bb222..be2cfc3 100644 --- a/core/i18n/ja_JP.json +++ b/core/i18n/ja_JP.json @@ -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", diff --git a/core/i18n/pt_PT.json b/core/i18n/pt_PT.json index 9dc4c0d..ce61a3d 100644 --- a/core/i18n/pt_PT.json +++ b/core/i18n/pt_PT.json @@ -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", diff --git a/core/i18n/ru_RU.json b/core/i18n/ru_RU.json index 53bb222..be2cfc3 100644 --- a/core/i18n/ru_RU.json +++ b/core/i18n/ru_RU.json @@ -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", diff --git a/core/i18n/tr.json b/core/i18n/tr.json index 53bb222..be2cfc3 100644 --- a/core/i18n/tr.json +++ b/core/i18n/tr.json @@ -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", diff --git a/desktop/php/zwavejs.php b/desktop/php/zwavejs.php index bc87187..74da3a7 100644 --- a/desktop/php/zwavejs.php +++ b/desktop/php/zwavejs.php @@ -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 '