public static function pull($_options) { //log::add('tesla', 'error', "Vehicle data updated through API"); //if $eqLogics = eqLogic::byType('tesla'); // ne pas oublier de modifier pour le nom de votre plugin // la liste des équipements try { $list = tesla::listAllVehicles(); } catch (Exception $e) { $message = displayExeption($e); //TODO: Not Used log::add('tesla', 'error', $e); } foreach ($eqLogics as $eqLogic) { log::add('tesla', 'error', "Pulling data for " . $eqLogic->getHumanName(false, false) . " VIN: " . $eqLogic->getConfiguration('vin')); foreach ($list->{'response'} as $car) { if ($car->{'vehicle_id'} == $eqLogic->getLogicalId()) { $eqLogic->setConfiguration('state', $car->{'state'}); } } try { log::add('tesla', 'error', "Getting Data "); $carData = tesla::getVehicleData($eqLogic->getConfiguration('id')); log::add('tesla', 'error', $carData); foreach ($eqLogic->getCmd('info') as $cmd) { $cmd->event($carData->{$cmd->getLogicalId()}); log::add('tesla', 'error', "Adding " . $cmd->getLogicalId() . " : " . $carData->{$cmd->getLogicalId()}); } } catch (Exception $e) { $message = displayExeption($e); //TODO: Not Used log::add('tesla', 'error', $e); } } }
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') == 'syncEqLogicWithTeslaSite') { tesla::syncEqLogicWithTeslaSite(); ajax::success(); } if (init('action') == 'createToken') { $result = tesla::createToken(init('email'), init('password')); //config::save('token',$result,'tesla'); ajax::success($result); } if (init('action') == 'checkAPI') { ajax::success(tesla::checkAPI()); } // action qui permet d'obtenir l'ensemble des eqLogic if (init('action') == 'getAll') { $eqLogics = eqLogic::byType('tesla'); // ne pas oublier de modifier pour le nom de votre plugin // la liste des équipements foreach ($eqLogics as $eqLogic) { $data['id'] = $eqLogic->getId(); $data['humanSidebar'] = $eqLogic->getHumanName(true, false); $data['humanContainer'] = $eqLogic->getHumanName(true, true); $return[] = $data; } ajax::success($return); } throw new Exception(__('Aucune methode correspondante à : ', __FILE__) . init('action'));
* 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/>. */ require_once dirname(__FILE__) . '/../../../core/php/core.inc.php'; include_file('core', 'authentification', 'php'); if (!isConnect()) { include_file('desktop', '404', 'php'); die; } $apiAccessOK = false; try { // Test access API $apiAccessOK = tesla::checkAPI(); } catch (Exception $e) { } ?> <form class="form-horizontal"> <fieldset> <legend><i class="fa fa-list-alt"></i> {{Etat}}</legend> <?php echo '<div class="form-group">'; echo '<label class="col-sm-6 control-label">{{API Tesla}}</label>'; if (!$apiAccessOK) { echo '<div class="col-sm-1"><span class="label label-danger tooltips" style="font-size : 1em;" title="{{Verifiez vos information d\'identification Tesla & generez un token}}">NOK</span></div>'; } else { echo '<div class="col-sm-1"><span class="label label-success" style="font-size : 1em;" title="{{' . $apiAccessOK . ' voiture' . ($apiAccessOK == 1 ? '' : 's') . '}}">OK</span></div>'; } echo '</div>';