Ejemplo n.º 1
0
 public function execute($_options = array())
 {
     $replace = array();
     switch ($this->getSubType()) {
         case 'slider':
             $replace['#slider#'] = $_options['slider'];
             break;
         case 'color':
             $replace['#color#'] = $_options['color'];
             break;
         case 'message':
             $replace['#title#'] = $_options['title'];
             $replace['#message#'] = $_options['message'];
             break;
     }
     $eqLogic = $this->getEqLogic();
     $url = 'https://maker.ifttt.com/trigger/' . $this->getConfiguration('event', 'jeedom') . '/with/key/' . $eqLogic->getConfiguration('key') . '?';
     if ($this->getConfiguration('value1') != '') {
         $url .= 'value1=' . urlencode(jeedom::evaluateExpression(str_replace(array_keys($replace), $replace, $this->getConfiguration('value1')))) . '&';
     }
     if ($this->getConfiguration('value2') != '') {
         $url .= 'value2=' . urlencode(jeedom::evaluateExpression(str_replace(array_keys($replace), $replace, $this->getConfiguration('value2')))) . '&';
     }
     if ($this->getConfiguration('value3') != '') {
         $url .= 'value3=' . urlencode(jeedom::evaluateExpression(str_replace(array_keys($replace), $replace, $this->getConfiguration('value3')))) . '&';
     }
     $url = trim($url, '&');
     $request_http = new com_http($url);
     $request_http->exec(5, 3);
 }
Ejemplo n.º 2
0
 public function execute($_options = array())
 {
     $request_http = new com_http(trim($this->getConfiguration('webhook')));
     $post = array('text' => trim($_options['title'] . ' ' . $_options['message']));
     if ($this->getConfiguration('destination') != '') {
         $post['channel'] = $this->getConfiguration('destination');
     }
     $request_http->setPost(array('payload' => json_encode($post)));
     $request_http->exec(1, 1);
 }
Ejemplo n.º 3
0
 public function execute($_options = null)
 {
     if ($_options === null) {
         throw new Exception('[PushingBox] Les options de la fonction ne peuvent etre null');
     }
     if ($_options['message'] == '') {
         throw new Exception('[PushingBox] Le message et le sujet ne peuvent être vide');
     }
     $request = new com_http(PUSHINGBOXADDR . '?key=' . $this->getConfiguration('key') . '&message=' . urlencode($_options['message']));
     return $request->exec(6000, 0, false);
 }
Ejemplo n.º 4
0
 public static function cron30($_eqlogic_id = null)
 {
     if ($_eqlogic_id !== null) {
         $eqLogics = array(eqLogic::byId($_eqlogic_id));
     } else {
         $eqLogics = eqLogic::byType('wazeintime');
         sleep(rand(0, 120));
     }
     foreach ($eqLogics as $wazeintime) {
         if ($wazeintime->getIsEnable() == 1) {
             try {
                 $start = $wazeintime->getPosition('start');
                 $end = $wazeintime->getPosition('end');
                 $row = $wazeintime->getConfiguration('NOA') ? '' : 'row-';
                 $wazeRouteurl = 'https://www.waze.com/' . $row . 'RoutingManager/routingRequest?from=x%3A' . $start['lon'] . '+y%3A' . $start['lat'] . '&to=x%3A' . $end['lon'] . '+y%3A' . $end['lat'] . '&at=0&returnJSON=true&returnGeometries=true&returnInstructions=true&timeout=60000&nPaths=3&options=AVOID_TRAILS%3At';
                 $request_http = new com_http($wazeRouteurl);
                 $request_http->setUserAgent('User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0');
                 $json = json_decode($request_http->exec(6, 2), true);
                 if (isset($json['error'])) {
                     throw new Exception($json['error']);
                 }
                 $data = self::extractInfo($json);
                 $wazeRoutereturl = 'https://www.waze.com/' . $row . 'RoutingManager/routingRequest?from=x%3A' . $end['lon'] . '+y%3A' . $end['lat'] . '&to=x%3A' . $start['lon'] . '+y%3A' . $start['lat'] . '&at=0&returnJSON=true&returnGeometries=true&returnInstructions=true&timeout=60000&nPaths=3&options=AVOID_TRAILS%3At';
                 $request_http = new com_http($wazeRoutereturl);
                 $request_http->setUserAgent('User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0');
                 $json = json_decode($request_http->exec(6, 2), true);
                 if (isset($json['error'])) {
                     throw new Exception($json['error']);
                 }
                 $data = array_merge($data, self::extractInfo($json, 'ret'));
                 log::add('wazeintime', 'debug', 'Data : ' . print_r($data, true));
                 foreach ($wazeintime->getCmd('info') as $cmd) {
                     if ($cmd->getLogicalId() == 'lastrefresh') {
                         $cmd->event(date('H:i'));
                         continue;
                     }
                     if (!isset($data[$cmd->getLogicalId()])) {
                         continue;
                     }
                     if ($cmd->formatValue($data[$cmd->getLogicalId()]) != $cmd->execCmd()) {
                         $cmd->setCollectDate('');
                         $cmd->event($data[$cmd->getLogicalId()]);
                     }
                 }
                 $wazeintime->refreshWidget();
             } catch (Exception $e) {
                 log::add('wazeintime', 'error', $e->getMessage());
             }
         }
     }
 }
