|
@@ -14,6 +14,7 @@ import javax.xml.xpath.XPathFactory;
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.w3c.dom.Document;
|
|
import org.w3c.dom.Document;
|
|
import org.w3c.dom.Node;
|
|
import org.w3c.dom.Node;
|
|
@@ -30,8 +31,10 @@ import com.icontrols.kakao.common.utils.CommonUtil;
|
|
import com.icontrols.kakao.common.utils.NodeUtil;
|
|
import com.icontrols.kakao.common.utils.NodeUtil;
|
|
import com.icontrols.kakao.common.utils.XmlUtil;
|
|
import com.icontrols.kakao.common.utils.XmlUtil;
|
|
import com.icontrols.kakao.config.AsyncConfig;
|
|
import com.icontrols.kakao.config.AsyncConfig;
|
|
|
|
+import com.icontrols.kakao.entity.ParcelInfo;
|
|
import com.icontrols.kakao.entity.ThingsInfo;
|
|
import com.icontrols.kakao.entity.ThingsInfo;
|
|
import com.icontrols.kakao.entity.UserInfo;
|
|
import com.icontrols.kakao.entity.UserInfo;
|
|
|
|
+import com.icontrols.kakao.repo.ParcelInfoRepository;
|
|
import com.icontrols.kakao.repo.ThingsInfoRepository;
|
|
import com.icontrols.kakao.repo.ThingsInfoRepository;
|
|
import com.icontrols.kakao.socket.utils.IPGenerator;
|
|
import com.icontrols.kakao.socket.utils.IPGenerator;
|
|
import com.icontrols.kakao.socket.utils.SSLClient;
|
|
import com.icontrols.kakao.socket.utils.SSLClient;
|
|
@@ -49,6 +52,9 @@ public class KakaoMsgHandler {
|
|
@Resource(name="wallpadMsgSender")
|
|
@Resource(name="wallpadMsgSender")
|
|
WallpadMsgSender wallpadMsgSender;
|
|
WallpadMsgSender wallpadMsgSender;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ ParcelInfoRepository parcelRepo;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 카카오 전용 인증 프로세스
|
|
* 카카오 전용 인증 프로세스
|
|
* 월패드에 인증번호를 노출시키는 메시지를 전송한다.
|
|
* 월패드에 인증번호를 노출시키는 메시지를 전송한다.
|
|
@@ -204,6 +210,8 @@ public class KakaoMsgHandler {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
thingList.add(new ThingsInfo("elevator","ElevatorCaller", Integer.toString(dong), Integer.toString(ho)));
|
|
thingList.add(new ThingsInfo("elevator","ElevatorCaller", Integer.toString(dong), Integer.toString(ho)));
|
|
|
|
+ thingList.add(new ThingsInfo("parcel","CommonParcel", Integer.toString(dong), Integer.toString(ho)));
|
|
|
|
+ thingList.add(new ThingsInfo("parking","CommonParking", Integer.toString(dong), Integer.toString(ho)));
|
|
}catch(Exception e) {
|
|
}catch(Exception e) {
|
|
logger.error("[ERROR] - " + e.getMessage());
|
|
logger.error("[ERROR] - " + e.getMessage());
|
|
return null;
|
|
return null;
|
|
@@ -252,6 +260,9 @@ public class KakaoMsgHandler {
|
|
Node dCount = null;
|
|
Node dCount = null;
|
|
NodeList devList = (NodeList)xpath.evaluate("//imap/service/devinfo", doc, XPathConstants.NODESET);
|
|
NodeList devList = (NodeList)xpath.evaluate("//imap/service/devinfo", doc, XPathConstants.NODESET);
|
|
|
|
|
|
|
|
+ logger.debug("****device list***");
|
|
|
|
+ logger.debug(devList.toString());
|
|
|
|
+
|
|
NodeUtil.asList(devList)
|
|
NodeUtil.asList(devList)
|
|
.stream()
|
|
.stream()
|
|
.filter(pNode -> THINGS_INFO.isAvailableThings(XmlUtil.getAttributeWithItem(pNode, "name")))
|
|
.filter(pNode -> THINGS_INFO.isAvailableThings(XmlUtil.getAttributeWithItem(pNode, "name")))
|
|
@@ -260,7 +271,7 @@ public class KakaoMsgHandler {
|
|
int childCount = Integer.parseInt(XmlUtil.getAttributeWithItem(pNode, "value"));
|
|
int childCount = Integer.parseInt(XmlUtil.getAttributeWithItem(pNode, "value"));
|
|
|
|
|
|
List<Map<String, Object>> childNodeInfoList = null;
|
|
List<Map<String, Object>> childNodeInfoList = null;
|
|
- logger.debug("tmpModelID --> " + tmpModelId + "childCount = " + childCount);
|
|
|
|
|
|
+ logger.debug("[tmpModelID] --> " + tmpModelId + " [childCount] = " + childCount);
|
|
try {
|
|
try {
|
|
// subdevinfo 를 가지고 있는 THINGS일 경우는 subdevinfo 들을 다시 구해야 한다.
|
|
// subdevinfo 를 가지고 있는 THINGS일 경우는 subdevinfo 들을 다시 구해야 한다.
|
|
// 예를들어 light는 light01 ~ 05 등의 subdevinfo를 가진다.
|
|
// 예를들어 light는 light01 ~ 05 등의 subdevinfo를 가진다.
|
|
@@ -312,6 +323,17 @@ public class KakaoMsgHandler {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+ //aircon의 capa를 다시 조회한다.
|
|
|
|
+ // aircon은 세대별로 지원하는 모드가 다를 수 있어서 월패드의 해당 세대의 에어컨 속성을 다시 조회해서 전달해줘야 한다.
|
|
|
|
+// Map<String, Object> airconCapaMap = getAirconCapability(dong, ho);
|
|
|
|
+// for(int i=1; i <=10; i++) {
|
|
|
|
+// String _tmpEndpoint = "aircon_" + i;
|
|
|
|
+// if(body.containsKey(_tmpEndpoint)) {
|
|
|
|
+// Map<String, Object> _tmpDeviceMap = (HashMap)body.get(_tmpEndpoint);
|
|
|
|
+// _tmpDeviceMap.put("capabilities", airconCapaMap.get("capabilities"));
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+
|
|
// elevator는 하드코딩.
|
|
// elevator는 하드코딩.
|
|
// elevator가 존재해야 카카오홈 앱에서 엘리베이터를 제어할 수 있다.
|
|
// elevator가 존재해야 카카오홈 앱에서 엘리베이터를 제어할 수 있다.
|
|
Map<String, Object> eleMap = new HashMap<String, Object>();
|
|
Map<String, Object> eleMap = new HashMap<String, Object>();
|
|
@@ -324,19 +346,199 @@ public class KakaoMsgHandler {
|
|
eleMap.put(KEY_INFO.BODY_KEY_ADDITIONALPROP, getAdditionalProp(KEY_INFO.BODY_KEY_ROOMPRESETNAME, THINGS_INFO.DEVICE_DETAIL.ELEVATOR.getRoomName()));
|
|
eleMap.put(KEY_INFO.BODY_KEY_ADDITIONALPROP, getAdditionalProp(KEY_INFO.BODY_KEY_ROOMPRESETNAME, THINGS_INFO.DEVICE_DETAIL.ELEVATOR.getRoomName()));
|
|
body.put("elevator", eleMap);
|
|
body.put("elevator", eleMap);
|
|
|
|
|
|
- if(SERVERINFO.KAKAO_I_WALLPAD_APPLY) {
|
|
|
|
- Map<String, Object> wpMap = new HashMap<String, Object>();
|
|
|
|
- String wpEndpointId = "WALLPAD_"+SERVERINFO.danzi_code+"_"+dong+"_"+ho;
|
|
|
|
- wpMap.put("endpointId", wpEndpointId);
|
|
|
|
- wpMap.put("name", "월패드");
|
|
|
|
- wpMap.put("displayType", "DummyWallPad");
|
|
|
|
- wpMap.put("capabilities", new ArrayList<>());
|
|
|
|
- wpMap.put("state", "{}");
|
|
|
|
- wpMap.put("additionalProperties", null);
|
|
|
|
-
|
|
|
|
- body.put(wpEndpointId, wpMap);
|
|
|
|
|
|
+ // 주차위치도 직접 입력해줘야 함.
|
|
|
|
+// Map<String, Object> parkingMap = new HashMap<String, Object>();
|
|
|
|
+// parkingMap.put(KEY_INFO.BODY_KEY_DISPLAY_TYPE, THINGS_INFO.THINGS.PARKING.getKakaoDisplayName());
|
|
|
|
+// parkingMap.putAll(getDeviceCapabilities(THINGS_INFO.THINGS.PARKING.getThingsName(), null));
|
|
|
|
+// parkingMap.put(KEY_INFO.BODY_KEY_ENDPOINT_ID, THINGS_INFO.DEVICE_DETAIL.PARKING.getModelId());
|
|
|
|
+// parkingMap.put(KEY_INFO.BODY_KEY_NAME, THINGS_INFO.THINGS.PARKING.getDesc());
|
|
|
|
+//
|
|
|
|
+// // 주차위치를 월패드에 물어봐서 입력해주어야함.
|
|
|
|
+// parkingMap.put(KEY_INFO.BODY_KEY_STATE, getParkingList(dong, ho));
|
|
|
|
+// parkingMap.put(KEY_INFO.BODY_KEY_ADDITIONALPROP, getAdditionalProp(KEY_INFO.BODY_KEY_ROOMPRESETNAME, THINGS_INFO.DEVICE_DETAIL.PARKING.getRoomName()));
|
|
|
|
+// body.put("parking", parkingMap);
|
|
|
|
+
|
|
|
|
+ // 택배 정보를 조회해서 알려주어야 함.
|
|
|
|
+// Map<String, Object> parcelMap = getParcelList(dong, ho);
|
|
|
|
+//
|
|
|
|
+// if(parcelMap != null)
|
|
|
|
+// body.put("parcel", parcelMap);
|
|
|
|
+
|
|
|
|
+// if(SERVERINFO.KAKAO_I_WALLPAD_APPLY) {
|
|
|
|
+// Map<String, Object> wpMap = new HashMap<String, Object>();
|
|
|
|
+// String wpEndpointId = "WALLPAD_"+SERVERINFO.danzi_code+"_"+dong+"_"+ho;
|
|
|
|
+// wpMap.put("endpointId", wpEndpointId);
|
|
|
|
+// wpMap.put("name", "월패드");
|
|
|
|
+// wpMap.put("displayType", "DummyWallPad");
|
|
|
|
+// wpMap.put("capabilities", new ArrayList<>());
|
|
|
|
+// wpMap.put("state", "{}");
|
|
|
|
+// wpMap.put("additionalProperties", null);
|
|
|
|
+//
|
|
|
|
+// body.put(wpEndpointId, wpMap);
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+ }catch(Exception e) {
|
|
|
|
+ retMap.put(KEY_INFO.HTTP_KEY_ERROR, KAKAO_RESULT.getErrorInfo(KAKAO_RESULT.FAIL_INTERNAL));
|
|
|
|
+ logger.error("[ERROR] - " + e.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ metadata.put("aptCode", SERVERINFO.danzi_code);
|
|
|
|
+ retMap.put(KEY_INFO.HTTP_KEY_METADATA, metadata);
|
|
|
|
+ retMap.put(KEY_INFO.HTTP_KEY_UNREACHABLEIDS, unreachableIds);
|
|
|
|
+ retMap.put(KEY_INFO.HTTP_KEY_BODY, body);
|
|
|
|
+
|
|
|
|
+ return retMap;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public Map<String, Object> getDevicesStatusListTemp(int dong, int ho) {
|
|
|
|
+ Map<String, Object> retMap = new HashMap<String, Object>();
|
|
|
|
+ Map<String, String> metadata = new HashMap<String, String>();
|
|
|
|
+ Map<String, Object> body = new HashMap<String, Object>();
|
|
|
|
+ List<String> unreachableIds = new ArrayList<String>();
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ Document doc = new WallpadMsgSender().remoteDeviceStatusList(dong, ho);
|
|
|
|
+
|
|
|
|
+ if(doc == null) {
|
|
|
|
+ retMap.put(KEY_INFO.HTTP_KEY_ERROR, KAKAO_RESULT.getErrorInfo(KAKAO_RESULT.FAIL_UNREACHABLE));
|
|
|
|
+ logger.error("[ERROR]-[Document is Null] - [" + dong + "-" + ho + "]");
|
|
|
|
+ return retMap;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ XPath xpath = XPathFactory.newInstance().newXPath();
|
|
|
|
+ Node iMap = (Node)xpath.evaluate("//imap/service", doc, XPathConstants.NODE);
|
|
|
|
+ String xmlResult = XmlUtil.getAttributeWithItem(iMap, "result");
|
|
|
|
+
|
|
|
|
+ logger.debug("[KakaoMsgHandler - getDeviceList] - xmlResult -> " + xmlResult);
|
|
|
|
+
|
|
|
|
+ if(!xmlResult.equalsIgnoreCase("ok")) {
|
|
|
|
+ retMap.put(KEY_INFO.HTTP_KEY_ERROR, KAKAO_RESULT.getErrorInfo(KAKAO_RESULT.FAIL_UNREACHABLE));
|
|
|
|
+ logger.error("[KakaoMsgHandler - getDeviceList] - [" + dong + "]-[" + ho + "] xmlResult not ok \r\n" + xmlResult);
|
|
|
|
+
|
|
|
|
+ return retMap;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 월패드와 연결된 상위 THINGS 갯수 확인
|
|
|
|
+ Node dCount = null;
|
|
|
|
+ NodeList devList = (NodeList)xpath.evaluate("//imap/service/devinfo", doc, XPathConstants.NODESET);
|
|
|
|
+
|
|
|
|
+ logger.debug("****device list***");
|
|
|
|
+ logger.debug(devList.toString());
|
|
|
|
+
|
|
|
|
+ NodeUtil.asList(devList)
|
|
|
|
+ .stream()
|
|
|
|
+ .filter(pNode -> THINGS_INFO.isAvailableThings(XmlUtil.getAttributeWithItem(pNode, "name")))
|
|
|
|
+ .forEach(pNode -> {
|
|
|
|
+ String tmpModelId = XmlUtil.getAttributeWithItem(pNode, "name");
|
|
|
|
+ int childCount = Integer.parseInt(XmlUtil.getAttributeWithItem(pNode, "value"));
|
|
|
|
+
|
|
|
|
+ List<Map<String, Object>> childNodeInfoList = null;
|
|
|
|
+ logger.debug("[tmpModelID] --> " + tmpModelId + " [childCount] = " + childCount);
|
|
|
|
+ try {
|
|
|
|
+ // subdevinfo 를 가지고 있는 THINGS일 경우는 subdevinfo 들을 다시 구해야 한다.
|
|
|
|
+ // 예를들어 light는 light01 ~ 05 등의 subdevinfo를 가진다.
|
|
|
|
+
|
|
|
|
+ // livinglight와 light는 -> dimmer와 colorTemp를 조절이 가능한 조명이 포함될 수 있다.
|
|
|
|
+ // 전등의 경우 월패드에서는 크게 livinglight 또는 light 로 나뉘고 속성은 같은반변
|
|
|
|
+ // 카카오에서는 light, LightDimmer, ColorLightDimmer 세가지로 나뉜다.
|
|
|
|
+ // 월패드의 status는 (전원)/(디밍값)/(색상온도값) 으로 구성되며
|
|
|
|
+ // 전원을 제외하고 각 지원하지 않는 기능은 null로 전달된다.
|
|
|
|
+ // LightDimmer는 월패드에서 status가 on/40/null 로 status가 구성되고
|
|
|
|
+ // ColorLightDimmer는 월패드에서 status가 on/40/10 의 형태 또는 status가 on/null/10 의형태로 구성된다.
|
|
|
|
+ // status의 구성요소에 맞게 capability가 구성되어야 한다.
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if(tmpModelId.equalsIgnoreCase("light") || tmpModelId.equalsIgnoreCase("electric")) {
|
|
|
|
+ for(int j=1; j <= childCount; j++) {
|
|
|
|
+ String childName = j < 10 ? tmpModelId+"0"+j : tmpModelId+j;
|
|
|
|
+ Node childNode = (Node)xpath.evaluate("//imap/service/devinfo/*[@name='"+ childName +"']", doc, XPathConstants.NODE);
|
|
|
|
+ logger.debug("childName = " + childName + " // j = " + j);
|
|
|
|
+
|
|
|
|
+ if(childNode == null) continue;
|
|
|
|
+
|
|
|
|
+ String tmpValue = XmlUtil.getAttributeWithItem(childNode, "value");
|
|
|
|
+
|
|
|
|
+ if(tmpValue == null) continue;
|
|
|
|
+
|
|
|
|
+ int tmpchildCount = Integer.parseInt(tmpValue);
|
|
|
|
+
|
|
|
|
+ NodeList childList = (NodeList)xpath.evaluate("//imap/service/devinfo/subdevinfo/*[@name='"+ childName +"']", doc, XPathConstants.NODESET);
|
|
|
|
+
|
|
|
|
+ childNodeInfoList = getChildDeviceInfo(tmpchildCount, childList);
|
|
|
|
+ logger.debug("child-->>" + childNodeInfoList.toString());
|
|
|
|
+ if(childNodeInfoList != null)
|
|
|
|
+ childNodeInfoList.forEach(tMap -> { body.putAll(tMap); });
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ NodeList childList = (NodeList)xpath.evaluate("//imap/service/devinfo/*[@name='"+ tmpModelId +"']", doc, XPathConstants.NODESET);
|
|
|
|
+
|
|
|
|
+ childNodeInfoList = getChildDeviceInfo(childCount, childList);
|
|
|
|
+
|
|
|
|
+ logger.debug("child-->>" + childNodeInfoList.toString());
|
|
|
|
+
|
|
|
|
+ if(childNodeInfoList != null)
|
|
|
|
+ childNodeInfoList.forEach(tMap -> { body.putAll(tMap); });
|
|
|
|
+ }
|
|
|
|
+ }catch(Exception e) {
|
|
|
|
+ retMap.put(KEY_INFO.HTTP_KEY_ERROR, KAKAO_RESULT.getErrorInfo(KAKAO_RESULT.FAIL_INTERNAL));
|
|
|
|
+ logger.error("[ERROR] at stream - " + e.getMessage());
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ Map<String, Object> airconCapaMap = getAirconCapability(dong, ho);
|
|
|
|
+ for(int i=1; i <=10; i++) {
|
|
|
|
+ String _tmpEndpoint = "aircon_" + i;
|
|
|
|
+ if(body.containsKey(_tmpEndpoint)) {
|
|
|
|
+ Map<String, Object> _tmpDeviceMap = (HashMap)body.get(_tmpEndpoint);
|
|
|
|
+ _tmpDeviceMap.put("capabilities", airconCapaMap.get("capabilities"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // elevator는 하드코딩.
|
|
|
|
+ // elevator가 존재해야 카카오홈 앱에서 엘리베이터를 제어할 수 있다.
|
|
|
|
+ Map<String, Object> eleMap = new HashMap<String, Object>();
|
|
|
|
+
|
|
|
|
+ eleMap.put(KEY_INFO.BODY_KEY_DISPLAY_TYPE, THINGS_INFO.THINGS.ELEVATOR.getKakaoDisplayName());
|
|
|
|
+ eleMap.putAll(getDeviceCapabilities(THINGS_INFO.THINGS.ELEVATOR.getThingsName(), null));
|
|
|
|
+ eleMap.put(KEY_INFO.BODY_KEY_ENDPOINT_ID, THINGS_INFO.DEVICE_DETAIL.ELEVATOR.getModelId());
|
|
|
|
+ eleMap.put(KEY_INFO.BODY_KEY_NAME, THINGS_INFO.THINGS.ELEVATOR.getDesc());
|
|
|
|
+ eleMap.put(KEY_INFO.BODY_KEY_STATE, new HashMap<String, Object>());
|
|
|
|
+ eleMap.put(KEY_INFO.BODY_KEY_ADDITIONALPROP, getAdditionalProp(KEY_INFO.BODY_KEY_ROOMPRESETNAME, THINGS_INFO.DEVICE_DETAIL.ELEVATOR.getRoomName()));
|
|
|
|
+ body.put("elevator", eleMap);
|
|
|
|
+
|
|
|
|
+ // 주차위치도 직접 입력해줘야 함.
|
|
|
|
+ Map<String, Object> parkingMap = new HashMap<String, Object>();
|
|
|
|
+ parkingMap.put(KEY_INFO.BODY_KEY_DISPLAY_TYPE, THINGS_INFO.THINGS.PARKING.getKakaoDisplayName());
|
|
|
|
+ parkingMap.putAll(getDeviceCapabilities(THINGS_INFO.THINGS.PARKING.getThingsName(), null));
|
|
|
|
+ parkingMap.put(KEY_INFO.BODY_KEY_ENDPOINT_ID, THINGS_INFO.DEVICE_DETAIL.PARKING.getModelId());
|
|
|
|
+ parkingMap.put(KEY_INFO.BODY_KEY_NAME, THINGS_INFO.THINGS.PARKING.getDesc());
|
|
|
|
+
|
|
|
|
+ // 주차위치를 월패드에 물어봐서 입력해주어야함.
|
|
|
|
+ parkingMap.put(KEY_INFO.BODY_KEY_STATE, getParkingList(dong, ho));
|
|
|
|
+ parkingMap.put(KEY_INFO.BODY_KEY_ADDITIONALPROP, getAdditionalProp(KEY_INFO.BODY_KEY_ROOMPRESETNAME, THINGS_INFO.DEVICE_DETAIL.PARKING.getRoomName()));
|
|
|
|
+ body.put("parking", parkingMap);
|
|
|
|
+
|
|
|
|
+ // 택배 정보를 조회해서 알려주어야 함.
|
|
|
|
+ Map<String, Object> parcelMap = getParcelList(dong, ho);
|
|
|
|
+
|
|
|
|
+ if(parcelMap != null)
|
|
|
|
+ body.put("parcel", parcelMap);
|
|
|
|
+
|
|
|
|
+// if(SERVERINFO.KAKAO_I_WALLPAD_APPLY) {
|
|
|
|
+// Map<String, Object> wpMap = new HashMap<String, Object>();
|
|
|
|
+// String wpEndpointId = "WALLPAD_"+SERVERINFO.danzi_code+"_"+dong+"_"+ho;
|
|
|
|
+// wpMap.put("endpointId", wpEndpointId);
|
|
|
|
+// wpMap.put("name", "월패드");
|
|
|
|
+// wpMap.put("displayType", "DummyWallPad");
|
|
|
|
+// wpMap.put("capabilities", new ArrayList<>());
|
|
|
|
+// wpMap.put("state", "{}");
|
|
|
|
+// wpMap.put("additionalProperties", null);
|
|
|
|
+//
|
|
|
|
+// body.put(wpEndpointId, wpMap);
|
|
|
|
+// }
|
|
|
|
+
|
|
}catch(Exception e) {
|
|
}catch(Exception e) {
|
|
retMap.put(KEY_INFO.HTTP_KEY_ERROR, KAKAO_RESULT.getErrorInfo(KAKAO_RESULT.FAIL_INTERNAL));
|
|
retMap.put(KEY_INFO.HTTP_KEY_ERROR, KAKAO_RESULT.getErrorInfo(KAKAO_RESULT.FAIL_INTERNAL));
|
|
logger.error("[ERROR] - " + e.getMessage());
|
|
logger.error("[ERROR] - " + e.getMessage());
|
|
@@ -350,6 +552,288 @@ public class KakaoMsgHandler {
|
|
return retMap;
|
|
return retMap;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ private Map<String, Object>getParkingList(int dong, int ho){
|
|
|
|
+ Map<String, Object> retMap = new HashMap<String, Object>();
|
|
|
|
+ try {
|
|
|
|
+ Document doc = new WallpadMsgSender().remoteGetParkingList(dong, ho);
|
|
|
|
+ if(doc == null) {
|
|
|
|
+ retMap.put(KEY_INFO.HTTP_KEY_ERROR, KAKAO_RESULT.getErrorInfo(KAKAO_RESULT.FAIL_UNREACHABLE));
|
|
|
|
+ logger.error("[ERROR]-[getParkingList]-[Document is Null] - [" + dong + "-" + ho + "]");
|
|
|
|
+ return retMap;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ XPath xpath = XPathFactory.newInstance().newXPath();
|
|
|
|
+ Node iMap = (Node)xpath.evaluate("//imap/service", doc, XPathConstants.NODE);
|
|
|
|
+ String xmlResult = XmlUtil.getAttributeWithItem(iMap, "result");
|
|
|
|
+
|
|
|
|
+ logger.debug("[KakaoMsgHandler - getParkingList] - xmlResult -> " + xmlResult);
|
|
|
|
+
|
|
|
|
+ if(!xmlResult.equalsIgnoreCase("ok")) {
|
|
|
|
+// retMap.put(KEY_INFO.HTTP_KEY_ERROR, KAKAO_RESULT.getErrorInfo(KAKAO_RESULT.FAIL_UNREACHABLE));
|
|
|
|
+ logger.error("[KakaoMsgHandler - getParkingList] - [" + dong + "]-[" + ho + "] xmlResult not ok \r\n" + xmlResult);
|
|
|
|
+ retMap.put("parkingLocations", new ArrayList<>());
|
|
|
|
+ return retMap;
|
|
|
|
+ }
|
|
|
|
+ Node parkingList = (Node)xpath.evaluate("//imap/service/parking_list",doc, XPathConstants.NODE);
|
|
|
|
+ int parkingListCnt = Integer.parseInt(XmlUtil.getAttributeWithItem(parkingList, "total_count"));
|
|
|
|
+
|
|
|
|
+ logger.debug("[KakaoMsgHandler - getParkingList] - 1 parkingListCnt = " + parkingListCnt);
|
|
|
|
+
|
|
|
|
+ if(parkingListCnt == 0) return retMap;
|
|
|
|
+
|
|
|
|
+ List<Map<String,Object>> parkingLocations = new ArrayList<>();
|
|
|
|
+ NodeUtil.asList((NodeList)xpath.evaluate("//imap/service/parking_list/parking_info", doc, XPathConstants.NODESET))
|
|
|
|
+ .stream()
|
|
|
|
+ .forEach(pNode ->{
|
|
|
|
+ String carNum = XmlUtil.getAttributeWithItem(pNode, "car_num");
|
|
|
|
+ String location = XmlUtil.getAttributeWithItem(pNode, "location");
|
|
|
|
+ Map<String, Object> _parkingInfo = new HashMap<String, Object>();
|
|
|
|
+
|
|
|
|
+ _parkingInfo.put("carno", carNum);
|
|
|
|
+ _parkingInfo.put("name", location);
|
|
|
|
+ _parkingInfo.put("parked", true);
|
|
|
|
+
|
|
|
|
+ parkingLocations.add(_parkingInfo);
|
|
|
|
+ });
|
|
|
|
+ retMap.put("parkingLocations", parkingLocations);
|
|
|
|
+ }catch(Exception e) {
|
|
|
|
+ logger.error("[ERROR]-[getParkingList]-" + e.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ logger.info("[parkingList]-[ret]-" + retMap.toString());
|
|
|
|
+
|
|
|
|
+ return retMap;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private Map<String, Object>getParcelList(int dong, int ho){
|
|
|
|
+ Map<String, Object> retMap = new HashMap<String, Object>();
|
|
|
|
+ try {
|
|
|
|
+ List<ParcelInfo> list = parcelRepo.findByDonghoId(dong+"/"+ho);
|
|
|
|
+ // 해당 세대의 조회된 택배DB가 없을 경우 DB를 생성한다.
|
|
|
|
+ ParcelInfo parcelObj = null;
|
|
|
|
+ if(list.size() == 0) {
|
|
|
|
+ parcelObj = new ParcelInfo(dong+"/"+ho, 0, null, null);
|
|
|
|
+ parcelRepo.save(parcelObj);
|
|
|
|
+ }else {
|
|
|
|
+ parcelObj = list.get(0);
|
|
|
|
+ }
|
|
|
|
+ Map<String, Object> stateMap = new HashMap<>();
|
|
|
|
+ List<Object> parcelList = new ArrayList<>();
|
|
|
|
+ logger.info("[" + dong + "/" + ho +"]-[parcel]-" + parcelObj.toString());
|
|
|
|
+
|
|
|
|
+ for(int i=0; i < parcelObj.getQuantity(); i++) {
|
|
|
|
+ Map<String, Object> _obj = new HashMap<>();
|
|
|
|
+ _obj.put("name", "택배 보관함");
|
|
|
|
+ _obj.put("lastDeliveredTime", parcelObj.getLstUptTime());
|
|
|
|
+ parcelList.add(_obj);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ stateMap.put("parcelLocations", parcelList);
|
|
|
|
+
|
|
|
|
+ retMap.put(KEY_INFO.BODY_KEY_DISPLAY_TYPE, THINGS_INFO.THINGS.PARCEL.getKakaoDisplayName());
|
|
|
|
+ retMap.putAll(getDeviceCapabilities(THINGS_INFO.THINGS.PARCEL.getThingsName(), null));
|
|
|
|
+ retMap.put(KEY_INFO.BODY_KEY_ENDPOINT_ID, THINGS_INFO.DEVICE_DETAIL.PARCEL.getModelId());
|
|
|
|
+ retMap.put(KEY_INFO.BODY_KEY_NAME, THINGS_INFO.THINGS.PARCEL.getDesc());
|
|
|
|
+ retMap.put(KEY_INFO.BODY_KEY_STATE, stateMap);
|
|
|
|
+ retMap.put(KEY_INFO.BODY_KEY_ADDITIONALPROP, getAdditionalProp(KEY_INFO.BODY_KEY_ROOMPRESETNAME, THINGS_INFO.DEVICE_DETAIL.PARKING.getRoomName()));
|
|
|
|
+ }catch(Exception e) {
|
|
|
|
+ logger.error("[ERROR]-[getParcelList]-" + e.getMessage());
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ return retMap;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public Map<String, Object>getAirconCapability(int dong, int ho){
|
|
|
|
+ String jsonString = THINGS_INFO.THINGS_CAPABILITY.AIRCON.getCapJsonStr();
|
|
|
|
+
|
|
|
|
+ Map<String, Object> capabilities = CommonUtil.jsonToMap(jsonString);
|
|
|
|
+ try {
|
|
|
|
+ Document doc = new WallpadMsgSender().remoteGetAirconAttributes(dong, ho);
|
|
|
|
+ if(doc == null) {
|
|
|
|
+ logger.error("[ERROR]-[getAirconCapability]-[Document is Null] - [" + dong + "-" + ho + "]");
|
|
|
|
+ return capabilities;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ XPath xpath = XPathFactory.newInstance().newXPath();
|
|
|
|
+ Node iMap = (Node)xpath.evaluate("//imap/service", doc, XPathConstants.NODE);
|
|
|
|
+ String xmlResult = XmlUtil.getAttributeWithItem(iMap, "result");
|
|
|
|
+
|
|
|
|
+ logger.debug("[KakaoMsgHandler - private] - xmlResult -> " + xmlResult);
|
|
|
|
+
|
|
|
|
+ if(!xmlResult.equalsIgnoreCase("ok")) {
|
|
|
|
+// retMap.put(KEY_INFO.HTTP_KEY_ERROR, KAKAO_RESULT.getErrorInfo(KAKAO_RESULT.FAIL_UNREACHABLE));
|
|
|
|
+ logger.error("[KakaoMsgHandler - getAirconCapability] - [" + dong + "]-[" + ho + "] xmlResult not ok \r\n" + xmlResult);
|
|
|
|
+ return capabilities;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Node attributes = (Node)xpath.evaluate("//imap/service/attributes",doc, XPathConstants.NODE);
|
|
|
|
+ int totalAirconCount = Integer.parseInt(XmlUtil.getAttributeWithItem(attributes, "total_count"));
|
|
|
|
+
|
|
|
|
+ logger.debug("[KakaoMsgHandler - getAirconCapability] - totalAirconCount = " + totalAirconCount);
|
|
|
|
+
|
|
|
|
+ Node coolTempAttributes = (Node)xpath.evaluate("//imap/service/attributes/cool_temperature",doc, XPathConstants.NODE);
|
|
|
|
+ int minCoolTemperature = Integer.parseInt(XmlUtil.getAttributeWithItem(coolTempAttributes, "min"));
|
|
|
|
+ int maxCoolTemperature = Integer.parseInt(XmlUtil.getAttributeWithItem(coolTempAttributes, "max"));
|
|
|
|
+
|
|
|
|
+ Node heatTempAttributes = (Node)xpath.evaluate("//imap/service/attributes/heat_temperature",doc, XPathConstants.NODE);
|
|
|
|
+ int minHeatTemperature = Integer.parseInt(XmlUtil.getAttributeWithItem(heatTempAttributes, "min"));
|
|
|
|
+ int maxHeatTemperature = Integer.parseInt(XmlUtil.getAttributeWithItem(heatTempAttributes, "max"));
|
|
|
|
+
|
|
|
|
+ int minTemperature = minCoolTemperature<=minHeatTemperature?minCoolTemperature:minHeatTemperature;
|
|
|
|
+ int maxTemperature = maxCoolTemperature>=maxHeatTemperature?maxCoolTemperature:maxHeatTemperature;
|
|
|
|
+
|
|
|
|
+ logger.debug("[KakaoMsgHandler - getAirconCapability] - minTemperature = " + minTemperature + " - maxTemperature =" + maxTemperature);
|
|
|
|
+
|
|
|
|
+ Node modeAttributes = (Node)xpath.evaluate("//imap/service/attributes/mode",doc, XPathConstants.NODE);
|
|
|
|
+ String strModeOption = XmlUtil.getElemetTextValue(modeAttributes);
|
|
|
|
+ String[] arrModeOption = strModeOption.split("/");
|
|
|
|
+ logger.debug("[KakaoMsgHandler - getAirconCapability] - arrModeOption = " + arrModeOption);
|
|
|
|
+
|
|
|
|
+ Node airFlowAttributes = (Node)xpath.evaluate("//imap/service/attributes/air_flow",doc, XPathConstants.NODE);
|
|
|
|
+ String strAirFlowOption = XmlUtil.getElemetTextValue(airFlowAttributes);
|
|
|
|
+ String[] arrAirFlowOption = strAirFlowOption.split("/");
|
|
|
|
+ logger.debug("[KakaoMsgHandler - getAirconCapability] - arrAirFlowOption = " + arrAirFlowOption);
|
|
|
|
+
|
|
|
|
+ List<HashMap<String, Object>> capabilityList = (ArrayList)capabilities.get("capabilities");
|
|
|
|
+ logger.debug("[KakaoMsgHandler - getAirconCapability] - capabilityList = " + capabilityList.toString());
|
|
|
|
+
|
|
|
|
+ for(HashMap<String, Object> capa:capabilityList) {
|
|
|
|
+ String capaName = (String) capa.get("name");
|
|
|
|
+ logger.debug("[KakaoMsgHandler - getAirconCapability] - capaName = " + capaName);
|
|
|
|
+ Map<String, Object> attr = (HashMap)capa.get("attributes");
|
|
|
|
+ logger.debug("[KakaoMsgHandler - getAirconCapability] - attr = " + attr.toString());
|
|
|
|
+ if(capaName.equalsIgnoreCase("AirConditioner")) {
|
|
|
|
+ Map<String, Object> modeCapa = (HashMap)attr.get("mode");
|
|
|
|
+ logger.debug("[KakaoMsgHandler - getAirconCapability] - modeCapa = " + modeCapa.toString());
|
|
|
|
+
|
|
|
|
+ List<String> modeAttrList = new ArrayList();
|
|
|
|
+ for(String mode:arrModeOption) {
|
|
|
|
+ logger.debug("[KakaoMsgHandler - getAirconCapability] - modeCapa-detail = " + mode);
|
|
|
|
+ if(mode.equalsIgnoreCase("auto"))
|
|
|
|
+ modeAttrList.add("auto");
|
|
|
|
+ else if(mode.equalsIgnoreCase("cool"))
|
|
|
|
+ modeAttrList.add("cool");
|
|
|
|
+ else if(mode.equalsIgnoreCase("heat"))
|
|
|
|
+ modeAttrList.add("heat");
|
|
|
|
+ else if(mode.equalsIgnoreCase("fan"))
|
|
|
|
+ modeAttrList.add("fan_only");
|
|
|
|
+ else if(mode.equalsIgnoreCase("dehum"))
|
|
|
|
+ modeAttrList.add("dehumidify");
|
|
|
|
+ }
|
|
|
|
+ modeCapa.clear();
|
|
|
|
+ modeCapa.put("writable", modeAttrList);
|
|
|
|
+ modeCapa.put("supported", modeAttrList);
|
|
|
|
+ modeCapa.put("mutability", "rw");
|
|
|
|
+ }else if(capaName.equalsIgnoreCase("AirFlow")) {
|
|
|
|
+ Map<String, Object> airFlowCapa = (HashMap)attr.get("fanSpeed");
|
|
|
|
+ List<String> airFlowAttrList = new ArrayList();
|
|
|
|
+ for(String mode:arrAirFlowOption) {
|
|
|
|
+ if(mode.equalsIgnoreCase("auto"))
|
|
|
|
+ airFlowAttrList.add("auto");
|
|
|
|
+ else if(mode.equalsIgnoreCase("low"))
|
|
|
|
+ airFlowAttrList.add("low");
|
|
|
|
+ else if(mode.equalsIgnoreCase("mid"))
|
|
|
|
+ airFlowAttrList.add("middle");
|
|
|
|
+ else if(mode.equalsIgnoreCase("high"))
|
|
|
|
+ airFlowAttrList.add("high");
|
|
|
|
+ }
|
|
|
|
+ airFlowCapa.clear();
|
|
|
|
+ airFlowCapa.put("writable", airFlowAttrList);
|
|
|
|
+ airFlowCapa.put("supported", airFlowAttrList);
|
|
|
|
+ airFlowCapa.put("mutability", "rw");
|
|
|
|
+ }else if(capaName.equalsIgnoreCase("Temperature")) {
|
|
|
|
+ Map<String, Object> tempAttr = new HashMap<>();
|
|
|
|
+ tempAttr.put("mutability", "r");
|
|
|
|
+ tempAttr.put("max", maxTemperature);
|
|
|
|
+ tempAttr.put("min", minTemperature);
|
|
|
|
+ tempAttr.put("mutability", "r");
|
|
|
|
+ attr.clear();
|
|
|
|
+ attr.put("currentTemperature", tempAttr);
|
|
|
|
+
|
|
|
|
+ }else if(capaName.equalsIgnoreCase("TemperatureSetpoint")) {
|
|
|
|
+ Map<String, Object> tempAttr = new HashMap<>();
|
|
|
|
+ tempAttr.put("mutability", "r");
|
|
|
|
+ tempAttr.put("max", maxTemperature);
|
|
|
|
+ tempAttr.put("min", minTemperature);
|
|
|
|
+ tempAttr.put("mutability", "r");
|
|
|
|
+ attr.clear();
|
|
|
|
+ attr.put("targetSetpoint", tempAttr);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }catch(Exception e) {
|
|
|
|
+ logger.error("[ERROR]-[getAirconCapability]-[Exception]-" + e.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ logger.info("[getAirconCapability]-" + capabilities.toString());
|
|
|
|
+ return capabilities;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static Map<String, Object>getAirconEnableTemperature(int dong, int ho, String endpointId){
|
|
|
|
+ // 디바이스의 현재 상태를 먼저 조회한다.
|
|
|
|
+ // 디바이스의 모드를 먼저 확인한다.
|
|
|
|
+ // 디바이스의 설정 온도 가능 범위를 확인한다.
|
|
|
|
+ // 디바이스가 냉방이면 냉방의 가능범위를 응답한다.
|
|
|
|
+ // 디바이스가 난방이면 난방의 가능범위를 응답한다.
|
|
|
|
+ // 디바이스가 그외 모드이면 냉방과 난방의 교집합으로 응답한다.
|
|
|
|
+ Map<String, Object> retMap = new HashMap<String, Object>();
|
|
|
|
+ try {
|
|
|
|
+ Map<String, Object> deviceStateMap= getDeviceStatus(dong, ho, endpointId);
|
|
|
|
+ Map<String, Object> statusMap = (HashMap)deviceStateMap.get(endpointId);
|
|
|
|
+ if(statusMap.containsKey("mode")) {
|
|
|
|
+ String mode = (String)statusMap.get("mode");
|
|
|
|
+
|
|
|
|
+ Document doc = new WallpadMsgSender().remoteGetAirconAttributes(dong, ho);
|
|
|
|
+ if(doc == null) {
|
|
|
|
+ logger.error("[ERROR]-[getAirconEnableTemperature]-[Document is Null] - [" + dong + "-" + ho + "]");
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ XPath xpath = XPathFactory.newInstance().newXPath();
|
|
|
|
+ Node iMap = (Node)xpath.evaluate("//imap/service", doc, XPathConstants.NODE);
|
|
|
|
+ String xmlResult = XmlUtil.getAttributeWithItem(iMap, "result");
|
|
|
|
+
|
|
|
|
+ logger.debug("[KakaoMsgHandler - private] - xmlResult -> " + xmlResult);
|
|
|
|
+
|
|
|
|
+ if(!xmlResult.equalsIgnoreCase("ok")) {
|
|
|
|
+// retMap.put(KEY_INFO.HTTP_KEY_ERROR, KAKAO_RESULT.getErrorInfo(KAKAO_RESULT.FAIL_UNREACHABLE));
|
|
|
|
+ logger.error("[KakaoMsgHandler - getAirconEnableTemperature] - [" + dong + "]-[" + ho + "] xmlResult not ok \r\n" + xmlResult);
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Node coolTempAttributes = (Node)xpath.evaluate("//imap/service/attributes/cool_temperature",doc, XPathConstants.NODE);
|
|
|
|
+ int minCoolTemperature = Integer.parseInt(XmlUtil.getAttributeWithItem(coolTempAttributes, "min"));
|
|
|
|
+ int maxCoolTemperature = Integer.parseInt(XmlUtil.getAttributeWithItem(coolTempAttributes, "max"));
|
|
|
|
+
|
|
|
|
+ Node heatTempAttributes = (Node)xpath.evaluate("//imap/service/attributes/heat_temperature",doc, XPathConstants.NODE);
|
|
|
|
+ int minHeatTemperature = Integer.parseInt(XmlUtil.getAttributeWithItem(heatTempAttributes, "min"));
|
|
|
|
+ int maxHeatTemperature = Integer.parseInt(XmlUtil.getAttributeWithItem(heatTempAttributes, "max"));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if(mode.equalsIgnoreCase("cool")) {
|
|
|
|
+ retMap.put("min", minCoolTemperature);
|
|
|
|
+ retMap.put("max", maxCoolTemperature);
|
|
|
|
+ }else if(mode.equalsIgnoreCase("heat")) {
|
|
|
|
+ retMap.put("min", minHeatTemperature);
|
|
|
|
+ retMap.put("max", maxHeatTemperature);
|
|
|
|
+ }else {
|
|
|
|
+ retMap.put("min", minCoolTemperature >= minHeatTemperature?minCoolTemperature:minHeatTemperature);
|
|
|
|
+ retMap.put("max", maxCoolTemperature <= maxHeatTemperature?maxCoolTemperature:maxHeatTemperature);
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ /// 에러처리..
|
|
|
|
+ logger.error("[ERROR]-[getAirconEnableTemperature]-["+dong+"]-["+ho+"]-["+endpointId+"]-" + deviceStateMap.toString());
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ }catch(Exception e) {
|
|
|
|
+ logger.error("[ERROR]-[getAirconEnableTemperature]-[Exception]-" + e.getMessage());
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ return retMap;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 동 호 정보 EndpointID 로 월패드에 상태 조회 메세지를 전송하고 결과를 반환 받는다.
|
|
* 동 호 정보 EndpointID 로 월패드에 상태 조회 메세지를 전송하고 결과를 반환 받는다.
|
|
* @param dong
|
|
* @param dong
|
|
@@ -357,7 +841,7 @@ public class KakaoMsgHandler {
|
|
* @param endpointId
|
|
* @param endpointId
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public Map<String, Object> getDeviceStatus(int dong, int ho, String endpointId){
|
|
|
|
|
|
+ public static Map<String, Object> getDeviceStatus(int dong, int ho, String endpointId){
|
|
Map<String, Object> retMap = new HashMap<String, Object>();
|
|
Map<String, Object> retMap = new HashMap<String, Object>();
|
|
String modelId = "";
|
|
String modelId = "";
|
|
int devNum = 1;
|
|
int devNum = 1;
|
|
@@ -438,7 +922,7 @@ public class KakaoMsgHandler {
|
|
return retMap;
|
|
return retMap;
|
|
}
|
|
}
|
|
|
|
|
|
- String action = KakaoMsgHandler.setDeviceActionStr(endpointId, modelId, actionName, desired);
|
|
|
|
|
|
+ String action = KakaoMsgHandler.setDeviceActionStr(dong, ho, endpointId, modelId, actionName, desired);
|
|
|
|
|
|
if(action.length() == 0) {
|
|
if(action.length() == 0) {
|
|
retMap.put(KEY_INFO.HTTP_KEY_ERROR, KAKAO_RESULT.getErrorInfo(KAKAO_RESULT.FAIL_INVALID_REQ));
|
|
retMap.put(KEY_INFO.HTTP_KEY_ERROR, KAKAO_RESULT.getErrorInfo(KAKAO_RESULT.FAIL_INVALID_REQ));
|
|
@@ -446,13 +930,23 @@ public class KakaoMsgHandler {
|
|
return retMap;
|
|
return retMap;
|
|
}
|
|
}
|
|
|
|
|
|
- Document doc = new WallpadMsgSender().remoteDeviceControl(
|
|
|
|
|
|
+ Document doc = null;
|
|
|
|
+ for(int i=0; i < 3; i++) {
|
|
|
|
+ doc = new WallpadMsgSender().remoteDeviceControl(
|
|
dong,
|
|
dong,
|
|
ho,
|
|
ho,
|
|
modelId,
|
|
modelId,
|
|
devNum,
|
|
devNum,
|
|
action
|
|
action
|
|
);
|
|
);
|
|
|
|
+ if(doc != null) break;
|
|
|
|
+ try {
|
|
|
|
+ Thread.sleep(500);
|
|
|
|
+ } catch (InterruptedException e) {
|
|
|
|
+ // TODO Auto-generated catch block
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
if(doc == null) {
|
|
if(doc == null) {
|
|
retMap.put(KEY_INFO.HTTP_KEY_ERROR, KAKAO_RESULT.getErrorInfo(KAKAO_RESULT.FAIL_UNREACHABLE));
|
|
retMap.put(KEY_INFO.HTTP_KEY_ERROR, KAKAO_RESULT.getErrorInfo(KAKAO_RESULT.FAIL_UNREACHABLE));
|
|
@@ -607,9 +1101,25 @@ public class KakaoMsgHandler {
|
|
case THINGS_INFO.THINGS_ELECPLUG:
|
|
case THINGS_INFO.THINGS_ELECPLUG:
|
|
jsonString = THINGS_INFO.THINGS_CAPABILITY.ELECTRIC.getCapJsonStr();
|
|
jsonString = THINGS_INFO.THINGS_CAPABILITY.ELECTRIC.getCapJsonStr();
|
|
break;
|
|
break;
|
|
|
|
+ case THINGS_INFO.THINGS_PARKING:
|
|
|
|
+ jsonString = THINGS_INFO.THINGS_CAPABILITY.PARKING.getCapJsonStr();
|
|
|
|
+ break;
|
|
|
|
+ case THINGS_INFO.THINGS_PARCEL:
|
|
|
|
+ jsonString = THINGS_INFO.THINGS_CAPABILITY.PARCEL.getCapJsonStr();
|
|
|
|
+ break;
|
|
|
|
+ case THINGS_INFO.THINGS_AIR_MONITOR:
|
|
|
|
+ jsonString = THINGS_INFO.THINGS_CAPABILITY.AIRSENSOR.getCapJsonStr();
|
|
|
|
+ break;
|
|
|
|
+ case THINGS_INFO.THINGS_AIRCON:
|
|
|
|
+ jsonString = THINGS_INFO.THINGS_CAPABILITY.AIRCON.getCapJsonStr();
|
|
|
|
+
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ logger.error("Can not found device capability - " + modelId + " - " + things.getEndPoint());
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
Map<String, Object> capabilities = CommonUtil.jsonToMap(jsonString);
|
|
Map<String, Object> capabilities = CommonUtil.jsonToMap(jsonString);
|
|
-
|
|
|
|
|
|
+ logger.info("[" + modelId + "]-endpoint - " + things.getEndPoint() + "-capability="+ capabilities.toString());
|
|
return capabilities;
|
|
return capabilities;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -618,6 +1128,8 @@ public class KakaoMsgHandler {
|
|
additionalPropMap.put(key, value);
|
|
additionalPropMap.put(key, value);
|
|
return additionalPropMap;
|
|
return additionalPropMap;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
public List<ThingsInfo> getChildThingsInfoList(int dong, int ho, int childCount, NodeList childList) {
|
|
public List<ThingsInfo> getChildThingsInfoList(int dong, int ho, int childCount, NodeList childList) {
|
|
List<ThingsInfo> thingsList = new ArrayList<>();
|
|
List<ThingsInfo> thingsList = new ArrayList<>();
|
|
|
|
|
|
@@ -685,10 +1197,12 @@ public class KakaoMsgHandler {
|
|
String cNodeName = XmlUtil.getAttributeWithItem(cNode, "name");
|
|
String cNodeName = XmlUtil.getAttributeWithItem(cNode, "name");
|
|
String cNodeDevNum = XmlUtil.getAttributeWithItem(cNode, "dev_num");
|
|
String cNodeDevNum = XmlUtil.getAttributeWithItem(cNode, "dev_num");
|
|
String status = XmlUtil.getElemetTextValue(cNode);
|
|
String status = XmlUtil.getElemetTextValue(cNode);
|
|
|
|
+ String[] strSplit = status.split("/");
|
|
|
|
+
|
|
String endpointId = cNodeName+"_"+cNodeDevNum;
|
|
String endpointId = cNodeName+"_"+cNodeDevNum;
|
|
|
|
|
|
if(cNodeName.contains("light")) {
|
|
if(cNodeName.contains("light")) {
|
|
- String[] strSplit = status.split("/");
|
|
|
|
|
|
+
|
|
// split 이 안됐다면 on off만 되는 예전 방식으로 전등 상태를 받았다는 뜻.
|
|
// split 이 안됐다면 on off만 되는 예전 방식으로 전등 상태를 받았다는 뜻.
|
|
if(strSplit.length > 1) {
|
|
if(strSplit.length > 1) {
|
|
if(!strSplit[1].equals("null") && strSplit[2].equals("null")) {
|
|
if(!strSplit[1].equals("null") && strSplit[2].equals("null")) {
|
|
@@ -702,8 +1216,8 @@ public class KakaoMsgHandler {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- String tmpModelId = cNodeName.equals("temper")?endpointId:cNodeName;
|
|
|
|
- logger.debug("tmpModelId = " + tmpModelId + " || endpointID = " + endpointId);
|
|
|
|
|
|
+ String tmpModelId = cNodeName.equals("temper") || cNodeName.equals("aircon") ?endpointId:cNodeName;
|
|
|
|
+ logger.debug("tmpModelId = " + tmpModelId + " || endpointID = " + endpointId + " || status = " + status);
|
|
|
|
|
|
|
|
|
|
THINGS_INFO.DEVICE_DETAIL detailDev = THINGS_INFO.getDeviceInfo(tmpModelId, status);
|
|
THINGS_INFO.DEVICE_DETAIL detailDev = THINGS_INFO.getDeviceInfo(tmpModelId, status);
|
|
@@ -714,15 +1228,16 @@ public class KakaoMsgHandler {
|
|
deviceInfo.put(KEY_INFO.BODY_KEY_NAME, detailDev.getDisplayName()+cNodeDevNum);
|
|
deviceInfo.put(KEY_INFO.BODY_KEY_NAME, detailDev.getDisplayName()+cNodeDevNum);
|
|
deviceInfo.put(KEY_INFO.BODY_KEY_DISPLAY_TYPE, detailDev.getDisplayType());
|
|
deviceInfo.put(KEY_INFO.BODY_KEY_DISPLAY_TYPE, detailDev.getDisplayType());
|
|
|
|
|
|
-
|
|
|
|
deviceInfo.putAll(getDeviceCapabilities(endpointId, status));
|
|
deviceInfo.putAll(getDeviceCapabilities(endpointId, status));
|
|
deviceInfo.put(KEY_INFO.BODY_KEY_STATE, setDeviceState(endpointId, status));
|
|
deviceInfo.put(KEY_INFO.BODY_KEY_STATE, setDeviceState(endpointId, status));
|
|
deviceInfo.put(KEY_INFO.BODY_KEY_ADDITIONALPROP, getAdditionalProp(KEY_INFO.BODY_KEY_ROOMPRESETNAME, detailDev.getRoomName()));
|
|
deviceInfo.put(KEY_INFO.BODY_KEY_ADDITIONALPROP, getAdditionalProp(KEY_INFO.BODY_KEY_ROOMPRESETNAME, detailDev.getRoomName()));
|
|
|
|
|
|
deviceMap.put(endpointId, deviceInfo);
|
|
deviceMap.put(endpointId, deviceInfo);
|
|
- deviceList.add(deviceMap);
|
|
|
|
|
|
|
|
|
|
+ if(!strSplit[0].equals("null"))
|
|
|
|
+ deviceList.add(deviceMap);
|
|
}catch(Exception e) {
|
|
}catch(Exception e) {
|
|
|
|
+ logger.error("[getChildDeviceInfo]-" + e.getMessage());
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -787,7 +1302,7 @@ public class KakaoMsgHandler {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
|
|
|
|
- public static String setDeviceActionStr(String endPointId, String modelId, String capability, Map<String, Object> desired) {
|
|
|
|
|
|
+ public static String setDeviceActionStr(int dong, int ho, String endPointId, String modelId, String capability, Map<String, Object> desired) {
|
|
StringBuffer sb = new StringBuffer();
|
|
StringBuffer sb = new StringBuffer();
|
|
|
|
|
|
THINGS_INFO.THINGS things = THINGS_INFO.getThingsType(endPointId);
|
|
THINGS_INFO.THINGS things = THINGS_INFO.getThingsType(endPointId);
|
|
@@ -809,43 +1324,46 @@ public class KakaoMsgHandler {
|
|
|
|
|
|
break;
|
|
break;
|
|
case THINGS_INFO.THINGS_LIGHT_DIMMER:
|
|
case THINGS_INFO.THINGS_LIGHT_DIMMER:
|
|
|
|
+ String [] arr_dimm_light_act = {"on", "null", "null"};
|
|
|
|
|
|
- if(capability.equals("Power") && desired.containsKey("power")) {
|
|
|
|
- String tmpState = (String)desired.get("power");
|
|
|
|
- if(tmpState.equals("on") || tmpState.equals("off")) {
|
|
|
|
- sb.append(tmpState);
|
|
|
|
- sb.append("/null/null");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ if(desired.containsKey("power"))
|
|
|
|
+ arr_dimm_light_act[0] = (String)desired.get("power");
|
|
|
|
+
|
|
|
|
|
|
if(desired.containsKey("brightness")) {
|
|
if(desired.containsKey("brightness")) {
|
|
- brightness = ((int)desired.get("brightness"))/10 == 0 ? 1: ((int)desired.get("brightness"))/10;
|
|
|
|
- sb.append("on").append("/").append(brightness).append("/null");
|
|
|
|
|
|
+// brightness = ((int)desired.get("brightness"))/10 == 0 ? 1: ((int)desired.get("brightness"))/10;
|
|
|
|
+ brightness = (int)desired.get("brightness");
|
|
|
|
+ if(brightness < 1)
|
|
|
|
+ arr_dimm_light_act[1] = Integer.toString(1);
|
|
|
|
+ else if(brightness > 10)
|
|
|
|
+ arr_dimm_light_act[1] = Integer.toString(10);
|
|
|
|
+ else
|
|
|
|
+ arr_dimm_light_act[1] = Integer.toString(brightness);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ sb.append(arr_dimm_light_act[0]).append("/")
|
|
|
|
+ .append(arr_dimm_light_act[1]).append("/")
|
|
|
|
+ .append(arr_dimm_light_act[2]);
|
|
break;
|
|
break;
|
|
|
|
|
|
case THINGS_INFO.THINGS_COLOR_LIGHT_DIMMER:
|
|
case THINGS_INFO.THINGS_COLOR_LIGHT_DIMMER:
|
|
|
|
+ String [] arr_color_dimm_light_act = {"on", "null", "null"};
|
|
|
|
|
|
- if(capability.equals("Power") && desired.containsKey("power")) {
|
|
|
|
- String tmpState = (String)desired.get("power");
|
|
|
|
- if(tmpState.equals("on") || tmpState.equals("off")) {
|
|
|
|
- sb.append(tmpState);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ if(desired.containsKey("power"))
|
|
|
|
+ arr_color_dimm_light_act[0] = (String)desired.get("power");
|
|
|
|
+
|
|
|
|
|
|
if(desired.containsKey("brightness")) {
|
|
if(desired.containsKey("brightness")) {
|
|
- brightness = ((int)desired.get("brightness"))/10 == 0 ? 1: ((int)desired.get("brightness"))/10;
|
|
|
|
- if(desired.containsKey("power"))
|
|
|
|
- sb.append("/").append(brightness);
|
|
|
|
|
|
+// brightness = ((int)desired.get("brightness"))/10 == 0 ? 1: ((int)desired.get("brightness"))/10;
|
|
|
|
+ brightness = (int)desired.get("brightness");
|
|
|
|
+ if(brightness < 1)
|
|
|
|
+ arr_color_dimm_light_act[1] = Integer.toString(1);
|
|
|
|
+ else if(brightness > 10)
|
|
|
|
+ arr_color_dimm_light_act[1] = Integer.toString(10);
|
|
else
|
|
else
|
|
- sb.append("on/").append(brightness);
|
|
|
|
- }else {
|
|
|
|
- sb.append("/null");
|
|
|
|
|
|
+ arr_color_dimm_light_act[1] = Integer.toString(brightness);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
if(desired.containsKey("colorTemperature")) {
|
|
if(desired.containsKey("colorTemperature")) {
|
|
// colorTemper = ((int)desired.get("colorTemperature"))/1000 == 0 ? 1:((int)desired.get("colorTemperature"))/1000;
|
|
// colorTemper = ((int)desired.get("colorTemperature"))/1000 == 0 ? 1:((int)desired.get("colorTemperature"))/1000;
|
|
int tmpColorTemp = (int)desired.get("colorTemperature");
|
|
int tmpColorTemp = (int)desired.get("colorTemperature");
|
|
@@ -854,22 +1372,12 @@ public class KakaoMsgHandler {
|
|
else if(tmpColorTemp > 5700) tmpColorTemp = 5700;
|
|
else if(tmpColorTemp > 5700) tmpColorTemp = 5700;
|
|
|
|
|
|
colorTemper = (tmpColorTemp)/300 - 9;
|
|
colorTemper = (tmpColorTemp)/300 - 9;
|
|
- if(desired.containsKey("power"))
|
|
|
|
- sb.append("/").append(colorTemper);
|
|
|
|
- else {
|
|
|
|
- if(desired.containsKey("brightness")) {
|
|
|
|
- sb.append("/").append(colorTemper);
|
|
|
|
- }else {
|
|
|
|
- sb = new StringBuffer();
|
|
|
|
- sb.append("on/null/").append(colorTemper);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- }else {
|
|
|
|
- sb.append("/null");
|
|
|
|
|
|
+ arr_color_dimm_light_act[2] = Integer.toString(colorTemper);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
+ sb.append(arr_color_dimm_light_act[0]).append("/")
|
|
|
|
+ .append(arr_color_dimm_light_act[1]).append("/")
|
|
|
|
+ .append(arr_color_dimm_light_act[2]);
|
|
break;
|
|
break;
|
|
|
|
|
|
case THINGS_INFO.THINGS_TEMPER:
|
|
case THINGS_INFO.THINGS_TEMPER:
|
|
@@ -895,23 +1403,20 @@ public class KakaoMsgHandler {
|
|
break;
|
|
break;
|
|
|
|
|
|
case THINGS_INFO.THINGS_VENTIL:
|
|
case THINGS_INFO.THINGS_VENTIL:
|
|
- if(capability.equals("Power") && desired.containsKey("power")) {
|
|
|
|
- String tmpState = (String)desired.get("power");
|
|
|
|
- if(tmpState.equals("on") || tmpState.equals("off")) sb.append(tmpState);
|
|
|
|
-
|
|
|
|
- if(tmpState.equals("on") && desired.containsKey("fanSpeed")) {
|
|
|
|
- String tmpFanSpeed = (String)desired.get("fanSpeed");
|
|
|
|
- if(tmpFanSpeed.equals("low") || tmpFanSpeed.equals("middle") || tmpFanSpeed.equals("high"))
|
|
|
|
- sb.append(desired.get("fanSpeed"));
|
|
|
|
- }
|
|
|
|
|
|
+ String []arr_ventil_act = {"on", "null"};
|
|
|
|
+ if(desired.containsKey("power")) {
|
|
|
|
+ arr_ventil_act[0] = (String) desired.get("power");
|
|
}
|
|
}
|
|
-
|
|
|
|
- if(capability.equals("AirFlow") && desired.containsKey("fanSpeed")) {
|
|
|
|
- String tmpFanSpeed = (String)desired.get("fanSpeed");
|
|
|
|
-
|
|
|
|
- if(tmpFanSpeed.equals("low") || tmpFanSpeed.equals("middle") || tmpFanSpeed.equals("high"))
|
|
|
|
- sb.append("on/").append(desired.get("fanSpeed"));
|
|
|
|
|
|
+ if(desired.containsKey("fanSpeed")) {
|
|
|
|
+ if("low".equals((String) desired.get("fanSpeed")))
|
|
|
|
+ arr_ventil_act[1] = "low";
|
|
|
|
+ else if("middle".equals((String) desired.get("fanSpeed")))
|
|
|
|
+ arr_ventil_act[1] = "mid";
|
|
|
|
+ else if("high".equals((String) desired.get("fanSpeed")))
|
|
|
|
+ arr_ventil_act[1] = "high";
|
|
}
|
|
}
|
|
|
|
+ sb.append(arr_ventil_act[0]).append("/")
|
|
|
|
+ .append(arr_ventil_act[1]);
|
|
break;
|
|
break;
|
|
|
|
|
|
case THINGS_INFO.THINGS_ELECPLUG: // 지원하지 않음
|
|
case THINGS_INFO.THINGS_ELECPLUG: // 지원하지 않음
|
|
@@ -928,15 +1433,103 @@ public class KakaoMsgHandler {
|
|
if("down".equalsIgnoreCase((String)desired.get("callDirection"))) {
|
|
if("down".equalsIgnoreCase((String)desired.get("callDirection"))) {
|
|
sb.append(desired.get("callDirection"));
|
|
sb.append(desired.get("callDirection"));
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ logger.info("[Elevator Call]-" + sb.toString());
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case THINGS_INFO.THINGS_AIRCON:
|
|
|
|
+ // 파워 설정온도 모드 풍속 풍향
|
|
|
|
+ String[] arr_aircon_act = {"on", "null", "null", "null", "null"};
|
|
|
|
+
|
|
|
|
+ if(desired.containsKey("power")) arr_aircon_act[0] = (String) desired.get("power");
|
|
|
|
+
|
|
|
|
+ if(desired.containsKey("targetSetpoint")) {
|
|
|
|
+ Map<String, Object> tempMap = getAirconEnableTemperature(dong, ho, endPointId);
|
|
|
|
+ int minTemp = (int) tempMap.get("min");
|
|
|
|
+ int maxTemp = (int) tempMap.get("max");
|
|
|
|
+ double dobReqTemp = (double) desired.get("targetSetpoint");
|
|
|
|
+ int reqTemp = (int) dobReqTemp;
|
|
|
|
+
|
|
|
|
+// int reqTemp = ((Double) desired.get("targetSetpoint")).intValue();
|
|
|
|
+ if(reqTemp < minTemp) arr_aircon_act[1] = Integer.toString(minTemp);
|
|
|
|
+ else if(reqTemp > maxTemp) arr_aircon_act[1] = Integer.toString(maxTemp);
|
|
|
|
+ else arr_aircon_act[1] = Integer.toString(reqTemp);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if(desired.containsKey("mode")) {
|
|
|
|
+ String modeVal = (String) desired.get("mode");
|
|
|
|
+
|
|
|
|
+ if(modeVal.equals("auto"))
|
|
|
|
+ arr_aircon_act[2] = "auto";
|
|
|
|
+ else if(modeVal.equals("cool"))
|
|
|
|
+ arr_aircon_act[2] = "cool";
|
|
|
|
+ else if(modeVal.equals("heat"))
|
|
|
|
+ arr_aircon_act[2] = "heat";
|
|
|
|
+ else if(modeVal.equals("dehumidify"))
|
|
|
|
+ arr_aircon_act[2] = "dehum";
|
|
|
|
+ else if(modeVal.equals("fan_only"))
|
|
|
|
+ arr_aircon_act[2] = "fan";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(desired.containsKey("fanSpeed")) {
|
|
|
|
+ String modeVal = (String) desired.get("fanSpeed");
|
|
|
|
+
|
|
|
|
+ if(modeVal.equals("auto"))
|
|
|
|
+ arr_aircon_act[3] = "auto";
|
|
|
|
+ else if(modeVal.equals("low"))
|
|
|
|
+ arr_aircon_act[3] = "low";
|
|
|
|
+ else if(modeVal.equals("middle"))
|
|
|
|
+ arr_aircon_act[3] = "mid";
|
|
|
|
+ else if(modeVal.equals("high"))
|
|
|
|
+ arr_aircon_act[3] = "high";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ sb.append(arr_aircon_act[0]).append("/");
|
|
|
|
+ sb.append(arr_aircon_act[1]).append("/");
|
|
|
|
+ sb.append(arr_aircon_act[2]).append("/");
|
|
|
|
+ sb.append(arr_aircon_act[3]).append("/null");
|
|
|
|
+
|
|
|
|
+ logger.info("[aircon]-action str = " + sb.toString());
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
}catch(Exception e) {
|
|
}catch(Exception e) {
|
|
-
|
|
|
|
|
|
+ logger.error("[Action Str Error]-" + e.getMessage());
|
|
|
|
+ e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
|
|
return sb.toString();
|
|
return sb.toString();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private static int getAirQuaility(String type, int value) {
|
|
|
|
+ switch(type) {
|
|
|
|
+ case "co2":
|
|
|
|
+ if(value < 1001)
|
|
|
|
+ return 0;
|
|
|
|
+ else if(value <= 1001 && value < 1501)
|
|
|
|
+ return 1;
|
|
|
|
+ else if(value <= 1501 && value < 3001)
|
|
|
|
+ return 2;
|
|
|
|
+ else return 3;
|
|
|
|
+ case "pm10":
|
|
|
|
+ if(value < 31)
|
|
|
|
+ return 0;
|
|
|
|
+ else if(value <= 31 && value < 81)
|
|
|
|
+ return 1;
|
|
|
|
+ else if(value <= 81 && value < 150)
|
|
|
|
+ return 2;
|
|
|
|
+ else return 3;
|
|
|
|
+ case "pm2_5":
|
|
|
|
+ if(value < 16)
|
|
|
|
+ return 0;
|
|
|
|
+ else if(value <= 16 && value < 36)
|
|
|
|
+ return 1;
|
|
|
|
+ else if(value <= 36 && value < 76)
|
|
|
|
+ return 2;
|
|
|
|
+ else return 3;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
/**
|
|
/**
|
|
* 상태조회 이후 월패드에서 받은 상태 값을 디바이스의 속성에 맞게 파싱하고
|
|
* 상태조회 이후 월패드에서 받은 상태 값을 디바이스의 속성에 맞게 파싱하고
|
|
* Map에 <"속성명", "상태값"> 형태로 담아준다.
|
|
* Map에 <"속성명", "상태값"> 형태로 담아준다.
|
|
@@ -949,6 +1542,9 @@ public class KakaoMsgHandler {
|
|
|
|
|
|
THINGS_INFO.THINGS things = THINGS_INFO.getThingsType(modelId);
|
|
THINGS_INFO.THINGS things = THINGS_INFO.getThingsType(modelId);
|
|
String[] splitStr = status.split("\\/");
|
|
String[] splitStr = status.split("\\/");
|
|
|
|
+
|
|
|
|
+ if(splitStr[0].equals("null")) return state;
|
|
|
|
+
|
|
int temp1, temp2 = 0;
|
|
int temp1, temp2 = 0;
|
|
switch(things.getEndPoint()) {
|
|
switch(things.getEndPoint()) {
|
|
case THINGS_INFO.THINGS_ELECPLUG:
|
|
case THINGS_INFO.THINGS_ELECPLUG:
|
|
@@ -965,7 +1561,7 @@ public class KakaoMsgHandler {
|
|
if(splitStr.length == 1) break;
|
|
if(splitStr.length == 1) break;
|
|
|
|
|
|
if(splitStr[1] != null && !splitStr[1].equals("null")) {
|
|
if(splitStr[1] != null && !splitStr[1].equals("null")) {
|
|
- temp1 = Integer.parseInt(splitStr[1]) * 10;
|
|
|
|
|
|
+ temp1 = Integer.parseInt(splitStr[1]);
|
|
state.put("brightness", temp1);
|
|
state.put("brightness", temp1);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -976,10 +1572,13 @@ public class KakaoMsgHandler {
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
case THINGS_INFO.THINGS_TEMPER:
|
|
case THINGS_INFO.THINGS_TEMPER:
|
|
|
|
+ Double targetTemp = Double.parseDouble(splitStr[1]);
|
|
|
|
+ Double currTemp = Double.parseDouble(splitStr[2]);
|
|
|
|
|
|
state.put("power", splitStr[0]);
|
|
state.put("power", splitStr[0]);
|
|
- state.put("targetSetpoint", Double.parseDouble(splitStr[1]));
|
|
|
|
- state.put("currentTemperature", Double.parseDouble(splitStr[2]));
|
|
|
|
|
|
+ state.put("targetSetpoint", Double.valueOf(targetTemp.intValue()));
|
|
|
|
+ state.put("currentTemperature", Double.valueOf(currTemp.intValue()));
|
|
|
|
+
|
|
|
|
|
|
break;
|
|
break;
|
|
case THINGS_INFO.THINGS_GAS:
|
|
case THINGS_INFO.THINGS_GAS:
|
|
@@ -1000,6 +1599,53 @@ public class KakaoMsgHandler {
|
|
case THINGS_INFO.THINGS_ELEVATOR:
|
|
case THINGS_INFO.THINGS_ELEVATOR:
|
|
state.put("callDirection", "down");
|
|
state.put("callDirection", "down");
|
|
break;
|
|
break;
|
|
|
|
+ case THINGS_INFO.THINGS_AIR_MONITOR:
|
|
|
|
+
|
|
|
|
+ int val_co2 = (int) Double.parseDouble(splitStr[0]);
|
|
|
|
+ int val_pm10 = (int) Double.parseDouble(splitStr[1]);
|
|
|
|
+ int val_pm2_5 = (int) Double.parseDouble(splitStr[2]);
|
|
|
|
+
|
|
|
|
+ int qual_co2 = getAirQuaility("co2", val_co2);
|
|
|
|
+ int qual_pm10 = getAirQuaility("pm10", val_pm10);
|
|
|
|
+ int qual_pm2_5 = getAirQuaility("pm2_5", val_pm2_5);
|
|
|
|
+
|
|
|
|
+ String[] arr_quality = {"good", "moderate", "unhealthy", "very_unhealth"};
|
|
|
|
+ int avg_qual = (qual_co2 + qual_pm10 + qual_pm2_5)/3;
|
|
|
|
+ String qualityIndex = arr_quality[avg_qual];
|
|
|
|
+
|
|
|
|
+ state.put("co2", val_co2);
|
|
|
|
+ state.put("pm10", val_pm10);
|
|
|
|
+ state.put("pm2_5", val_pm2_5);
|
|
|
|
+ state.put("qualityIndex", qualityIndex);
|
|
|
|
+ break;
|
|
|
|
+ case THINGS_INFO.THINGS_AIRCON:
|
|
|
|
+ logger.info("[에어컨 상태]-"+ status);
|
|
|
|
+
|
|
|
|
+ String power = splitStr[0].equalsIgnoreCase("removeheat")?"off":splitStr[0];
|
|
|
|
+ int set_temp = splitStr.length > 1 ? Integer.parseInt(splitStr[1]):0;
|
|
|
|
+ int cur_temp = splitStr.length > 2 ?Integer.parseInt(splitStr[2]):0;
|
|
|
|
+ String mode = splitStr.length > 3 ? splitStr[3]:null;
|
|
|
|
+ String airFlow = splitStr.length > 4 ? splitStr[4]:null;
|
|
|
|
+
|
|
|
|
+ state.put("power", power);
|
|
|
|
+ state.put("targetSetpoint", set_temp);
|
|
|
|
+ state.put("currentTemperature", cur_temp);
|
|
|
|
+
|
|
|
|
+ if(mode != null) {
|
|
|
|
+ if(mode.equals("auto")) state.put("mode", "auto");
|
|
|
|
+ else if(mode.equals("cool")) state.put("mode", "cool");
|
|
|
|
+ else if(mode.equals("heat")) state.put("mode", "heat");
|
|
|
|
+ else if(mode.equals("dehum")) state.put("mode", "dehumidify");
|
|
|
|
+ else if(mode.equals("fan")) state.put("mode", "fan_only");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(airFlow != null) {
|
|
|
|
+ if(airFlow.equals("auto")) state.put("fanSpeed", "auto");
|
|
|
|
+ else if(airFlow.equals("low")) state.put("fanSpeed", "low");
|
|
|
|
+ else if(airFlow.equals("mid")) state.put("fanSpeed", "middle");
|
|
|
|
+ else if(airFlow.equals("high")) state.put("fanSpeed", "high");
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
|
|
|
|
return state;
|
|
return state;
|