https://github.com/gboudreau/nissan-connect-php
Use the Nissan Connect (was Carwings) API using a simple PHP class.
https://github.com/gboudreau/nissan-connect-php
api carwings leaf nissan php
Last synced: 8 months ago
JSON representation
Use the Nissan Connect (was Carwings) API using a simple PHP class.
- Host: GitHub
- URL: https://github.com/gboudreau/nissan-connect-php
- Owner: gboudreau
- License: gpl-3.0
- Created: 2016-02-21T18:59:43.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-05-18T14:08:52.000Z (about 2 years ago)
- Last Synced: 2025-06-02T16:20:18.524Z (about 1 year ago)
- Topics: api, carwings, leaf, nissan, php
- Language: PHP
- Size: 115 KB
- Stars: 40
- Watchers: 10
- Forks: 18
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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
```php
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('you@something.com', '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_dump`ed result of call to `getStatus`):
```php
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](https://github.com/joshperry) for his [Carwings protocol reference](https://github.com/joshperry/carwings) which I used as a reference to refactor my [One-click access to LEAF](https://github.com/gboudreau/LEAF_Carwings_EasyAccess) by creating this class.
Developed mainly using a free open-source license of

kindly provided by [JetBrains](http://www.jetbrains.com/). Thanks guys!