Ejemplo n.º 5
0
 public function execute($_options = array())
 {
     $eqLogic = $this->getEqLogic();
     $zone = '';
     if ($eqLogic->getConfiguration('zone', 'main') == 2) {
         $zone = '&ZoneName=ZONE2';
     }
     if ($this->getLogicalId() == 'on') {
         $request_http = new com_http('http://' . $eqLogic->getConfiguration('ip') . '/MainZone/index.put.asp?cmd0=PutZone_OnOff%2FON' . $zone);
         $request_http->exec();
     } else {
         if ($this->getLogicalId() == 'off') {
             $request_http = new com_http('http://' . $eqLogic->getConfiguration('ip') . '/MainZone/index.put.asp?cmd0=PutZone_OnOff%2FOFF' . $zone);
             $request_http->exec();
         } else {
             if ($this->getLogicalId() == 'volume_p') {
                 $request_http = new com_http('http://' . $eqLogic->getConfiguration('ip') . '/MainZone/index.put.asp?cmd0=PutMasterVolumeBtn%2F%3E' . $zone);
                 $request_http->exec();
             } else {
                 if ($this->getLogicalId() == 'volume_m') {
                     $request_http = new com_http('http://' . $eqLogic->getConfiguration('ip') . '/MainZone/index.put.asp?cmd0=PutMasterVolumeBtn%2F%3C' . $zone);
                     $request_http->exec();
                 } else {
                     if ($this->getLogicalId() == 'refresh') {
                     } else {
                         if ($this->getLogicalId() == 'mute') {
                             $request_http = new com_http('http://' . $eqLogic->getConfiguration('ip') . '/MainZone/index.put.asp?cmd0=PutVolumeMute/TOGGLE');
                             $request_http->exec();
                         } else {
                             $request_http = new com_http('http://' . $eqLogic->getConfiguration('ip') . '/MainZone/index.put.asp?cmd0=PutZone_InputFunction%2F' . $this->getLogicalId() . $zone);
                             $request_http->exec();
                         }
                     }
                 }
             }
         }
     }
     sleep(1);
     $eqLogic->updateInfo();
 }
Ejemplo n.º 6
0
 public function getWeatherFromYahooXml()
 {
     if ($this->getConfiguration('city') == '') {
         return false;
     }
     $cache = cache::byKey('yahooWeatherXml' . $this->getConfiguration('city'));
     if ($cache->getValue() === '' || $cache->getValue() == 'false') {
         $request = new com_http('http://weather.yahooapis.com/forecastrss?w=' . urlencode($this->getConfiguration('city')) . '&u=c');
         $xmlMeteo = $request->exec(5000, 0);
         cache::set('yahooWeatherXml' . $this->getConfiguration('city'), $xmlMeteo, 7200);
     } else {
         $xmlMeteo = $cache->getValue();
     }
     return self::parseXmlWeather($xmlMeteo);
 }
