Interact with your Tesla Model S, X or 3 using PowerShell over the Tesla customer API
Andy Lyonette
PowerShell 3.0
- Create folder C:\Users\[username]\Documents\WindowsPowerShell\Modules\Tesla
- Copy Tesla\Tesla.ps1 and Tesla\Tesla.psm1 into that directory.
- Unblock Tesla.ps1 and Tesla.psm1 by right clicking each file and going to properties or using the cmdlet 'Unlock-File'
In order to retrieve data and send commands to a Tesla vehicle each time you open a new PowerShell session you first need to get a token from the Tesla customer API OATH service and get the ID used by the API to identify the vehicle you wish to affect. This can be achieved with the following commands:
$token = Get-TeslaToken -Credential (Get-Credential)
$vehicle = Get-TeslaVehicle -Token $token | Where-Object {$_.vin -like "*123456"}
If you only have one active Tesla vehicle in your MyTesla account you just can use:
$token = Get-TeslaToken -Credential (Get-Credential)
$vehicle = Get-TeslaVehicle -Token $token
All vehicle cmdlets require that the -vehicle and -token parameters are specified, use the $vehicle and $token variables created above. E.g. Invoke-TeslaVehicleLightsFlash -Vehicle $vehicle -Token $token
. Pipeline support is implemented in each of the cmdlets so you can also pass the parameters as a hashtable:
@{vehicle=$vehicle;token=$token} | Invoke-TeslaVehicleLightsFlash
The following cmdlets are available in the module complete with full comment-based help. In order to find out more about any cmdlet use the Get-Help cmdlet.
Eg. Get-Help Set-TeslaVehicleClimateControlTemperature -Detailed
or Get-Help Set-TeslaVehicleClimateControlTemperature -Examples
- Close-TeslaVehicleChargePortDoor
- Close-TeslaVehicleSunroof
- ConvertFrom-TeslaTimeStamp
- Disable-TeslaVehicleValetMode
- Enable-TeslaVehicleRemoteStart
- Enable-TeslaVehicleValetMode
- Get-TeslaDestinationCharger
- Get-TeslaServiceCenter
- Get-TeslaSite
- Get-TeslaStore
- Get-TeslaSuperCharger
- Get-TeslaVehicleChargeState
- Get-TeslaVehicleClimateState
- Get-TeslaVehicleConfig
- Get-TeslaVehicleDetail [ALIAS: Get-TeslaVehicleSummary]
- Get-TeslaVehicleDriveState
- Get-TeslaVehicleGuiSettings
- Get-TeslaVehicleImage
- Get-TeslaVehicleLocation
- Get-TeslaVehicleState
- Invoke-TeslaVehicleCommand
- Invoke-TeslaVehicleHorn
- Invoke-TeslaVehicleLightsFlash
- Invoke-TeslaVehicleWakeUp
- Lock-TeslaVehicle
- Open-TeslaVehicleChargePortDoor
- Open-TeslaVehicleSunroofVent
- Remove-TeslaVehicleValetModePin
- Set-TeslaVehicleChargeLimit
- Set-TeslaVehicleClimateControlTemperature
- Start-TeslaVehicleCharging
- Start-TeslaVehicleClimateControl
- Stop-TeslaVehicleCharging
- Stop-TeslaVehicleClimateControl
- Unlock-TeslaVehicle
- Get-TeslaToken
- Get-TeslaVehicle [ALIAS: Get-TeslaVehicles]
- ConvertFrom-TeslaTimeStamp
- Only vehicle commands implemented
- Testing only performed against an EU-spec Model S P100D (HW2) built October 2016 running firmware 2017.36.x
- Logic for Celsius/Fahrenheit conversion is implemented setting inside temperature but not tested on a non-EU vehicle
- Cmdlets exist only for known vehicle commands, however
Invoke-TeslaVehicleCommand
can be used to execute additional API commands as they are discovered
- Test with other vehicles, including Model 3
- Add PowerWall support
-
ADDED
- Get-TeslaDestinationCharger
- Get-TeslaServiceCenter
- Get-TeslaSite
- Get-TeslaStore
- Get-TeslaSuperCharger
- Get-TeslaVehicleConfig
- Get-TeslaVehicleDriveState
- Get-TeslaVehicleGuiSettings
- Get-TeslaVehicleImage
- Get-TeslaVehicleState
-
RENAMED
- Get-TeslaVehicles to Get-TeslaVehicle
- Get-TeslaVehicleSummary to Get-TeslaVehicleDetail
- Fixed a bug stopping the Enable-TeslaVehicleValetMode with the -pin parameter from starting
- Updated spelling mistake in content-based help as per issue #1
- Initial release
Inspiration drawn from:
- http://docs.timdorr.apiary.io/#reference/vehicle-commands/set-temperature/set-temperature
- https://github.com/JonnMsft/TeslaPSModule
Suggestions, improvements and fixes are all welcome!