public static function pull($_options) { $weather = weather::byId($_options['weather_id']); if (is_object($weather) && $weather->getIsEnable() == 1) { if (jeedom::isDateOk()) { $sunrise = $weather->getCmd(null, 'sunrise')->execCmd(); $sunset = $weather->getCmd(null, 'sunset')->execCmd(); if ($sunrise < 500 || $sunrise > 1000) { $sunrise = 500; } if ($sunset > 2300 || $sunset < 1600) { $sunset = 1600; } if (date('Gi') + 100 >= $sunrise && date('Gi') + 100 < $sunset) { $weather->getCmd(null, 'sunrise')->event($sunrise); } else { $weather->getCmd(null, 'sunset')->event($sunset); } } $weather->reschedule(); } else { $cron = cron::byClassAndFunction('weather', 'pull', $_options); if (is_object($cron)) { $cron->remove(); } } }
public function execute($_options = array()) { $eqLogic_weather = weather::byId($this->eqLogic_id); $weather = $eqLogic_weather->getWeatherArea(); if (!is_array($weather)) { return false; } if ($this->getConfiguration('day') == -1) { if ($this->getConfiguration('data') == 'condition') { return $weather['condition']['text']; } if ($this->getConfiguration('data') == 'temp') { return $weather['condition']['temperature']; } if ($this->getConfiguration('data') == 'humidity') { return $weather['atmosphere']['humidity']; } if ($this->getConfiguration('data') == 'pressure') { return $weather['atmosphere']['pressure']; } if ($this->getConfiguration('data') == 'wind_speed') { return $weather['wind']['speed']; } if ($this->getConfiguration('data') == 'wind_direction') { return $weather['wind']['direction']; } if ($this->getConfiguration('data') == 'sunrise') { return $weather['astronomy']['sunrise']; } if ($this->getConfiguration('data') == 'sunset') { return $weather['astronomy']['sunset']; } } if ($this->getConfiguration('data') == 'condition') { return $weather['forecast'][$this->getConfiguration('day')]['condition']; } if ($this->getConfiguration('data') == 'low') { return $weather['forecast'][$this->getConfiguration('day')]['low_temperature']; } if ($this->getConfiguration('data') == 'high') { return $weather['forecast'][$this->getConfiguration('day')]['high_temperature']; } return false; }
* Jeedom is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Jeedom. If not, see <http://www.gnu.org/licenses/>. */ try { require_once dirname(__FILE__) . '/../../../../core/php/core.inc.php'; include_file('core', 'authentification', 'php'); if (!isConnect('admin')) { throw new Exception(__('401 - Accès non autorisé', __FILE__)); } if (init('action') == 'getWeather') { $weather = weather::byId(init('id')); if (!is_object($weather)) { throw new Exception(__('Weather inconnu verifié l\'id', __FILE__)); } $return = utils::o2a($weather); $return['cmd'] = array(); foreach ($weather->getCmd() as $cmd) { $cmd_info = utils::o2a($cmd); $cmd_info['value'] = $cmd->execCmd(null, 0); $return['cmd'][] = $cmd_info; } ajax::success($return); } throw new Exception(__('Aucune methode correspondante à : ', __FILE__) . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) {