@@ -188,7 +188,13 @@ public static function configureSettings($_path) {
188188 // $port = jeedom::getUsbMapping($port);
189189 // exec(system::getCmdSudo() . 'chmod 777 ' . $port . ' > /dev/null 2>&1');
190190 //}
191- $ settings ['zwave ' ]['port ' ] = jeedom::getUsbMapping (config::byKey ('port ' , __CLASS__ ));
191+ $ port = config::byKey ('port ' , __CLASS__ );
192+ if ($ port == 'tcp ' ) {
193+ $ settings ['zwave ' ]['port ' ] = 'tcp:// ' . config::byKey ('tcp_ip_port ' , __CLASS__ );
194+ } else {
195+ $ settings ['zwave ' ]['port ' ] = jeedom::getUsbMapping ($ port );
196+ }
197+
192198 $ settings ['zwave ' ]['commandsTimeout ' ] = 60 ;
193199 $ settings ['zwave ' ]['logLevel ' ] = 'error ' ;
194200 $ settings ['zwave ' ]['logEnabled ' ] = true ;
@@ -281,34 +287,11 @@ public static function postConfig_zwavejs_mode($_value) {
281287 }
282288
283289 public static function additionnalDependancyCheck () {
284- if (config::byKey ('zwavejs::mode ' , 'zwavejs ' ) == 'distant ' ) {
285- $ return = array ();
286- $ return ['state ' ] = 'ok ' ;
287- return $ return ;
288- }
289- $ return = array ();
290- $ return ['state ' ] = 'ok ' ;
291- if (config::byKey ('lastDependancyInstallTime ' , __CLASS__ ) == '' ) {
292- $ return ['state ' ] = 'nok ' ;
293- } else if (!file_exists (__DIR__ . '/../../resources/zwave-js-ui/node_modules ' )) {
294- $ return ['state ' ] = 'nok ' ;
295- }
296- return $ return ;
297- }
298-
299- public static function dependancy_info () {
300- if (config::byKey ('zwavejs::mode ' , 'zwavejs ' ) == 'distant ' ) {
301- $ return = array ();
302- $ return ['state ' ] = 'ok ' ;
303- return $ return ;
304- }
305290 $ return = array ();
306- $ return ['progress_file ' ] = jeedom::getTmpFolder (__CLASS__ ) . '/dependance ' ;
307- $ return ['state ' ] = 'ok ' ;
308- if (config::byKey ('lastDependancyInstallTime ' , __CLASS__ ) == '' ) {
309- $ return ['state ' ] = 'nok ' ;
310- } else if (!file_exists (__DIR__ . '/../../resources/zwave-js-ui/node_modules ' )) {
311- $ return ['state ' ] = 'nok ' ;
291+ if (config::byKey ('zwavejs::mode ' , __CLASS__ ) === 'local ' ) {
292+ if (!file_exists (__DIR__ . '/../../resources/zwave-js-ui/node_modules ' )) {
293+ $ return ['state ' ] = 'nok ' ;
294+ }
312295 }
313296 return $ return ;
314297 }
@@ -332,6 +315,16 @@ public static function deamon_info() {
332315 if ($ port == 'none ' ) {
333316 $ return ['launchable ' ] = 'nok ' ;
334317 $ return ['launchable_message ' ] = __ ("Le port n'est pas configuré " , __FILE__ );
318+ } elseif ($ port == 'tcp ' ) {
319+ if (config::byKey ('tcp_ip_port ' , __CLASS__ ) == '' ) {
320+ $ return ['launchable ' ] = 'nok ' ;
321+ $ return ['launchable_message ' ] = __ ("Le port TCP n'est pas configuré " , __FILE__ );
322+ }
323+ $ parts = explode (': ' , config::byKey ('tcp_ip_port ' , __CLASS__ ));
324+ if (count ($ parts ) != 2 || !is_numeric ($ parts [1 ])) {
325+ $ return ['launchable ' ] = 'nok ' ;
326+ $ return ['launchable_message ' ] = __ ("Le port TCP n'est pas valide " , __FILE__ );
327+ }
335328 } else {
336329 $ port = jeedom::getUsbMapping ($ port );
337330 if (is_array ($ port ) || @!file_exists ($ port )) {
@@ -912,6 +905,7 @@ public static function handleNodeValueUpdate($_value_update) {
912905 public static function handleNodeValueUpdateDirect ($ _nodeId , $ _value_update ) {
913906 // log::add(__CLASS__, 'debug', '[' . __FUNCTION__ . '] ' . "Traitement d'un update de value d'un node direct");
914907 //log::add(__CLASS__, 'debug', '[' . __FUNCTION__ . '] ' . $_nodeId . ' ' . json_encode($_value_update));
908+ /** @var zwavejs */
915909 $ eqLogic = self ::byLogicalId ($ _nodeId , __CLASS__ );
916910 $ flatten = self ::flatten_array ($ _value_update );
917911 // log::add(__CLASS__, 'debug', json_encode($flatten, true));
@@ -927,11 +921,7 @@ public static function handleNodeValueUpdateDirect($_nodeId, $_value_update) {
927921 if ($ eqLogic ->getConfiguration ('missedWakeup ' , false )) {
928922 $ action = '<a href="/ ' . $ eqLogic ->getLinkToConfiguration () . '"> ' . __ ('Equipement ' , __FILE__ ) . '</a> ' ;
929923 if (config::byKey ('notifyMissWakeup ' , __CLASS__ , 1 ) == 1 && $ eqLogic ->getIsEnable () == 1 ) {
930- if (version_compare (jeedom::version (), '4.4.0 ' , '>= ' )) {
931- message::add ('zwavejs ' , "L'équipement : " . $ eqLogic ->getHumanName (true ) . ' avec le nodeId : ' . $ eqLogic ->getLogicalId () . ', vient de se réveiller après avoir raté au minimum 4 réveils. ' , $ action , 'Awake- ' . $ eqLogic ->getLogicalId (), true , 'alerting ' );
932- } else {
933- message::add ('zwavejs ' , "L'équipement : " . $ eqLogic ->getHumanName (true ) . ' avec le nodeId : ' . $ eqLogic ->getLogicalId () . ', vient de se réveiller après avoir raté au minimum 4 réveils. ' , $ action , 'Awake- ' . $ eqLogic ->getLogicalId (), true );
934- }
924+ message::add ('zwavejs ' , sprintf (__ ("L'équipement : %s avec le nodeId : %s, vient de se réveiller après avoir raté au minimum 4 réveils. " , __FILE__ ), $ eqLogic ->getHumanName (true ), $ eqLogic ->getLogicalId ()), $ action , 'Awake- ' . $ eqLogic ->getLogicalId (), true , 'alerting ' );
935925 }
936926 }
937927 $ eqLogic ->setConfiguration ('missedWakeup ' , false );
@@ -940,21 +930,13 @@ public static function handleNodeValueUpdateDirect($_nodeId, $_value_update) {
940930 if ($ data ['status ' ] == 'Dead ' && $ currentValue == 'Alive ' ) {
941931 $ action = '<a href="/ ' . $ eqLogic ->getLinkToConfiguration () . '"> ' . __ ('Equipement ' , __FILE__ ) . '</a> ' ;
942932 if (config::byKey ('notifyDead ' , __CLASS__ , 1 ) == 1 && $ eqLogic ->getIsEnable () == 1 ) {
943- if (version_compare (jeedom::version (), '4.4.0 ' , '>= ' )) {
944- message::add ('zwavejs ' , "L'équipement : " . $ eqLogic ->getHumanName (true ) . ' avec le nodeId : ' . $ eqLogic ->getLogicalId () . ', vient de passer au statut Dead. ' , $ action , 'Dead- ' . $ eqLogic ->getLogicalId (), true , 'alerting ' );
945- } else {
946- message::add ('zwavejs ' , "L'équipement : " . $ eqLogic ->getHumanName (true ) . ' avec le nodeId : ' . $ eqLogic ->getLogicalId () . ', vient de passer au statut Dead. ' , $ action , 'Dead- ' . $ eqLogic ->getLogicalId (), true );
947- }
933+ message::add ('zwavejs ' , sprintf (__ ("L'équipement : %s avec le nodeId : %s, vient de passer au statut Dead. " , __FILE__ ), $ eqLogic ->getHumanName (true ), $ eqLogic ->getLogicalId ()), $ action , 'Dead- ' . $ eqLogic ->getLogicalId (), true , 'alerting ' );
948934 }
949935 }
950936 if ($ data ['status ' ] == 'Alive ' && $ currentValue == 'Dead ' ) {
951937 $ action = '<a href="/ ' . $ eqLogic ->getLinkToConfiguration () . '"> ' . __ ('Equipement ' , __FILE__ ) . '</a> ' ;
952938 if (config::byKey ('notifyDead ' , __CLASS__ , 1 ) == 1 && $ eqLogic ->getIsEnable () == 1 ) {
953- if (version_compare (jeedom::version (), '4.4.0 ' , '>= ' )) {
954- message::add ('zwavejs ' , "L'équipement : " . $ eqLogic ->getHumanName (true ) . ' avec le nodeId : ' . $ eqLogic ->getLogicalId () . ', vient de passer au statut Alive. ' , $ action , 'Alive- ' . $ eqLogic ->getLogicalId (), true , 'alertingReturnBack ' );
955- } else {
956- message::add ('zwavejs ' , "L'équipement : " . $ eqLogic ->getHumanName (true ) . ' avec le nodeId : ' . $ eqLogic ->getLogicalId () . ', vient de passer au statut Alive. ' , $ action , 'Alive- ' . $ eqLogic ->getLogicalId (), true );
957- }
939+ message::add ('zwavejs ' , sprintf (__ ("L'équipement : %s avec le nodeId : %s, vient de passer au statut Alive. " , __FILE__ ), $ eqLogic ->getHumanName (true ), $ eqLogic ->getLogicalId ()), $ action , 'Alive- ' . $ eqLogic ->getLogicalId (), true , 'alertingReturnBack ' );
958940 }
959941 }
960942 } else if (isset ($ data ['value ' ])) {
@@ -1472,11 +1454,7 @@ public static function constructHealthPage($_values, $_mobile = False) {
14721454 $ eqLogic = self ::byLogicalId ($ values ['id ' ], __CLASS__ );
14731455 $ productDetails = '<sup><i class="fas fa-question-circle tooltips" title=" ' . $ values ['manufacturer ' ] . ' ' . $ values ['productDescription ' ] . ' Firmware : ' . $ values ['firmwareVersion ' ] . '"></i><sup> ' ;
14741456 if (is_object ($ eqLogic )) {
1475- $ image = 'plugins/zwavejs/core/config/devices/ ' . $ eqLogic ->getImgFilePath ();
1476- if (!is_file (dirname (__FILE__ ) . '/../config/devices/ ' . $ eqLogic ->getImgFilePath ())) {
1477- $ image = 'plugins/zwavejs/plugin_info/zwavejs_icon.png ' ;
1478- }
1479- $ healthPage .= '<td><img src=" ' . $ image . '" height="40"/> <a href="index.php?v=d&p=zwavejs&m=zwavejs&id= ' . $ eqLogic ->getId () . '"> ' . $ eqLogic ->getHumanName (true ) . '</a> ' . ' ' . $ productDetails . '</td> ' ;
1457+ $ healthPage .= '<td><img src=" ' . $ eqLogic ->getImage () . '" height="40"/> <a href="index.php?v=d&p=zwavejs&m=zwavejs&id= ' . $ eqLogic ->getId () . '"> ' . $ eqLogic ->getHumanName (true ) . '</a> ' . ' ' . $ productDetails . '</td> ' ;
14801458 } else {
14811459 $ healthPage .= '<td><img src="plugins/zwavejs/plugin_info/zwavejs_icon.png" height="40"/> ' . $ values ['productLabel ' ] . ' - ' . $ values ['productDescription ' ] . ' ' . $ productDetails . '</td> ' ;
14821460 }
@@ -1585,11 +1563,7 @@ public static function constructHealthPage($_values, $_mobile = False) {
15851563 if ($ wakedup > 3 * $ values ['values ' ]['132-0-wakeUpInterval ' ]['value ' ]) {
15861564 $ action = '<a href="/ ' . $ eqLogic ->getLinkToConfiguration () . '"> ' . __ ('Equipement ' , __FILE__ ) . '</a> ' ;
15871565 if (config::byKey ('notifyMissWakeup ' , __CLASS__ , 1 ) == 1 && $ eqLogic ->getIsEnable () == 1 ) {
1588- if (version_compare (jeedom::version (), '4.4.0 ' , '>= ' )) {
1589- message::add ('zwavejs ' , "L'équipement : " . $ eqLogic ->getHumanName (true ) . ' avec le nodeId : ' . $ eqLogic ->getLogicalId () . ", ne s'est pas reveillé au moins 4 fois. Il a peut être un problème (batterie ou autres). " , $ action , 'Wakeup- ' . $ eqLogic ->getLogicalId (), true , 'alertingReturnBack ' );
1590- } else {
1591- message::add ('zwavejs ' , "L'équipement : " . $ eqLogic ->getHumanName (true ) . ' avec le nodeId : ' . $ eqLogic ->getLogicalId () . ", ne s'est pas reveillé au moins 4 fois. Il a peut être un problème (batterie ou autres). " , $ action , 'Wakeup- ' . $ eqLogic ->getLogicalId (), true );
1592- }
1566+ message::add ('zwavejs ' , sprintf (__ ("L'équipement : %s avec le nodeId : %s, ne s'est pas reveillé au moins 4 fois. Il a peut être un problème (batterie ou autres). " , __FILE__ ), $ eqLogic ->getHumanName (true ), $ eqLogic ->getLogicalId ()), $ action , 'Wakeup- ' . $ eqLogic ->getLogicalId (), true , 'alertingReturnBack ' );
15931567 }
15941568 $ eqLogic ->setConfiguration ('missedWakeup ' , true );
15951569 $ eqLogic ->save ();
@@ -1605,11 +1579,7 @@ public static function constructHealthPage($_values, $_mobile = False) {
16051579 $ healthPage .= '<tr><td> ' . $ values ['id ' ] . '</td> ' ;
16061580 $ eqLogic = self ::byLogicalId ($ values ['id ' ], __CLASS__ );
16071581 if (is_object ($ eqLogic )) {
1608- $ image = 'plugins/zwavejs/core/config/devices/ ' . $ eqLogic ->getImgFilePath ();
1609- if (!is_file (dirname (__FILE__ ) . '/../config/devices/ ' . $ eqLogic ->getImgFilePath ())) {
1610- $ image = 'plugins/zwavejs/plugin_info/zwavejs_icon.png ' ;
1611- }
1612- $ healthPage .= '<td><img src=" ' . $ image . '" height="40"/> ' . $ eqLogic ->getHumanName (true ) . '</td> ' ;
1582+ $ healthPage .= '<td><img src=" ' . $ eqLogic ->getImage () . '" height="40"/> ' . $ eqLogic ->getHumanName (true ) . '</td> ' ;
16131583 } else {
16141584 $ healthPage .= '<td><img src="plugins/zwavejs/plugin_info/zwavejs_icon.png" height="40"/> ' . $ values ['productLabel ' ] . ' - ' . $ values ['productDescription ' ] . '</td> ' ;
16151585 }
@@ -1757,15 +1727,11 @@ public static function getWaiting() {
17571727 foreach (self ::byType (__CLASS__ ) as $ eqLogic ) {
17581728 $ waitings = $ eqLogic ->getCache ('waiting ' , array ());
17591729 if (is_object ($ eqLogic )) {
1760- $ image = 'plugins/zwavejs/core/config/devices/ ' . $ eqLogic ->getImgFilePath ();
1761- if (!is_file (dirname (__FILE__ ) . '/../config/devices/ ' . $ eqLogic ->getImgFilePath ())) {
1762- $ image = 'plugins/zwavejs/plugin_info/zwavejs_icon.png ' ;
1763- }
17641730 foreach ($ waitings as $ property => $ data ) {
17651731 $ globWaiting [] = array (
17661732 'id ' => $ eqLogic ->getLogicalId (),
17671733 'eqId ' => $ eqLogic ->getId (),
1768- 'image ' => $ image ,
1734+ 'image ' => $ eqLogic -> getImage () ,
17691735 'name ' => $ eqLogic ->getHumanName (true ),
17701736 'property ' => $ property ,
17711737 'value ' => $ data ['value ' ],
@@ -2276,9 +2242,15 @@ public function getImgFilePath() {
22762242 }
22772243
22782244 public function getImage () {
2245+ $ default = parent ::getImage ();
2246+ $ plugin = plugin::byId (__CLASS__ );
2247+ if ($ default != $ plugin ->getPathImgIcon ()) {
2248+ return $ default ; // this is a custom image uploaded by the user, we keep it
2249+ }
2250+
22792251 $ file = 'plugins/zwavejs/core/config/devices/ ' . $ this ->getImgFilePath ();
22802252 if (!is_file (__DIR__ . '/../../../../ ' . $ file )) {
2281- return ' plugins/zwavejs/plugin_info/zwavejs_icon.png ' ;
2253+ return $ default ;
22822254 }
22832255 return $ file ;
22842256 }
0 commit comments