2222class mobile extends eqLogic {
2323 /* * *************************Attributs****************************** */
2424
25- public static $ _pluginSuported = array ('mobile ' , 'openzwave ' , 'rfxcom ' , 'edisio ' , 'mpower ' , 'mySensors ' , 'Zibasedom ' , 'virtual ' , 'camera ' , 'weather ' , 'philipsHue ' , 'enocean ' , 'wifipower ' , 'alarm ' , 'mode ' , 'apcupsd ' , 'btsniffer ' , 'dsc ' , 'rflink ' , 'mysensors ' , 'relaynet ' , 'remora ' , 'unipi ' , 'eibd ' , 'thermostat ' , 'netatmoThermostat ' , 'espeasy ' , 'jeelink ' , 'teleinfo ' , 'tahoma ' , 'protexiom ' , 'lifx ' , 'wattlet ' , 'rfplayer ' , 'openenocean ' ,'netatmoWeather ' ,'Volets ' );
25+ public static $ _pluginSuported = array ('mobile ' , 'openzwave ' , 'rfxcom ' , 'edisio ' , 'mpower ' , 'mySensors ' , 'Zibasedom ' , 'virtual ' , 'camera ' , 'weather ' , 'philipsHue ' , 'enocean ' , 'wifipower ' , 'alarm ' , 'mode ' , 'apcupsd ' , 'btsniffer ' , 'dsc ' , 'rflink ' , 'mysensors ' , 'relaynet ' , 'remora ' , 'unipi ' , 'eibd ' , 'thermostat ' , 'netatmoThermostat ' , 'espeasy ' , 'jeelink ' , 'teleinfo ' , 'tahoma ' , 'protexiom ' , 'lifx ' , 'wattlet ' , 'rfplayer ' , 'openenocean ' , 'netatmoWeather ' , 'Volets ' );
2626
27- public static $ _pluginWidget = array ('alarm ' , 'camera ' , 'thermostat ' , 'netatmoThermostat ' , 'weather ' , 'mode ' ,'mobile ' );
27+ public static $ _pluginWidget = array ('alarm ' , 'camera ' , 'thermostat ' , 'netatmoThermostat ' , 'weather ' , 'mode ' , 'mobile ' );
2828
2929 public static $ _pluginMulti = array ('LIGHT_STATE ' , 'ENERGY_STATE ' , 'FLAP_STATE ' , 'HEATING_STATE ' , 'SIREN_STATE ' , 'LOCK_STATE ' );
3030
@@ -97,26 +97,26 @@ public static function getTemplateJson() {
9797 }
9898 return json_decode (cmd::cmdToValue (file_get_contents (dirname (__FILE__ ) . '/../../data/mobile.json ' )), true );
9999 }
100-
101- public static function makeSaveJson ($ data = '' , $ mobileID , $ type = 'dashboard ' ) {
102- $ path = dirname (__FILE__ ) . '/../../data/ ' . $ mobileID. '/ ' . $ type. '.json ' ;
100+
101+ public static function makeSaveJson ($ data = array (), $ mobileID , $ type = 'dashboard ' ) {
102+ $ path = dirname (__FILE__ ) . '/../../data/ ' . $ mobileID . '/ ' . $ type . '.json ' ;
103103 if (!file_exists (dirname (__FILE__ ) . '/../../data ' )) {
104104 mkdir (dirname (__FILE__ ) . '/../../data ' );
105105 }
106- if (!file_exists (dirname (__FILE__ ) . '/../../data/ ' . $ mobileID )) {
107- mkdir (dirname (__FILE__ ) . '/../../data/ ' . $ mobileID );
106+ if (!file_exists (dirname (__FILE__ ) . '/../../data/ ' . $ mobileID )) {
107+ mkdir (dirname (__FILE__ ) . '/../../data/ ' . $ mobileID );
108108 }
109- if (file_exists (dirname (__FILE__ ) . '/../../data/ ' . $ mobileID. '/ ' . $ type. '.json ' )) {
110- unlink (dirname (__FILE__ ) . '/../../data/ ' . $ mobileID. '/ ' . $ type. '.json ' );
109+ if (file_exists (dirname (__FILE__ ) . '/../../data/ ' . $ mobileID . '/ ' . $ type . '.json ' )) {
110+ unlink (dirname (__FILE__ ) . '/../../data/ ' . $ mobileID . '/ ' . $ type . '.json ' );
111111 }
112- file_put_contents (dirname (__FILE__ ) . '/../../data/ ' . $ mobileID. '/ ' . $ type. '.json ' , json_encode ($ data ));
112+ file_put_contents (dirname (__FILE__ ) . '/../../data/ ' . $ mobileID . '/ ' . $ type . '.json ' , json_encode ($ data ));
113113 }
114-
115- public static function getSaveJson ($ mobileID ,$ type = 'dashboard ' ) {
116- if (!file_exists (dirname (__FILE__ ) . '/../../data/ ' . $ mobileID. '/ ' . $ type. '.json ' )) {
117- self ::makeSaveJson ();
114+
115+ public static function getSaveJson ($ mobileID , $ type = 'dashboard ' ) {
116+ if (!file_exists (dirname (__FILE__ ) . '/../../data/ ' . $ mobileID . '/ ' . $ type . '.json ' )) {
117+ self ::makeSaveJson (array (), $ mobileID , $ type );
118118 }
119- return json_decode (file_get_contents (dirname (__FILE__ ) . '/../../data/ ' . $ mobileID. '/ ' . $ type. '.json ' ), true );
119+ return json_decode (file_get_contents (dirname (__FILE__ ) . '/../../data/ ' . $ mobileID . '/ ' . $ type . '.json ' ), true );
120120 }
121121
122122 public static function discovery_eqLogic ($ plugin = array (), $ hash = null ) {
@@ -127,7 +127,7 @@ public static function discovery_eqLogic($plugin = array(), $hash = null) {
127127 continue ;
128128 }
129129 foreach ($ eqLogics as $ eqLogic ) {
130- if ($ eqLogic ->getEqType_name () != 'mobile ' ){
130+ if ($ eqLogic ->getEqType_name () != 'mobile ' ) {
131131 if ($ eqLogic ->getIsEnable () != 1 ) {
132132 continue ;
133133 }
@@ -139,7 +139,7 @@ public static function discovery_eqLogic($plugin = array(), $hash = null) {
139139 }
140140 }
141141 $ eqLogic_array = utils::o2a ($ eqLogic );
142- if ($ eqLogic ->getEqType_name () == 'mobile ' ){
142+ if ($ eqLogic ->getEqType_name () == 'mobile ' ) {
143143 if (isset ($ eqLogic_array ["logicalId " ])) {
144144 $ eqLogic_array ["localApiKey " ] = $ eqLogic_array ["logicalId " ];
145145 }
@@ -182,6 +182,9 @@ public static function discovery_cmd($plugin = array(), $eqLogics = null, $_with
182182 if (in_array ($ cmd ->getGeneric_type (), ['GENERIC_ERROR ' , 'DONT ' ])) {
183183 continue ;
184184 }
185+ if (!isset ($ eqLogic ['eqType_name ' ])) {
186+ $ eqLogic ['eqType_name ' ] = '' ;
187+ }
185188 if ($ cmd ->getIsVisible () != 1 && !in_array ($ cmd ->getGeneric_type (), $ genericisvisible ) && !in_array ($ eqLogic ['eqType_name ' ], self ::$ _pluginWidget )) {
186189 continue ;
187190 }
@@ -429,7 +432,7 @@ public function getQrCode() {
429432 public static function jsonPublish ($ os , $ titre , $ message , $ badge = 'null ' , $ type , $ idNotif , $ answer , $ timeout ) {
430433 $ dateNotif = date ("Y-m-d H:i:s " );
431434 $ badge = '+1 ' ;
432- $ message = preg_replace ("# {2,}# " ," " ,preg_replace ("#( \r\n| \n\r| \n| \r)# " ,"\\\\\\n " ,$ message ));
435+ $ message = preg_replace ("# {2,}# " , " " , preg_replace ("#( \r\n| \n\r| \n| \r)# " , "\\\\\\n " , $ message ));
433436 if ($ timeout != 'nok ' ) {
434437 $ timeout = date ('Y-m-d H:i:s ' , strtotime ("$ dateNotif + $ timeout SECONDS " ));
435438 }
@@ -470,48 +473,56 @@ public static function notification($arn, $os, $titre, $message, $badge = 'null'
470473 curl_close ($ ch );
471474 log::add ('mobile ' , 'debug ' , 'notification resultat > ' . $ server_output );
472475 }
473-
474- public function SaveGeoloc ($ geoloc ){
475- log::add ('mobile ' , 'debug ' , '|----------------------------------- ' );
476- log::add ('mobile ' , 'debug ' , '|--debut de la fonction SaveGeoLoc-- ' );
477- log::add ('mobile ' , 'debug ' , '|----------------------------------- ' );
478- log::add ('mobile ' , 'debug ' , '| ' );
479- $ eqLogicMobile = eqLogic::byLogicalId ($ geoloc ['iQ ' ], 'mobile ' );
480- log::add ('mobile ' , 'debug ' , '| iQ = ' . $ geoloc ['iQ ' ]);
481- if (isset ($ eqLogicMobile )){
482- log::add ('mobile ' , 'debug ' , '| Mobile bien trouvé dans cette Jeedom ' );
483- log::add ('mobile ' , 'debug ' , '| Objet > ' . $ eqLogicMobile ->getId ());
484- }
485- $ cmdgeoloc = cmd::byEqLogicIdAndLogicalId ($ eqLogicMobile ->getId (),'geoId_ ' . $ geoloc ['id ' ]);
486- if (!is_object ($ cmdgeoloc )){
476+
477+ public function SaveGeoloc ($ geoloc ) {
478+ log::add ('mobile ' , 'debug ' , '|----------------------------------- ' );
479+ log::add ('mobile ' , 'debug ' , '|--debut de la fonction SaveGeoLoc-- ' );
480+ log::add ('mobile ' , 'debug ' , '|----------------------------------- ' );
481+ log::add ('mobile ' , 'debug ' , '| ' );
482+ $ eqLogicMobile = eqLogic::byLogicalId ($ geoloc ['Iq ' ], 'mobile ' );
483+ log::add ('mobile ' , 'debug ' , '| Iq = ' . $ geoloc ['Iq ' ]);
484+ if (isset ($ eqLogicMobile )) {
485+ log::add ('mobile ' , 'debug ' , '| Mobile bien trouvé dans cette Jeedom ' );
486+ log::add ('mobile ' , 'debug ' , '| Objet > ' . $ eqLogicMobile ->getId ());
487+ }
488+ $ cmdgeoloc = cmd::byEqLogicIdAndLogicalId ($ eqLogicMobile ->getId (), 'geoId_ ' . $ geoloc ['id ' ]);
489+ if (!is_object ($ cmdgeoloc )) {
487490 $ cmdgeoloc = new mobileCmd ();
488- $ cmdgeoloc ->setLogicalId ('geoId_ ' . $ geoloc ['id ' ]);
491+ $ cmdgeoloc ->setLogicalId ('geoId_ ' . $ geoloc ['id ' ]);
489492 $ cmdgeoloc ->setEqLogic_id ($ eqLogicMobile ->getId ());
490493 $ cmdgeoloc ->setType ('info ' );
491494 $ cmdgeoloc ->setSubType ('binary ' );
492495 $ cmdgeoloc ->setIsVisible (1 );
493496 }
494- $ cmdgeoloc ->setName (__ ($ geoloc ['name ' ], __FILE__ ));
495- $ cmdgeoloc ->setConfiguration ('latitude ' , $ geoloc ['latitude ' ]);
496- $ cmdgeoloc ->setConfiguration ('longitude ' , $ geoloc ['longitude ' ]);
497- $ cmdgeoloc ->setConfiguration ('subtitle ' , $ geoloc ['subtitle ' ]);
498- $ cmdgeoloc ->setConfiguration ('radius ' , $ geoloc ['radius ' ]);
499- $ cmdgeoloc ->save ();
497+ $ cmdgeoloc ->setName (__ ($ geoloc [ ' id ' ]. ' - ' . $ geoloc ['name ' ], __FILE__ ));
498+ $ cmdgeoloc ->setConfiguration ('latitude ' , $ geoloc ['latitude ' ]);
499+ $ cmdgeoloc ->setConfiguration ('longitude ' , $ geoloc ['longitude ' ]);
500+ $ cmdgeoloc ->setConfiguration ('subtitle ' , $ geoloc ['subtitle ' ]);
501+ $ cmdgeoloc ->setConfiguration ('radius ' , $ geoloc ['radius ' ]);
502+ $ cmdgeoloc ->save ();
500503 }
501-
502- public function DelGeoloc ($ geoloc ){
503- $ eqLogicMobile = eqLogic::byLogicalId ($ geoloc ['iQ ' ], 'mobile ' );
504- $ cmdgeoloc = cmd::byEqLogicIdAndLogicalId ($ eqLogicMobile ->getId (),'geoId_ ' .$ geoloc ['id ' ]);
505- if (isset ($ cmdgeoloc )){
504+
505+ public function delGeoloc ($ geoloc ) {
506+ log::add ('mobile ' , 'debug ' , 'Geoloc lancement DEL du mobile > ' .$ geoloc ['Iq ' ].' pour ' .$ geoloc ['id ' ]);
507+ $ eqLogicMobile = eqLogic::byLogicalId ($ geoloc ['Iq ' ], 'mobile ' );
508+ $ cmdgeoloc = cmd::byEqLogicIdAndLogicalId ($ eqLogicMobile ->getId (), 'geoId_ ' . $ geoloc ['id ' ]);
509+ if (isset ($ cmdgeoloc )) {
506510 $ cmdgeoloc ->remove ();
507511 }
508512 }
509-
510- public function EventGeoloc ($ geoloc ){
511- $ eqLogicMobile = eqLogic::byLogicalId ($ geoloc ['iQ ' ], 'mobile ' );
512- $ cmdgeoloc = cmd::byEqLogicIdAndLogicalId ($ eqLogicMobile ->getId (),'geoId_ ' .$ geoloc ['id ' ]);
513- if (isset ($ cmdgeoloc )){
514- $ cmdgeoloc ->event ($ geoloc ['value ' ]);
513+
514+ public function EventGeoloc ($ geoloc ) {
515+ log::add ('mobile ' , 'debug ' , 'Geoloc Event du mobile > ' .$ geoloc ['Iq ' ].' pour ' .$ geoloc ['id ' ]);
516+ $ eqLogicMobile = eqLogic::byLogicalId ($ geoloc ['Iq ' ], 'mobile ' );
517+ $ cmdgeoloc = cmd::byEqLogicIdAndLogicalId ($ eqLogicMobile ->getId (), 'geoId_ ' . $ geoloc ['id ' ]);
518+ if (isset ($ cmdgeoloc )) {
519+ log::add ('mobile ' , 'debug ' , 'commande trouvé ' );
520+ if (geoloc['value ' ] !== $ cmdgeoloc ->execCmd ()){
521+ log::add ('mobile ' , 'debug ' , 'Valeur non pareil. ' );
522+ $ cmdgeoloc ->event ($ geoloc ['value ' ]);
523+ }else {
524+ log::add ('mobile ' , 'debug ' , 'Valeur pareil. > ' .geoloc['value ' ].' / ' .$ cmdgeoloc ->execCmd ());
525+ }
515526 }
516527 }
517528
@@ -557,7 +568,7 @@ class mobileCmd extends cmd {
557568 /* * ***********************Methode static*************************** */
558569
559570 /* * *********************Methode d'instance************************* */
560-
571+
561572 public function dontRemoveCmd () {
562573 return true ;
563574 }
@@ -593,3 +604,4 @@ public function execute($_options = array()) {
593604}
594605
595606?>
607+
0 commit comments