Ejemplo n.º 7
0
 public function execute($_options = null)
 {
     $value = $this->getConfiguration('value');
     switch ($this->getType()) {
         case 'action':
             switch ($this->getSubType()) {
                 case 'slider':
                     $value = str_replace('#slider#', $_options['slider'], $value);
                     break;
                 case 'color':
                     $value = str_replace('#color#', $_options['color'], $value);
                     return $this->setRGBColor($value);
                     break;
             }
             break;
     }
     $request = zwave::makeBaseUrl() . '/ZWaveAPI/Run/';
     $request .= 'devices[' . $this->getEqLogic()->getLogicalId() . ']';
     if ($this->getConfiguration('instanceId') != '') {
         $request .= '.instances[' . $this->getConfiguration('instanceId') . ']';
     }
     $request .= '.commandClasses[' . $this->getConfiguration('class') . ']';
     $request .= '.' . $value;
     $http = new com_http($request);
     $result = zwave::handleError($http->exec(1, 3, true));
     if (is_json($result)) {
         $result = json_decode($result, true);
         $value = self::handleResult($result);
         if (isset($result['updateTime'])) {
             $this->setCollectDate(date('Y-m-d H:i:s', $result['updateTime']));
         }
     } else {
         $value = $result;
         if ($value === true || $value == 'true') {
             return 1;
         }
         if ($value === false || $value == 'false') {
             return 0;
         }
         if (is_numeric($value)) {
             return round($value, 1);
         }
     }
     return $value;
 }
Ejemplo n.º 8
0
 public function execute($_options = null)
 {
     $jeenode = $this->getEqLogic();
     $jeenodeReal = $jeenode->getEqReal();
     $mode = $this->getConfiguration('mode');
     $typeCmd = $this->getConfiguration('type');
     $port = $jeenode->getLogicalId();
     if ($jeenode->getLogicalId() == 'I2C') {
         if ($typeCmd == 'c' && $_options != null) {
             $rgb = self::hex2rgb($_options['color']);
             $request = new com_http($jeenodeReal->getHttpHeader() . '&t=' . $typeCmd . '&m=' . $mode . '&p=5&v=' . $rgb[0] . '&v1=' . $rgb[1] . '&v2=' . $rgb[2]);
             return $request->exec();
         }
     } else {
         $value = '';
         if ($typeCmd == 'p' && $_options != null) {
             $value = $_options['slider'] / 100 * 255;
         }
         if ($_options === null && $this->getConfiguration('value') != '') {
             $value = $this->getConfiguration('value');
         }
         $request = new com_http($jeenodeReal->getHttpHeader() . '&t=' . $typeCmd . '&m=' . $mode . '&p=' . $port . '&v=' . $value);
         $result = $request->exec();
         if ($result == 'NR') {
             throw new Exception('Erreur lors de la recuperation d\'information ' . $jeenode->getName() . ' (' . $jeenodeReal->getName() . '). Retour jeenode : ' . $result);
         }
         if ($this->getType() == 'info' && $this->getConfiguration('calcul') != '') {
             $returnValue = intval($result);
             $calcul = str_replace('#V#', $returnValue, $this->getConfiguration('calcul'));
             $test = new evaluate();
             $result = $test->Evaluer($calcul);
         }
         $jeenodeReal->updateLastCommunication();
         if ($this->getType() == 'action' && $_options != null && $result != $value) {
             throw new Exception('Erreur lors de l\'éxécution de l\'action sur ' . $jeenode->getName() . ' (' . $jeenodeReal->getName() . '). Retour jeenode : ' . $result);
         }
         return $result;
     }
 }
Ejemplo n.º 9
0
 public function execute($_options = null)
 {
     $nabaztag = $this->getEqLogic();
     $parameters = $this->getConfiguration('parameters');
     $type = $this->getConfiguration('request');
     switch ($this->subType) {
         case 'message':
             $parameters = urlencode(str_replace('#message#', $_options['message'], $parameters));
             break;
         case 'slider':
             $parameters = str_replace('#slider#', $_options['slider'], $parameters);
             break;
     }
     if ($type == 'urlList') {
         $parameters = urlencode($parameters);
         $request = 'http://' . $nabaztag->getConfiguration('addr') . '/ojn/FR/api_stream.jsp?sn=' . $nabaztag->getConfiguration('mac') . '&token=' . $nabaztag->getConfiguration('token') . '&' . $type . '=' . $parameters;
     } else {
         $request = 'http://' . $nabaztag->getConfiguration('addr') . '/ojn/FR/api.jsp?sn=' . $nabaztag->getConfiguration('mac') . '&token=' . $nabaztag->getConfiguration('token') . '&' . $type . '=' . $parameters;
     }
     log::add('nabaztag', 'debug', $request);
     try {
         $request = new com_http($request);
         $result = $request->exec(0.1, 1);
         log::add('nabaztag', 'debug', print_r($result, true));
         $xml = new SimpleXMLElement($result);
         $json = json_decode(json_encode($xml), TRUE);
     } catch (Exception $e) {
         log::add('nabaztag', 'debug', log::exception($e));
     }
     if (isset($json) && is_array($json) && isset($json['message']) && ($json['message'] == 'PREMIUM_ONLY' || $json['message'] == 'PLUGINNOTAVAILABLE')) {
         throw new Exception($json['message'] . ' : ' . $json['comment']);
     }
 }
