top

SMARTHOME

This class provides methods to bring the information of appliances that can be connected to SmartHome, check status and be able to modify, etc.

Add the following line for SmartHome class into a html file your own :

  script type="text/javascript" src="$MANAGER_WIDGET/Common/webapi/1.0/webapis.js">/script>

You can declare SmartHome class like this :

  ex) var smarthome = webapis.smarthome;

Enum

ObjectNameValueDescription
SMART_HOME_CMDCMD_MODECMD_MODEThis indentifier indicates a command for accessing device’s mode.
CMD_WIND_DIRECTIONCMD_WIND_DIRECTIONThis indentifier indicates a command for accessing a value of wind’s direction.
CMD_WIND_SPEEDLEVELCMD_WIND_SPEEDLEVELThis indentifier indicates a command for accessing a value of wind’s speedlevel.
CMD_TEMPERATURECURRENTCMD_TEMPERATURECURRENTThis indentifier indicates a command for accessing a value of current temperature.
CMD_TEMPERATUREDESIREDCMD_TEMPERATUREDESIREDThis indentifier indicates a command for accessing a value of desired temperature.
CMD_OPERATIONCMD_OPERATIONThis indentifier indicates a command for accessing device’s operation.
MODE_VALUEAC_AUTOautoThis indentifier indicates aircondition’s auto mode.
AC_COOLcoolThis indentifier indicates aircondition’s cool mode.
AC_DRYdryThis indentifier indicates aircondition’s dry mode.
AC_FANfanThis indentifier indicates aircondition’s fan mode.
AC_HEATheatThis indentifier indicates aircondition’s heat mode.
WIND_DIRECTION_VALUEAC_UNKNOWNunknownThis indentifier indicates unknown status.
AC_WIDEwideThis indentifier indicates wide status.
AC_CENTERcenterThis indentifier indicates center status.
AC_LEFTleftThis indentifier indicates left status.
AC_RIGHTrightThis indentifier indicates right status.
AC_LONGlongThis indentifier indicates long status.
OPERATION_VALUEPOWER_ONonThis indentifier indicates POWER ON operation.
POWER_OFFoffThis indentifier indicates POWER OFF operation.

Methods

init

Description
This function creates initial connection.
Parameters
none
Return■Boolean
  - true : success to initialize
  - false : fail to initialize
Emulator SupportY
SDK Constraint- Support from SDK 5.0 - Dummy Return Value : true
Example
if (webapis.smarthome.init() == false)
    {
           alert("Fail to init SmartHome API");
           return false;
    }

destroy

Description
This function releases connection.
Parameters
none
Return■void
Emulator SupportY
SDK Constraint- Support from SDK 5.0
Example
webapis.smarthome.destroy();

getDevices

Description
This function gets all the devices.
Parameters
none
Return■Array
  - Contains all devices' information.
    * (e.g.) deviceIdList : 
    ["1d520e69-885b-44a4-866f-22e9fa7fe937","4bd37d06-5837-419b-94e9-ef07a809c74a","637c9308-01fd-474b-b465-812116ce4511","1d520e69-885b-44a4-866f-22e9fa7fe93b","4bd37d06-5837-419b-94e9-ef07a809c74e","637c9308-01fd-474b-b465-812116ce4519"]
Emulator SupportY
SDK Constraint- Support from SDK 5.0 - Dummy Return Value : ["1d520e69-885b-44a4-866f-22e9fa7fe937","4bd37d06-5837-419b-94e9-ef07a809c74a","637c9308-01fd-474b-b465-812116ce4511","1d520e69-885b-44a4-866f-22e9fa7fe93b","4bd37d06-5837-419b-94e9-ef07a809c74e","637c9308-01fd-474b-b465-812116ce4519"]
Example
var deviceIdList = webapis.smarthome.getDevices();
for (var i = 0; i < deviceIdList.length; i++)
{
    alert("device id: " + deviceIdList[i]);
}
if( deviceIdList.length <= 0)
{
    alert("No device exist");
}

getDeviceName

Description
This function gets the device's name according the device id.
Parameters
■deviceId(Mandatory) 
    - String
    - device id from getDevices()
      * (e.g.) deviceId: "0a23cbc7-e061-4884-93e7-387604d69516"
Return■String
  - Contains the device's name
    * (e.g.) name : "Air Conditioner"
Emulator SupportY
SDK Constraint- SDK 5.0 이상에서 지원 - Dummy Return Value(입력된 Device ID에 따라 다르다) "1d520e69-885b-44a4-866f-22e9fa7fe937" : "MEMORYasdfghjkqwertyuiopzxcvbnm33333333333333333", "4bd37d06-5837-419b-94e9-ef07a809c74a" : "13K_WM_LCD", "637c9308-01fd-474b-b465-812116ce4511" : "REF" "1d520e69-885b-44a4-866f-22e9fa7fe93b":"MEMORY" "4bd37d06-5837-419b-94e9-ef07a809c74e":"13K_WM_LCD_TOW" "637c9308-01fd-474b-b465-812116ce4519":"REF_TOW"
Example
var devName = webapis.smarthome.getDeviceName("0a23cbc7-e061-4884-93e7-387604d69516");
if(devName)
{
    alert("The device name is:" + devName);
}
else
{
     alert("Get device name failed");
}

