How to use the teslajs.chargeStateAsync function in teslajs

To help you get started, we’ve selected a few teslajs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mseminatore / alexa-tesla / index.js View on Github external
.then( function(vehicles) {
        // get options object - which must include authToken and vehicleID
        var options = getOptionsFromCarName(session, carName);
        
        tjs.chargeStateAsync(options)
        .done( function(chargeState) {
            
            var str = "";
            if (options.display_name) {
                str = options.display_name;
            } else {
                str = "The car";
            }

            if (chargeState.charging_state != "Disconnected") {
                str += " is plugged in.";
            } else {
                str += " is not plugged in.";
            }
            res.say(str).send();
        });