Plugin car.hvac

car.hvac

Controls the HVAC system

Members

HvacFanDirection

Fan direction enumeration
Properties:
Name Type Description
DEFROST The fan is set to defrost the front window.
DEFROST_AND_FEET The fan is directed to the front window and the feet.
FACE The fan is directed to the face.
FACE_AND_FEET The fan is directed to the face and feet.
FEET The fan is directed to the feet.

HvacSetting

HVAC settings enumeration
Properties:
Name Type Description
FAN_SPEED Number The fan speed (0 to 6; 0 for off).
FAN_DIRECTION String The fan direction. Use the values from car.hvac.HvacFanDirection.
AIR_CONDITIONING Boolean The air conditioning (true for on).
AIR_RECIRCULATION Boolean The air recirculation (true for on).
ZONE_LINK Boolean Zone Link. When on, both left and right zones are controlled by the left settings (true for on).
TEMPERATURE Number The temperature (15 to 26 degrees Celsius).
HEATED_SEAT Number Seat heating level (0 to 3; 0 for off).
DEFROST Boolean Window defrost (true for on).

Methods

cancelWatch

Stop watching HVAC items
Parameters:
Name Type Description
watchId String The watch ID returned by car.hvac.watchHvac().
Example
car.hvac.cancelWatch(watchId);

get

Return HVAC settings for the specified filter

If successful, car.hvac.get() calls the successCallback function with an array of setting objects containing the setting (car.hvac.HvacSetting), the zone (car.Zone), and the value (number/string/boolean).

Parameters:
Name Type Argument Description
successCallback Function The function to call with the result.
errorCallback Function <optional>
The function to call if there is an error.
settings Array <optional>
An array of car.hvac.HvacSetting values to whitelist.
zones Array <optional>
An array of car.Zone values to whitelist.
See:
  • car.hvac.HvacSetting
  • car.Zone
Examples
 

//define your callback function(s)
function successCallback(hvacItems) {
        //iterate through all the hvac items
        for (var i=0; i<hvacItems.length; i++) {
            console.log("hvac item setting = " + hvacItems[i].setting + '\n' +    //a car.hvac.HvacSetting value
                        "hvac item zone = " + hvacItems[i].zone + '\n' +        //a car.Zone value
                        "hvac item value = " + hvacItems[i].value + '\n\n');    //a mixed value type, depending on the setting
        }
}

function errorCallback(error) {
        console.log(error.code, error.msg);
}


//call the method
car.hvac.get(successCallback, errorCallback);
 REST - without any filters

Request:
http://<car-ip>/car/hvac/get

Success Response:
{
        code: 1,
        data: [
            { setting: 'temperature', zone: 'frontLeft', value: 20 },
            { setting: 'temperature', zone: 'frontRight', value: 22 },
            { setting: 'temperature', zone: 'rear', value: 22 },
            { setting: 'airConditioning', zone: 'everywhere', value: true },
            ...
        ]
}

Error Response:
{
        code: -1,
        msg: "An error has occurred"
}
 REST - with settings and zone filters

Request:
http://<car-ip>/car/hvac/get?settings=temperature,heatedSeats&zones=frontLeft,frontRight

Success Response:
{
        code: 1,
        data: [
            { setting: 'temperature', zone: 'frontLeft', value: 20 },
            { setting: 'temperature', zone: 'frontRight', value: 22 },
            { setting: 'heatedSeat', zone: 'frontLeft', value: 5 },
            { setting: 'heatedSeat', zone: 'frontRight', value: 0 }
        ]
}

Error Response:
{
        code: -1,
        msg: "An error has occurred"
}

set

Save an HVAC setting
Parameters:
Name Type Argument Description
setting String A car.hvac.HvacSetting value.
zone String A car.Zone value.
value Mixed The value to save.
successCallback Function <optional>
The function to call with the result.
errorCallback Function <optional>
The function to call if there is an error.
See:
  • car.hvac.HvacSetting
  • car.Zone
Examples
//set the temperature in the entire car to 50
car.hvac.set(car.hvac.HvacSetting.TEMPERATURE, car.Zone.EVERYWHERE, 50);
//NOTE: this is equivalent to doing: car.hvac.set('temperature', 'everywhere', 50);
 REST

Request:
http://<car-ip>/car/hvac/set?setting=temperature&zone=frontLeft&value=25

Success Response:
{
        code: 1,
}

Error Response:
{
        code: -1,
        msg: "An error has occurred"
}

watchHvac

Watch for HVAC changes
Parameters:
Name Type Description
callback Function The function to call when a change is detected.
Returns:
An ID for the added watch.
Type
  • String
Example
//define a callback function
function myCallback(hvacItems) {
        //iterate through the changed items
        for (var i=0; i<hvacItems.length; i++) {
            console.log("hvac item setting = " + hvacItems[i].setting + '\n' +    //a car.hvac.HvacSetting value
                        "hvac item zone = " + hvacItems[i].zone + '\n' +        //a car.Zone value
                        "hvac item value = " + hvacItems[i].value + '\n\n');    //a mixed value type, depending on the setting
        }
}

var watchId = car.hvac.watchHvac(myCallback);