getDeviceType

Description
This function gets the device's type according the device id
Parameters
■deviceId(Mandatory) 
    - String
    - device id from getDevices()
      * (e.g.) deviceId: "0a23cbc7-e061-4884-93e7-387604d69516"
Return■String
  - Contains the device's type
    * (e.g.) type : "Washer"
Emulator SupportY
SDK Constraint- Support from SDK 5.0 - Dummy Return Value(입력된 Device ID에 따라 다르다)"1d520e69-885b-44a4-866f-22e9fa7fe937" : "Air_Conditioner","4bd37d06-5837-419b-94e9-ef07a809c74a" : "Washer","637c9308-01fd-474b-b465-812116ce4511" : "Refrigerator" "1d520e69-885b-44a4-866f-22e9fa7fe93b": "Air_Conditioner","4bd37d06-5837-419b-94e9-ef07a809c74e": "Washer","637c9308-01fd-474b-b465-812116ce4519": "Refrigerator"
Example
var deviceType = webapis.smarthome.getDeviceType("0a23cbc7-e061-4884-93e7-387604d69516");
if(deviceType)
{
    alert("The device type is:" + deviceType);
}
else
{
     alert("Get device type failed");
}

getDeviceStatus

Description
This function gets the device's status information
Parameters
■deviceId(Mandatory) 
    - String
    - Contains device's id
      * (e.g.) deviceId: "0a23cbc7-e061-4884-93e7-387604d69516" 
■cmd(Mandatory) 
    - SMART_HOME_CMD
    - Contains the status which will be got
      * value: SMART_HOME_CMD  ( CMD_MODE,CMD_OPERATION_POWER,CMD_AC_WIND_DIRECTION,CMD_AC_WIND_SPEEDLEVEL,CMD_AC_TEMPERATURE_DESIRED,CMD_AC_TEMPERATURE_CURRENT,CMD_REF_TEMPERATURE_FREZZE,CMD_REF_TEMPERATURE_FRIDGE,CMD_WASHER_OPERATION_PROGRESS,CMD_WASHER_OPERATION_STATE,CMD_WASHER_OPERATION_PROGRESS_PERCENTAGE )
Return■String
  - Contains device's status information
    * (e.g.) mode : "cool"
