use of org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.impl.JSONDeviceSceneSpecImpl in project smarthome by eclipse.
the class DeviceImpl method saveConfigSceneSpecificationIntoDevice.
@SuppressWarnings("null")
@Override
public void saveConfigSceneSpecificationIntoDevice(String propertries) {
String[] scenes = propertries.split("\n");
for (int i = 0; i < scenes.length; i++) {
logger.debug("Find saved scene configuration for device with dSID {} and sceneID {}", dsid, i);
String[] sceneIdToConfig = scenes[i].replaceAll(" ", "").split("=");
String[] sceneParm = sceneIdToConfig[1].split(",");
JSONDeviceSceneSpecImpl sceneSpecNew = null;
int sceneValue = -1;
int sceneAngle = -1;
for (int j = 0; j < sceneParm.length; j++) {
String[] sceneParmSplit = sceneParm[j].split(":");
switch(sceneParmSplit[0]) {
case "Scene":
sceneSpecNew = new JSONDeviceSceneSpecImpl(sceneParmSplit[1]);
break;
case "dontcare":
sceneSpecNew.setDontcare(Boolean.parseBoolean(sceneParmSplit[1]));
break;
case "localPrio":
sceneSpecNew.setLocalPrio(Boolean.parseBoolean(sceneParmSplit[1]));
break;
case "specialMode":
sceneSpecNew.setSpecialMode(Boolean.parseBoolean(sceneParmSplit[1]));
break;
case "sceneValue":
sceneValue = Integer.parseInt(sceneParmSplit[1]);
break;
case "sceneAngle":
sceneAngle = Integer.parseInt(sceneParmSplit[1]);
break;
}
}
if (sceneValue > -1) {
logger.debug("Saved sceneValue {}, sceneAngle {} for scene id {} into device with dsid {}", sceneValue, sceneAngle, i, getDSID().getValue());
synchronized (sceneOutputMap) {
sceneOutputMap.put(sceneSpecNew.getScene().getSceneNumber(), new Integer[] { sceneValue, sceneAngle });
}
}
if (sceneSpecNew != null) {
logger.debug("Saved sceneConfig: [{}] for scene id {} into device with dsid {}", sceneSpecNew.toString(), i, getDSID().getValue());
synchronized (sceneConfigMap) {
sceneConfigMap.put(sceneSpecNew.getScene().getSceneNumber(), sceneSpecNew);
}
}
}
}
use of org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.impl.JSONDeviceSceneSpecImpl in project smarthome by eclipse.
the class DsAPIImpl method getDeviceSceneMode.
@Override
public DeviceSceneSpec getDeviceSceneMode(String token, DSID dSID, String dSUID, String name, Short sceneID) {
if (checkRequiredDevice(dSID, dSUID, name) && SimpleRequestBuilder.objectToString(sceneID) != null) {
String response = transport.execute(SimpleRequestBuilder.buildNewRequest(InterfaceKeys.JSON).addRequestClass(ClassKeys.DEVICE).addFunction(FunctionKeys.GET_SCENE_MODE).addDefaultDeviceParameter(token, dSID, dSUID, name).addParameter(ParameterKeys.SCENE_ID, SimpleRequestBuilder.objectToString(sceneID)).buildRequestString());
JsonObject responseObj = JSONResponseHandler.toJsonObject(response);
if (JSONResponseHandler.checkResponse(responseObj)) {
JsonObject sceneSpec = JSONResponseHandler.getResultJsonObject(responseObj);
if (sceneSpec != null) {
return new JSONDeviceSceneSpecImpl(sceneSpec);
}
}
}
return null;
}
use of org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.impl.JSONDeviceSceneSpecImpl in project smarthome by eclipse.
the class DeviceImpl method saveConfigSceneSpecificationIntoDevice.
@SuppressWarnings("null")
@Override
public void saveConfigSceneSpecificationIntoDevice(Map<String, String> propertries) {
if (propertries != null) {
String sceneSave;
for (String key : propertries.keySet()) {
if (key.startsWith(DigitalSTROMBindingConstants.DEVICE_SCENE)) {
try {
short sceneID = Short.parseShort((String) key.subSequence(DigitalSTROMBindingConstants.DEVICE_SCENE.length(), key.length()));
sceneSave = propertries.get(key);
if (StringUtils.isNotBlank(sceneSave)) {
logger.debug("Find saved scene configuration for device with dSID {} and sceneID {}", dsid, key);
String[] sceneParm = sceneSave.replace(" ", "").split(",");
JSONDeviceSceneSpecImpl sceneSpecNew = null;
int sceneValue = -1;
int sceneAngle = -1;
for (int j = 0; j < sceneParm.length; j++) {
String[] sceneParmSplit = sceneParm[j].split(":");
switch(sceneParmSplit[0]) {
case "Scene":
sceneSpecNew = new JSONDeviceSceneSpecImpl(sceneParmSplit[1]);
break;
case "dontcare":
sceneSpecNew.setDontcare(Boolean.parseBoolean(sceneParmSplit[1]));
break;
case "localPrio":
sceneSpecNew.setLocalPrio(Boolean.parseBoolean(sceneParmSplit[1]));
break;
case "specialMode":
sceneSpecNew.setSpecialMode(Boolean.parseBoolean(sceneParmSplit[1]));
break;
case "sceneValue":
sceneValue = Integer.parseInt(sceneParmSplit[1]);
break;
case "sceneAngle":
sceneAngle = Integer.parseInt(sceneParmSplit[1]);
break;
}
}
if (sceneValue > -1) {
logger.debug("Saved sceneValue {}, sceneAngle {} for scene id {} into device with dsid {}", sceneValue, sceneAngle, sceneID, getDSID().getValue());
internalSetSceneOutputValue(sceneID, sceneValue, sceneAngle);
deviceStateUpdates.add(new DeviceStateUpdateImpl(DeviceStateUpdate.UPDATE_SCENE_OUTPUT, new Short[] { sceneID, (short) -1 }));
}
if (sceneSpecNew != null) {
logger.debug("Saved sceneConfig: [{}] for scene id {} into device with dsid {}", sceneSpecNew.toString(), sceneID, getDSID().getValue());
synchronized (sceneConfigMap) {
sceneConfigMap.put(sceneID, sceneSpecNew);
}
deviceStateUpdates.add(new DeviceStateUpdateImpl(DeviceStateUpdate.UPDATE_SCENE_CONFIG, new Short[] { sceneID, (short) -1 }));
}
}
} catch (NumberFormatException e) {
// ignore
}
}
}
}
}
Aggregations