OK Google, preheat my Nissan Leaf

If you have a Google Home device and a Nissan Leaf electric car, you probably think it would be nice if you could say something like:

Hey Google, heat up the car!

Or maybe in the summer…

OK Google, cool the car!

And it would activate the climate control, to heat or cool the car, without having to deal with any sluggish apps on your phone.

I have managed to achieve this using an AWS Lambda function and IFTTT (if this then that). The basic way it works is:

  • You say a predefined phrase to the Google Assistant.
  • This triggers an action in IFTTT which makes a request to a URL.
  • This URL triggers the Lambda function which calls the Nissan API.

To give credit where it’s due, I got the idea from this post by Mark Timms on the SpeakEV forums.

If you want to use this for your Nissan Leaf, you are welcome to use my Lambda function, by following the instructions below. You can also run the Lambda function in your own AWS account, if you are familiar with AWS Lambda.

How to use my Lambda function with your Leaf

First, sign up for IFTTT if you don’t already have an account.

Then go to https://ifttt.com/create to create a new applet:

IFTTT new applet step 1Click on “this” to select your trigger. On the next page select “Google Assistant”:

ifttt2Then select “Say a simple phrase”. Enter your desired phrase and canned response:

ifttt3The phrase and response can be anything you like. Click on “Create trigger”. Next click on “that” to create your action:

ifttt_that

On the next page, select “Webhooks”:

ifttt_webhooksThen select “Make a web request”. On the next page, enter the web request details to call the Lambda function:
ifttt5

The URL to call the function is:

https://6y4516lpkf.execute-api.eu-west-1.amazonaws.com/myLeaf

Select POST as the method and “application/json” as the content type. This allows you to pass in your Nissan account details via a JSON body:

{
    "username": "USERNAME",
    "password": "PASSWORD",
    "region": "NE",
    "command": "startclimate"
}

And finally, review and finish:

ifttt_finishNow, when you say your chosen phrase to Google Assistant, a request will be made which will turn on the climate control in your car.

You can follow the same process to create another applet to cool the car, for the summer. Only the phrase and response need to differ, the call to the Lambda function is exactly the same.

Please note:

  • Google Assistant will respond with your canned response regardless of whether the call to the car succeeds or fails.
  • As you can see you will be passing your Nissan account details to my Lambda function. I do not store or log these details in any way or use them for any other purpose. If you are not comfortable with this then see below to see how to host the function in your own AWS account.

Thankyou!

If you find this useful and you are not yet powering your Nissan Leaf with green energy, please consider using my referral link to switch to Octopus:

https://share.octopus.energy/brave-bear-676

You will get £50 credit to your account and so will I. Thanks!

Running the function in your own AWS account

The function is written in Python 3.6, and uses the pycarwings2 library from https://github.com/filcole/pycarwings2

The lambda zip bundle can be downloaded from here:

https://leaf-lambda.s3-eu-west-1.amazonaws.com/lambda_package.zip

And the code can be seen here:

https://gist.github.com/jwilf/ef8fb04dbfd5446415f8222ccce02826

If you want to repackage, this post may help you.

 

Leave a Reply

Your email address will not be published. Required fields are marked *