Emulator SupportY
SDK Constraint- Support from SDK 5.0 - Dummy Return Value(입력된 Device ID에 따라 다르다) "1d520e69-885b-44a4-866f-22e9fa7fe937" CMD_MODE : "cool",CMD_AC_WIND_DIRECTION : "center",CMD_AC_WIND_SPEEDLEVEL : "3",CMD_AC_TEMPERATURE_CURRENT : "27",CMD_AC_TEMPERATURE_DESIRED : "18",CMD_OPERATION_POWER : "on",CMD_REF_TEMPERATURE_FREZZE:exceptionCMD_REF_TEMPERATURE_FRIDGE:exceptionCMD_WASHER_OPERATION_PROGRESS:undefinedCMD_WASHER_OPERATION_STATE:undefinedCMD_WASHER_OPERATION_PROGRESS_PERCENTAGE :undefined"4bd37d06-5837-419b-94e9-ef07a809c74a"CMD_MODE : "delicateshandwash",CMD_AC_WIND_DIRECTION : null,CMD_AC_WIND_SPEEDLEVEL :null,CMD_AC_TEMPERATURE_CURRENT : null,CMD_AC_TEMPERATURE_DESIRED : null,CMD_OPERATION_POWER : "on",CMD_REF_TEMPERATURE_FREZZE:null,CMD_REF_TEMPERATURE_FRIDGE:null,CMD_WASHER_OPERATION_PROGRESS:washCMD_WASHER_OPERATION_STATE:runCMD_WASHER_OPERATION_PROGRESS_PERCENTAGE :50"637c9308-01fd-474b-b465-812116ce4511"CMD_MODE : nullCMD_AC_WIND_DIRECTION : null,CMD_AC_WIND_SPEEDLEVEL :null,CMD_AC_TEMPERATURE_CURRENT : exception,CMD_AC_TEMPERATURE_DESIRED : undefinedCMD_OPERATION_POWER : "null",CMD_REF_TEMPERATURE_FREZZE:-3,CMD_REF_TEMPERATURE_FRIDGE:18,CMD_WASHER_OPERATION_PROGRESS:nullCMD_WASHER_OPERATION_STATE:nullCMD_WASHER_OPERATION_PROGRESS_PERCENTAGE :null"1d520e69-885b-44a4-866f-22e9fa7fe93b"CMD_MODE : "dry",CMD_AC_WIND_DIRECTION : "center",CMD_AC_WIND_SPEEDLEVEL : "3",CMD_AC_TEMPERATURE_CURRENT : "30",CMD_AC_TEMPERATURE_DESIRED : "20",CMD_OPERATION_POWER : "off",CMD_REF_TEMPERATURE_FREZZE:exceptionCMD_REF_TEMPERATURE_FRIDGE:exceptionCMD_WASHER_OPERATION_PROGRESS:undefinedCMD_WASHER_OPERATION_STATE:undefinedCMD_WASHER_OPERATION_PROGRESS_PERCENTAGE :undefined"4bd37d06-5837-419b-94e9-ef07a809c74e"CMD_MODE : "normal"CMD_AC_WIND_DIRECTION : null,CMD_AC_WIND_SPEEDLEVEL :null,CMD_AC_TEMPERATURE_CURRENT : null,CMD_AC_TEMPERATURE_DESIRED : null,CMD_OPERATION_POWER : "off",CMD_REF_TEMPERATURE_FREZZE:null,CMD_REF_TEMPERATURE_FRIDGE:null,CMD_WASHER_OPERATION_PROGRESS:washCMD_WASHER_OPERATION_STATE:runCMD_WASHER_OPERATION_PROGRESS_PERCENTAGE :40"637c9308-01fd-474b-b465-812116ce4519"CMD_MODE : nullCMD_AC_WIND_DIRECTION : null,CMD_AC_WIND_SPEEDLEVEL :null,CMD_AC_TEMPERATURE_CURRENT : exception,CMD_AC_TEMPERATURE_DESIRED : undefinedCMD_OPERATION_POWER : "null",CMD_REF_TEMPERATURE_FREZZE:-10,CMD_REF_TEMPERATURE_FRIDGE:20,CMD_WASHER_OPERATION_PROGRESS:nullCMD_WASHER_OPERATION_STATE:nullCMD_WASHER_OPERATION_PROGRESS_PERCENTAGE :null
Example
var deviceMode = webapis.smarthome.getDeviceStatus("42e6584a-40e0-43f0-9f8d-b2a75353cdce",webapis.smarthome.SMART_HOME_CMD.CMD_MODE);
if(deviceMode)
{
     alert("The device mode is :" + deviceMode);
}
else
{
    alert("Get device mode failed");
}

setDeviceStatus

Description
This function modify the device's status information
Parameters
■deviceId(Mandatory) 
    - String
    - Contains device's id
      * (e.g.) deviceId: "0a23cbc7-e061-4884-93e7-387604d69516" 
■cmd(Mandatory) 
    - SMART_HOME_CMD
    - Contains the status which will be modified
      * value: SMART_HOME_CMD  ( CMD_MODE,CMD_OPERATION_POWER,CMD_AC_WIND_DIRECTION,CMD_AC_WIND_SPEEDLEVEL,CMD_AC_TEMPERATURE_DESIRED,CMD_AC_TEMPERATURE_CURRENT,CMD_REF_TEMPERATURE_FREZZE,CMD_REF_TEMPERATURE_FRIDGE,CMD_WASHER_OPERATION_PROGRESS,CMD_WASHER_OPERATION_STATE,CMD_WASHER_OPERATION_PROGRESS_PERCENTAGE )
■statusInfo(Mandatory) 
  - Contains the status information which will be changed to be.
    * (e.g.) statusInfo: MODE_VALUE.AC_COOL  
    * value 
      - CMD_OPERATION_POWER : OPERATION_VALUE.POWER_ON,OPERATION_VALUE.POWER_OFF
      - CMD_MODE  : AC_AUTO,AC_COOL,AC_DRY,AC_FAN,AC_HEAT
      - CMD_AC_WIND_DIRECTION : AC_WIDE,AC_CENTER,AC_LEFT,AC_RIGHT,AC_LONG
      - CMD_AC_TEMPERATURE_DESIRED : INT(18 ~30)
      - CMD_AC_WIND_SPEEDLEVEL:INT
Return■Boolean
    - Contains the modify result
    - true : success, false : fail
     * (e.g.) setFlag : true
Emulator SupportY
SDK Constraint- Support from SDK 5.0 - Dummy Return Value : true- 이 함수 호출 후 getDeviceStatus()의 Dummy Return Value는 변경될 수 있다.
Example
var setFlag = webapis.smarthome.setDeviceStatus("0a23cbc7-e061-4884-93e7-387604d69516",webapis.smarthome.SMART_HOME_CMD.CMD_MODE,webapis.smarthome.MODE_VALUE.AC_COOL);
if(setFlag)
{
    alert("Set device status successed");
}
else
{
     alert("Set device status failed");
}