AC: Air conditioner control

更新时间:
2024-05-15
下载文档

AC: Air conditioner control

This module is the vehicle air conditioning control module. This module is provided in EdgerOS 2.0.0 and later, and apps need to have vehicle.cockpit permission to use this module.

User can use the following code to import the AC module.

var AC = require('vehicle/ac');

Support

The following shows AC module APIs available for each permissions.

 User ModePrivilege Mode
AC
ac.request
ac.release
ac.info
ac.temperature
ac.blower
ac.control

AC Class

new AC()

  • Returns: {Object} AC object.

Create a AC object.

AC Object

ac.request(callback)

  • callback {Function} Callback.
    • error {Error} Specify the error message when the request is failed.

Request for vehicle air conditioning operation. After the request is successful, the vehicle air conditioner information can be obtained and the air conditioner can be controlled.

ac.release()

Release the current AC object, no operation is allowed after the object is released.

The object needs to be released as soon as possible when it is no longer used.

ac.info(callback)

  • callback {Function} Callback.
    • error {Error} Specify the error message when failed.
    • info {Object} Air conditioner information.

Get air conditioning information. The info object contains the following members:

MemberTypeDescription
airCondStInteger0: OFF 1: ON
insideTempNumberTemperature inside the car
outsideTempNumberTemperature outside the car
lhTempStringLeft front temperature
rhTempStringRight front temperature
blowerModStIntegerBlower mode.
blowerSpdIntegerBlower speed. (0 - 10) 0: Stop
cycleThrInteger0: Internal circulation 100: External circulation (0-100)

The temperature string (lhTemp and rhTemp) information contains the following possible:

'LOW', '16.5', '17', '17.5', '18', '18.5', '19', '19.5', '20', '20.5', '21', '21.5', '22', '22.5', '23', '23.5', '24', '24.5', '25', '25.5', '26', '26.5', '27', '27.5', '28', '28.5', '29', '29.5', '30', '30.5', '31', '31.5', 'HIGH'

Blower mode: blowerModSt has the following types:

ValueDescription
1Face
2Foot
3Window
4Face & Foot
5Face & Window
6Foot & Window
7Face & Foot & Window

The info object may also contains the following members:

Optional MemberTypeDescription
leftChnlExptTempIntegerLeft channel outlet expected temperature
rightChnlExptTempIntegerRight channel outlet expected temperature
leftBlowerFaceAirOutTempIntegerAir outlet temperature on the left blowing face
rightBlowerFaceAirOutTempIntegerAir outlet temperature on the right blowing face
leftBlowerFootAirOutTempIntegerAir outlet temperature on the left blowing foot
rightBlowerFootAirOutTempIntegerAir outlet temperature on the right blowing foot

Example

var AC = require('vehicle/ac');

var ac = new AC();

ac.request(error => {
  if (error == undefined) {
    ac.info((error, info) => {
      if (info) {
        console.log(info);
      }
    });
  }
});

ac.temperature(temp, callback)

  • temp {Object} Temperature object.
  • callback {Function} Callback.
    • error {Error} Specify the error message when an error occurs.

Set the interior temperature. temperature object can contain the following members:

  • lhTemp {String} Left front temperature.
  • rhTemp {String} Right front temperature.

Example

ac.temperature({
  lhTemp: '24.5', rhTemp: 'LOW'
}, error => {
  if (error) {
    console.error(error);
  }
});

ac.blower(param, callback)

  • param {Object} Blower parameter object.
  • callback {Function} Callback.
    • error {Error} Specify the error message when an error occurs.

Set blower parameters:

  • blowerModSt {Integer} Blower mode.
  • blowerSpd {Integer} Blower speed. (0 - 10)

Example

ac.blower({
  blowerModSt: 4, blowerSpd: 2
}, error => {
  if (error) {
    console.error(error);
  }
});

ac.control(param, callback)

  • param {Object} Control parameter object.
  • callback {Function} Callback.
    • error {Error} Specify the error message when an error occurs.

Control air conditioner:

  • airCondSt {Integer} 0: OFF 1: ON.
  • auto {Boolean} Whether to automatically turn on and off the air conditioner according to the temperature.
  • cycleThr {Integer} 0: Internal circulation 100: External circulation.

Example

ac.control({
  airCondSt: 0, auto: true, cycleThr: 80
}, error => {
  if (error) {
    console.error(error);
  }
});

AC Object Events

The ac object inherits from the EventEmitter class. The following events are thrown in some specific situations.

info

When the state of the air conditioner changes, this event will be generated.

Example

ac.on('info', info => {
  console.log(info);
});
文档内容是否对您有所帮助?
有帮助
没帮助