Ejemplo n.º 10
0
 public function preSave()
 {
     $this->setDatetime(date('Y-m-d H:i:s'));
     if ($this->getId() == '') {
         $connection = connection::byIp($this->getIp());
         if (is_object($connection)) {
             $this->setId($connection->getId());
         }
     }
     if ($this->getLocalisation() == '' && !netMatch('192.*.*.*', $this->getIp()) && !netMatch('127.0.0.1', $this->getIp()) && !netMatch('10.*.*.*', $this->getIp())) {
         try {
             $http = new com_http('http://ipinfo.io/' . $this->getIp());
             $http->setLogError(false);
             $details = json_decode($http->exec(1, 2), true);
             $localisation = '';
             if (is_array($details)) {
                 if (isset($details['country'])) {
                     $localisation .= $details['country'] . ' - ';
                 }
                 if (isset($details['region'])) {
                     $localisation .= $details['region'] . ' - ';
                 }
                 if (isset($details['postal'])) {
                     $localisation .= ' (' . $details['postal'] . ') ';
                 }
                 if (isset($details['city'])) {
                     $localisation .= $details['city'] . ' - ';
                 }
                 $this->setLocalisation($localisation);
                 if (isset($details['loc'])) {
                     $this->setInformations('coordonate', $details['loc']);
                 }
                 if (isset($details['org'])) {
                     $this->setInformations('org', $details['org']);
                 }
                 if (isset($details['hostname'])) {
                     $this->setInformations('hostname', $details['hostname']);
                 }
             }
         } catch (Exception $e) {
             $this->setLocalisation('Unknow');
         }
     }
 }
Ejemplo n.º 11
0
 public function execute($_options = null)
 {
     $karotz = $this->getEqLogic();
     if ($this->getLogicalId() == 'refresh') {
         $karotz->cron30($karotz->getId());
         return true;
     }
     if ($this->type != 'action') {
         return;
     }
     $requestHeader = 'http://' . $karotz->getConfiguration('addr') . '/cgi-bin/';
     $type = $this->getConfiguration('request');
     if ($this->getConfiguration('parameters') == '') {
         $request = $requestHeader . $type;
     } else {
         $parameters = $this->getConfiguration('parameters');
         if ($_options != null) {
             switch ($this->getSubType()) {
                 case 'message':
                     if ($this->getLogicalId() == 'tts') {
                         $parameters = str_replace('#message#', rawurlencode($_options['message']), $parameters);
                         if (isset($_options['title']) && $_options['title'] != null && strpos($_options['title'], ' ') === false) {
                             $parameters = str_replace('#title#', $_options['title'], $parameters);
                         } else {
                             $parameters = str_replace('#title#', '', $parameters);
                         }
                         $parameters = trim($parameters, '&');
                         if ($karotz->getConfiguration('ttsengine') != 0 && strpos($parameters, 'engine') === false) {
                             $parameters .= '&engine=' . $karotz->getConfiguration('ttsengine');
                         }
                     } else {
                         $parameters = str_replace('#message#', $_options['message'], $parameters);
                         $parameters = str_replace('#title#', rawurlencode($_options['title']), $parameters);
                     }
                     break;
                 case 'slider':
                     $parameters = str_replace('#slider#', $_options['slider'], $parameters);
                     break;
                 case 'color':
                     $parameters = str_replace('#', '', str_replace('#color#', $_options['color'], $parameters));
                     break;
             }
         }
         $request = $requestHeader . $type . '?' . $parameters;
     }
     $request = new com_http($request);
     $request->exec(10, 1);
     if ($this->getLogicalId() == 'color') {
         $led_pulse = $karotz->getCmd('info', 'led_pulse');
         if (is_object($led_pulse) && $led_pulse->execCmd() == 1) {
             $pulseon = $karotz->getCmd(null, 'pulseon');
             if (is_object($pulseon)) {
                 $pulseon->execCmd();
             }
         }
     }
     if (in_array($this->getLogicalId(), array('wakeup', 'sleeping', 'color', 'pulseon', 'pulseoff'))) {
         sleep(1);
         $karotz->cron30($karotz->getId());
     }
     return;
 }
