How to use the teslajs.climateStateAsync 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) {
        var options = req.getSession().get("options");
        
        tjs.climateStateAsync(options)
        .done(function(climate_state) {
            var state = climate_state.is_auto_conditioning_on ? "on" : "off";
            var str = "The climate system is currently " + state + ". ";
            
            if (climate_state.driver_temp_setting != climate_state.passenger_temp_setting ) {
                str += "The driver temperature is set to " + Math.round(c2f(climate_state.driver_temp_setting)) + " degrees ";
                str += "and the passenger temperature is set to " + Math.round(c2f(climate_state.passenger_temp_setting)) + " degrees.";
            } else {
                str += "The temperature is set to " + Math.round(c2f(climate_state.driver_temp_setting)) + " degrees.";
            }
            res.say(str).send();
        });
    });