mseminatore / TeslaJS

An Unofficial Tesla API library for NodeJS

Home Page:https://www.teslajs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Struggling to loop through all vehicles on account

joepalexander opened this issue · comments

For my university FYP, i decided to build an asset tracking system system, within this encompasses a system in which the milage of our business model 3 fleet is logged every evening. I am struggling to get the API to loop through and log to console all of the vehicles on the account without manually editing the 'program.index ||' section. Can anyone help guide me through this?

I am happy to try to help. I assume you are writing this project in NodeJS and that you know JavaScript.

The vehicles() call will return an array listing all of the vehicles on the account. Once you have that array of vehicles, and looking at the odometer.js sample you should be able to write code that can then iterate over each of the vehicle ID's values, setting options.vehicleID and making the call to vehicleState() for each car.

I am happy to try to help. I assume you are writing this project in NodeJS and that you know JavaScript.

The vehicles() call will return an array listing all of the vehicles on the account. Once you have that array of vehicles, and looking at the odometer.js sample you should be able to write code that can then iterate over each of the vehicle ID's values, setting options.vehicleID and making the call to vehicleState() for each car.

Thank you for this. I will give it a shot and if I get stuck i will come back to you!