Ejemplo n.º 12
0
 public function updateIP()
 {
     $externalIP = $this->getCmd(null, 'externalIP');
     if (!is_object($externalIP)) {
         throw new Exception(__('Commande externalIP inexistante', __FILE__));
     }
     $ip = $externalIP->execCmd(null, 2);
     switch ($this->getConfiguration('type')) {
         case 'dyndnsorg':
             $url = 'https://' . $this->getConfiguration('username') . ':' . $this->getConfiguration('password') . '@members.dyndns.org/nic/update?hostname=' . $this->getConfiguration('hostname') . '&myip=' . $ip;
             $request_http = new com_http($url);
             $request_http->setUserAgent('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.12) Gecko/20070508 Firefox/1.5.0.12');
             $result = $request_http->exec();
             if (strpos($result, 'good') === false) {
                 throw new Exception(__('Erreur de mise à jour de dyndns.org : ', __FILE__) . $result);
             }
             break;
         case 'noipcom':
             $url = 'https://' . $this->getConfiguration('username') . ':' . $this->getConfiguration('password') . '@dynupdate.no-ip.com/nic/update?hostname=' . $this->getConfiguration('hostname') . '&myip=' . $ip;
             $request_http = new com_http($url);
             $request_http->setUserAgent('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.12) Gecko/20070508 Firefox/1.5.0.12');
             $result = $request_http->exec();
             if (strpos($result, 'good') === false || strpos($result, 'nochg') === false) {
                 throw new Exception(__('Erreur de mise à jour de noip.com : ', __FILE__) . $result);
             }
             break;
         case 'ovhcom':
             $url = 'https://' . $this->getConfiguration('username') . ':' . $this->getConfiguration('password') . '@www.ovh.com/nic/update?system=dyndns&hostname=' . $this->getConfiguration('hostname') . '&myip=' . $ip;
             $request_http = new com_http($url);
             $request_http->setUserAgent('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.12) Gecko/20070508 Firefox/1.5.0.12');
             $result = $request_http->exec();
             if (strpos($result, 'good') === false && strpos($result, 'nochg') === false) {
                 throw new Exception(__('Erreur de mise à jour de ovh.com : ', __FILE__) . $result);
             }
             break;
     }
 }
