All Projects → gboudreau → nissan-connect-php

gboudreau / nissan-connect-php

Licence: GPL-3.0 License
Use the Nissan Connect (was Carwings) API using a simple PHP class.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to nissan-connect-php

carwings
Go package and CLI tool for the Nissan Leaf Carwings API
Stars: ✭ 23 (-20.69%)
Mutual labels:  leaf, nissan, carwings
leafMVC
MVC "Framework" created from Leaf PHP Framework
Stars: ✭ 25 (-13.79%)
Mutual labels:  leaf
Nissboard
🚗 Nissan Consult/OBDII Realtime Dashboard
Stars: ✭ 20 (-31.03%)
Mutual labels:  nissan
Butterfly
分布式ID生成器框架:超高性能的发号器框架。通过引入多种新的方案,彻底解决雪花算法的时间回拨等问题,并将雪花算法原生QPS提高最少十几~二十倍
Stars: ✭ 111 (+282.76%)
Mutual labels:  leaf
typecho-theme-leaf
一款简洁又大气的typecho主题。演示站点
Stars: ✭ 62 (+113.79%)
Mutual labels:  leaf
PHP-Frameworks-Bench
Popular PHP Frameworks Benchmark.
Stars: ✭ 28 (-3.45%)
Mutual labels:  leaf
Vapecord-ACNL-Plugin
Animal Crossing NL Vapecord Public Plugin WIP
Stars: ✭ 72 (+148.28%)
Mutual labels:  leaf
xcode-leaf-color-schemer
https://ashokgelal.com/2017/01/19/leaf_color_schemer_xcode/?ref=github
Stars: ✭ 26 (-10.34%)
Mutual labels:  leaf
Leaf
Distributed ID Generate Service
Stars: ✭ 5,080 (+17417.24%)
Mutual labels:  leaf
Leaf
A game server framework in Go (golang)
Stars: ✭ 4,250 (+14555.17%)
Mutual labels:  leaf
geoip
🌚 🌍 🌝 GeoIP 规则文件加强版,同时支持定制 V2Ray dat 格式路由规则文件 geoip.dat 和 MaxMind mmdb 格式文件 Country.mmdb。Enhanced edition of GeoIP files for V2Ray, Xray-core, Trojan-Go, Clash and Leaf, with replaced CN IPv4 CIDR available from ipip.net, appended CIDR lists and more.
Stars: ✭ 524 (+1706.9%)
Mutual labels:  leaf

Nissan Connect PHP Class

Use the Nissan Connect (was Carwings) API using a simple PHP class.

Installation

You can just download NissanConnect.class.php and require/include it, or use composer:

require "gboudreau/nissan-connect-php": "dev-master"

If you are in North America, you probably need to use the new-api branch, instead of master:

require "gboudreau/nissan-connect-php": "dev-new-api"

Usage

require_once 'NissanConnect.class.php';

// All parameters except the first two (username & password) are optional; the default values are shown here
// If you can't use the openssl_encrypt() function (very unlikely), you can use a web-service to encrypt your password. Simply change the last parameter to NissanConnect::ENCRYPTION_OPTION_WEBSERVICE
$nissanConnect = new NissanConnect('[email protected]', 'your_password_here', 'America/New_York', NissanConnect::COUNTRY_US, NissanConnect::ENCRYPTION_OPTION_OPENSSL);

// Change to TRUE to log debugging information into your PHP error log
$nissanConnect->debug = FALSE;

// How long (in seconds) should we wait for the result before giving up. Only used when $waitForResult = TRUE
$nissanConnect->maxWaitTime = 290;

try {
    $result = $nissanConnect->getStatus();
    var_dump($result);
    
    // Start charging
    $nissanConnect->startCharge();
    
    // Should we wait until the command result is known, before returning? Enabling this will wait until the car executed the command, and returned the response, which can sometimes take a few minutes.
    $waitForResult = FALSE; 
    
    // Start Climate Control
    $nissanConnect->startClimateControl($waitForResult);
    
    // Stop Climate Control
    $nissanConnect->stopClimateControl($waitForResult);
} catch (Exception $ex) {
    echo "An error occurred: " . $ex->getMessage();
}

Example output (var_dumped result of call to getStatus):

object(stdClass)#9 (18) {
  ["LastUpdated"]=>
  string(16) "2016-02-21 15:24"
  ["PluggedIn"]=>
  bool(true)
  ["Charging"]=>
  bool(false)
  ["ChargingMode"]=>
  string(12) "NOT_CHARGING"
  ["BatteryCapacity"]=>
  int(12)
  ["BatteryRemainingAmount"]=>
  int(9)
  ["BatteryRemainingAmountWH"]=>
  NULL
  ["BatteryRemainingAmountkWH"]=>
  NULL
  ["TimeRequiredToFull"]=>
  NULL
  ["TimeRequiredToFull200"]=>
  NULL
  ["TimeRequiredToFull200_6kW"]=>
  NULL
  ["CruisingRangeAcOn"]=>
  float(90.4)
  ["CruisingRangeAcOff"]=>
  float(115.712)
  ["CruisingRangeUnit"]=>
  string(2) "km"
  ["RemoteACRunning"]=>
  bool(false)
  ["RemoteACLastChanged"]=>
  string(16) "2016-02-21 15:24"
  ["ACStartStopURL"]=>
  NULL
  ["ACDurationBatterySec"]=>
  int(900)
  ["ACDurationPluggedSec"]=>
  int(7200)
}

Acknowledgements

Thanks to Joshua Perry for his Carwings protocol reference which I used as a reference to refactor my One-click access to LEAF by creating this class.

Developed mainly using a free open-source license of
PHPStorm
kindly provided by JetBrains. Thanks guys!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].