/// <summary> /// /// </summary> /// <param name="deviceId"></param> /// <param name="commandData"></param> /// <param name="result"></param> private void setPreset(Guid deviceId, Dictionary<string, object> commandData, HaDeviceCommandResult result) { // Get data from the commanddata if (commandData != null && commandData.ContainsKey("presetIndex")) { int presetIndex; if (int.TryParse(commandData["presetIndex"].ToString(), out presetIndex)) { var device = getHaDevice(deviceId) as CameraDevice; if (device != null) { var url = device.getPresetSetUrl(presetIndex); doHtmlGet(url, device.ip); } else { result.success = false; result.message = "Device not found."; } } else { result.success = false; result.message = "presetIndex is not an integer!"; } } else { result.success = false; result.message = "presetIndex data not found!"; } }
/// <summary> /// /// </summary> /// <param name="deviceId"></param> /// <param name="jsonCommandData"></param> /// <returns></returns> public HaDeviceCommandResult processCommand(Guid deviceId, HaDeviceCommand jsonCommandData) { var result = new HaDeviceCommandResult() { success = true }; HaCameraCommands cameraCommand; // Make sure it's a valid commandType if (Enum.TryParse<HaCameraCommands>(jsonCommandData.commandType, out cameraCommand)) { switch (cameraCommand) { case HaCameraCommands.gotoPreset: gotoPreset(deviceId, jsonCommandData.commandData, result); break; case HaCameraCommands.setPreset: setPreset(deviceId, jsonCommandData.commandData, result); break; } } else { result.success = false; result.message = "Invalid command type " + jsonCommandData.commandType; } return result; }