Ejemplo n.º 13
0
 public static function syncEwattch($_ip)
 {
     $request_http = new com_http($_ip . '/log.json?mode=10');
     $result = json_decode($request_http->exec(1, 1), true);
     foreach ($result['resource']['electricity'] as $resource) {
         $eqLogic = self::byLogicalId('electricity_' . $resource['name'], 'ewattch');
         if (!is_object($eqLogic)) {
             $eqLogic = new self();
             $eqLogic->setName('electricity_' . $resource['name']);
             $eqLogic->setEqType_name('ewattch');
             $eqLogic->setIsVisible(1);
             $eqLogic->setIsEnable(1);
             $eqLogic->setLogicalId('electricity_' . $resource['name']);
             $eqLogic->setConfiguration('ip', $_ip);
             $eqLogic->setCategory('energy', 1);
             $eqLogic->save();
         }
         $index = $eqLogic->getCmd(null, 'index');
         if (!is_object($index)) {
             $index = new ewattchCmd();
             $index->setLogicalId('index');
             $index->setIsVisible(1);
             $index->setName(__('Index', __FILE__));
         }
         $index->setUnite('wh');
         $index->setType('info');
         $index->setSubType('numeric');
         $index->setEventOnly(1);
         $index->setEqLogic_id($eqLogic->getId());
         $index->save();
         $cost = $eqLogic->getCmd(null, 'cost');
         if (!is_object($cost)) {
             $cost = new ewattchCmd();
             $cost->setLogicalId('cost');
             $cost->setIsVisible(1);
             $cost->setName(__('Coût', __FILE__));
         }
         $cost->setUnite('€');
         $cost->setType('info');
         $cost->setSubType('numeric');
         $cost->setEventOnly(1);
         $cost->setEqLogic_id($eqLogic->getId());
         $cost->save();
     }
     foreach ($result['resource']['water'] as $resource) {
         $eqLogic = self::byLogicalId('water_' . $resource['name'], 'ewattch');
         if (!is_object($eqLogic)) {
             $eqLogic = new self();
             $eqLogic->setName('water_' . $resource['name']);
             $eqLogic->setEqType_name('ewattch');
             $eqLogic->setIsVisible(1);
             $eqLogic->setIsEnable(1);
             $eqLogic->setLogicalId('water_' . $resource['name']);
             $eqLogic->setConfiguration('ip', $_ip);
             $eqLogic->setCategory('energy', 1);
             $eqLogic->save();
         }
         $index = $eqLogic->getCmd(null, 'index');
         if (!is_object($index)) {
             $index = new ewattchCmd();
             $index->setLogicalId('index');
             $index->setIsVisible(1);
             $index->setName(__('Index', __FILE__));
         }
         $index->setUnite('L');
         $index->setType('info');
         $index->setSubType('numeric');
         $index->setEventOnly(1);
         $index->setEqLogic_id($eqLogic->getId());
         $index->save();
         $cost = $eqLogic->getCmd(null, 'cost');
         if (!is_object($cost)) {
             $cost = new ewattchCmd();
             $cost->setLogicalId('cost');
             $cost->setIsVisible(1);
             $cost->setName(__('Coût', __FILE__));
         }
         $cost->setUnite('€');
         $cost->setType('info');
         $cost->setSubType('numeric');
         $cost->setEventOnly(1);
         $cost->setEqLogic_id($eqLogic->getId());
         $cost->save();
     }
     foreach ($result['resource']['heating'] as $resource) {
         $eqLogic = self::byLogicalId('heating_' . $resource['name'], 'ewattch');
         if (!is_object($eqLogic)) {
             $eqLogic = new self();
             $eqLogic->setName('heating_' . $resource['name']);
             $eqLogic->setEqType_name('ewattch');
             $eqLogic->setIsVisible(1);
             $eqLogic->setIsEnable(1);
             $eqLogic->setLogicalId('heating_' . $resource['name']);
             $eqLogic->setConfiguration('ip', $_ip);
             $eqLogic->setCategory('heating', 1);
             $eqLogic->save();
         }
         $index = $eqLogic->getCmd(null, 'index');
         if (!is_object($index)) {
             $index = new ewattchCmd();
             $index->setLogicalId('index');
             $index->setIsVisible(1);
             $index->setName(__('Index', __FILE__));
         }
         $index->setUnite('wh');
         $index->setType('info');
         $index->setSubType('numeric');
         $index->setEventOnly(1);
         $index->setEqLogic_id($eqLogic->getId());
         $index->save();
     }
     foreach ($result['resource']['environment'] as $resource) {
         $eqLogic = self::byLogicalId('environment_' . $resource['name'], 'ewattch');
         if (!is_object($eqLogic)) {
             $eqLogic = new self();
             $eqLogic->setName('environment_' . $resource['name']);
             $eqLogic->setEqType_name('ewattch');
             $eqLogic->setIsVisible(1);
             $eqLogic->setIsEnable(1);
             $eqLogic->setLogicalId('environment_' . $resource['name']);
             $eqLogic->setConfiguration('ip', $_ip);
             $eqLogic->save();
         }
         $value = $eqLogic->getCmd(null, 'value');
         if (!is_object($value)) {
             $value = new ewattchCmd();
             $value->setLogicalId('value');
             $value->setIsVisible(1);
             $value->setName(__('Valeur', __FILE__));
         }
         $value->setUnite($resource['units']);
         $value->setType('info');
         $value->setSubType('numeric');
         $value->setEventOnly(1);
         $value->setEqLogic_id($eqLogic->getId());
         $value->save();
     }
 }
Ejemplo n.º 14
0
 public function execute($_options = null)
 {
     $request = str_replace('#API#', config::byKey('api'), $this->getConfiguration('request'));
     if ($_options != null) {
         switch ($this->getType()) {
             case 'action':
                 switch ($this->getSubType()) {
                     case 'slider':
                         $request = str_replace('#slider#', $_options['slider'], $request);
                         break;
                     case 'color':
                         $request = str_replace('#color#', $_options['color'], $request);
                         break;
                     case 'message':
                         $replace = array('#title#', '#message#');
                         $replaceBy = array($_options['title'], $_options['message']);
                         if ($_options['message'] == '' || $_options['title'] == '') {
                             throw new Exception('[Script] Le message et le sujet ne peuvent être vide');
                         }
                         $request = str_replace($replace, $replaceBy, $request);
                         break;
                 }
                 break;
         }
     }
     switch ($this->getConfiguration('requestType')) {
         case 'http':
             $request_http = new com_http($request);
             log::add('script', 'info', 'Execution http de "' . $request . '"');
             return $request_http->exec();
             break;
         case 'script':
             $pathinfo = pathinfo($request);
             switch ($pathinfo['extension']) {
                 case 'php':
                     $request_shell = new com_shell('php ' . $request);
                     break;
                 case 'rb':
                     $request_shell = new com_shell('ruby ' . $request);
                     break;
                 case 'py':
                     $request_shell = new com_shell('python ' . $request);
                     break;
                 case 'pl':
                     $request_shell = new com_shell('perl ' . $request);
                     break;
                 default:
                     $request_shell = new com_shell($request);
                     break;
             }
             log::add('script', 'info', 'Execution shell de "' . $request . '"');
             return $request_shell->exec();
             break;
     }
     return false;
 }
