QNX CAR Platform for Infotainment 2.1 -- JavaScript API (Cordova)

car.hvac

Controls the HVAC system
Source:

Members

<static> HvacError

Error enumeration
Properties:
Name Type Description
UNKNOWN_ERROR An unknown error has occurred.
Source:

<static> 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.
Source:

<static> 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 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).
Source:

Methods

<static> cancelWatch(watchId)

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

<static> get(successCallback, errorCallback, settings, zones)

Return HVAC settings for the specified filter

If successful, get() calls the successCallback 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 callback that is called with the result.
errorCallback Function <optional>
The callback that is called 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.
Source:
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
		}
}

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

//optional: define a filter. See car.hvac#HvacFilter for details

//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: 'frontLeft', value: 0 }
		]
}

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

<static> set(setting, zone, value, successCallback, errorCallback)

Save an HVAC setting
Parameters:
Name Type Argument Description
setting String An HvacSetting value.
zone String A car.zone value.
value Mixed The value to save.
successCallback Function <optional>
The callback that is called with the result.
errorCallback Function <optional>
The callback that is called if there is an error.
Source:
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"
}

<static> watchHvac(callback) → {Number}

Watch for hvac changes
Parameters:
Name Type Description
callback Function The function to be called when a change is detected.
Source:
Returns:
An ID for the added watch.
Type
Number
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
		}
}

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