Ejemplo n.º 15
0
 public function pushUrl($_value)
 {
     $url = $this->getConfiguration('jeedomPushUrl');
     if ($url == '') {
         $url = config::byKey('cmdPushUrl');
     }
     if ($url == '') {
         return;
     }
     $replace = array('#value#' => $_value, '#cmd_name#' => $this->getName(), '#cmd_id#' => $this->getId(), '#humanname#' => $this->getHumanName());
     $url = str_replace(array_keys($replace), $replace, $url);
     log::add('event', 'event', __('Appels de l\'URL de push pour la commande ', __FILE__) . $this->getHumanName() . ' : ' . $url);
     $http = new com_http($url);
     $http->setLogError(false);
     try {
         $http->exec();
     } catch (Exception $e) {
         log::add('cmd', 'error', __('Erreur push sur : ', __FILE__) . $url . ' => ' . $e->getMessage());
     }
 }
Ejemplo n.º 16
0
    }
}
$urlMasterLocal = false;
try {
    $request_http = new com_http(network::getNetworkAccess('internal', 'proto:127.0.0.1:port:comp') . '/plugins/openzwave/core/php/jeeZwave.php?apikey=' . config::byKey('api') . '&test=1');
    $request_http->setNoSslCheck(false);
    if ($request_http->exec(1, 1) == 'OK') {
        $urlMasterLocal = true;
    }
} catch (Exception $e) {
}
$urlMasterDistant = false;
try {
    $request_http = new com_http(network::getNetworkAccess('internal', 'proto:ip:port:comp') . '/plugins/openzwave/core/php/jeeZwave.php?apikey=' . config::byKey('api') . '&test=1');
    $request_http->setNoSslCheck(false);
    if ($request_http->exec(1, 1) == 'OK') {
        $urlMasterDistant = true;
    }
} catch (Exception $e) {
}
?>
<form class="form-horizontal">
	<fieldset>
		<?php 
echo '<div class="form-group">';
echo '<label class="col-sm-4 control-label">{{Retour local}}</label>';
if (!$urlMasterLocal) {
    echo '<div class="col-sm-1"><span class="label label-danger tooltips" style="font-size : 1em;" title="{{Vérifiez votre configuration sur la page de configuration réseaux, celle-ci est incorrecte et le démon ne pourra communiquer avec Jeedom}}">NOK</span></div>';
} else {
    echo '<div class="col-sm-1"><span class="label label-success" style="font-size : 1em;">OK</span></div>';
}
Ejemplo n.º 17
0
 public function updateInfo()
 {
     switch ($this->getConfiguration('datasource')) {
         case 'ecowatt':
             $url = '';
             switch ($this->getConfiguration('region-ew')) {
                 case 'bretagne':
                     $url = 'http://www.ecowatt-bretagne.fr/restez-au-courant/alertes-2/';
                     break;
                 case 'paca':
                     $url = 'http://www.ecowatt-paca.fr/restez-au-courant/alertes-2/';
                     break;
             }
             if ($url == '') {
                 return;
             }
             $request_http = new com_http($url);
             $html = $request_http->exec();
             phpQuery::newDocumentHTML($html);
             $result = pq('div.alertes.small')->html();
             $result = substr($result, strpos($result, 'alt='));
             $result = substr($result, strpos($result, ' '), +15);
             $result = substr($result, 0, strpos($result, '"'));
             $result = strtolower($result);
             $result = explode(' ', trim($result));
             $this->checkAndUpdateCmd('today', $result[0]);
             $this->checkAndUpdateCmd('tomorrow', $result[1]);
             break;
         case 'ejp':
             $ejpdays = self::valueFromUrl('https://particulier.edf.fr/bin/edf_rc/servlets/ejptemponew?Date_a_remonter=' . date('Y-m-d') . '&TypeAlerte=EJP');
             $region = 'Ejp' . ucfirst(strtolower(str_replace(array('_', 'EJP'), '', $this->getConfiguration('region-ejp'))));
             $value = 'Non déterminé';
             if (isset($ejpdays['JourJ'][$region])) {
                 if ($ejpdays['JourJ'][$region] == 'NON_EJP') {
                     $value = 'Pas d\'EJP';
                 } elseif ($ejpdays['JourJ'][$region] == 'EST_EJP') {
                     $value = 'EJP';
                 }
             }
             $today = $this->getCmd(null, 'today');
             if (is_object($today) && $today->execCmd(null, 2) != $today->formatValue($value)) {
                 $today->event($value);
             }
             $value = 'Non déterminé';
             if (isset($ejpdays['JourJ1'][$region])) {
                 if ($ejpdays['JourJ1'][$region] == 'NON_EJP') {
                     $value = 'Pas d\'EJP';
                 } elseif ($ejpdays['JourJ1'][$region] == 'EST_EJP') {
                     $value = 'EJP';
                 }
             }
             $this->checkAndUpdateCmd('tomorrow', $value);
             $ejptotaldays = self::valueFromUrl('https://particulier.edf.fr/services/rest/referentiel/historicEJPStore?searchType=ejp');
             $region = str_replace(array('_', 'EJP'), '', $this->getConfiguration('region-ejp'));
             $this->fillValue('totalDays', $region . '::Total', $ejptotaldays, -1);
             $totalDays = $this->getCmd(null, 'totalDays');
             $remainingDays = $this->getCmd(null, 'remainingDays')->event(22 - $totalDays->execCmd(null, 2));
             break;
         case 'tempo':
             $tempodays = self::valueFromUrl('https://particulier.edf.fr/bin/edf_rc/servlets/ejptemponew?Date_a_remonter=' . date('Y-m-d') . '&TypeAlerte=TEMPO');
             $this->fillValue('today', 'JourJ::Tempo', $tempodays);
             $this->fillValue('tomorrow', 'JourJ1::Tempo', $tempodays);
             $tempodays = self::valueFromUrl('https://particulier.edf.fr/bin/edf_rc/servlets/ejptempodaysnew?TypeAlerte=TEMPO');
             $this->fillValue('white-remainingDays', 'PARAM_NB_J_BLANC', $tempodays);
             $this->fillValue('blue-remainingDays', 'PARAM_NB_J_BLEU', $tempodays);
             $this->fillValue('red-remainingDays', 'PARAM_NB_J_ROUGE', $tempodays);
             $tempodays = self::valueFromUrl('https://particulier.edf.fr/services/rest/referentiel/getConfigProperty?PARAM_CONFIG_PROPERTY=param.nb.bleu.periode');
             $this->fillValue('blue-totalDays', 'param.nb.bleu.periode', $tempodays);
             $tempodays = self::valueFromUrl('https://particulier.edf.fr/services/rest/referentiel/getConfigProperty?PARAM_CONFIG_PROPERTY=param.nb.blanc.periode');
             $this->fillValue('white-totalDays', 'param.nb.blanc.periode', $tempodays);
             $tempodays = self::valueFromUrl('https://particulier.edf.fr/services/rest/referentiel/getConfigProperty?PARAM_CONFIG_PROPERTY=param.nb.rouge.periode');
             $this->fillValue('red-totalDays', 'param.nb.rouge.periode', $tempodays);
             break;
         case 'eco2mix':
             # code...
             break;
     }
     $this->refreshWidget();
 }
Ejemplo n.º 18
0
 public function execute($_options = array())
 {
     $eqLogic_sarah = sarah::byId($this->eqLogic_id);
     $http = new com_http($eqLogic_sarah->getConfiguration('addrSrvTts') . '/?tts=' . urlencode($_options['message']));
     return $http->exec();
 }
Ejemplo n.º 19
0
 public function getWeatherFromYahooXml()
 {
     if ($this->getConfiguration('city') == '') {
         return false;
     }
     if ($this->_weatherData != '' && is_array($this->_weatherData)) {
         return $this->_weatherData;
     }
     $this->setCollectDate(date('Y-m-d H:i:s'));
     try {
         $request = new com_http('http://weather.yahooapis.com/forecastrss?w=' . urlencode($this->getConfiguration('city')) . '&u=c');
         $xml = $request->exec(30000, 2);
         $result = self::parseXmlWeather($xml);
     } catch (Exception $e) {
         log::add('weather', 'info', 'Error on data fetch : ' . $e->getMessage());
         return '';
     }
     $this->_weatherData = $result;
     return $result;
 }