public async Task <IActionResult> CreateSmartApp(OauthInfo authInfo) { if (ModelState.IsValid == false) { return(View(authInfo)); } var conn = new SmartThingsConnection(); if (await conn.Login(authInfo.STUserId, authInfo.STPassword) == false) { ModelState.AddModelError("STPassword", "Could not connect to smart things using the supplied credentials"); return(View("Index", authInfo)); } var cs = new DeviceTypeRepository(conn, "j64 Alarm", $"{myEnv.WebRootPath}/../SmartThingApps/j64AlarmDevice.groovy"); var ss = new DeviceTypeRepository(conn, "j64 Contact Zone", $"{myEnv.WebRootPath}/../SmartThingApps/j64ContactZoneDevice.groovy"); var mz = new DeviceTypeRepository(conn, "j64 Motion Zone", $"{myEnv.WebRootPath}/../SmartThingApps/j64MotionZoneDevice.groovy"); var pd = new DeviceTypeRepository(conn, "j64 Partition", $"{myEnv.WebRootPath}/../SmartThingApps/j64PartitionDevice.groovy"); var jal = new SmartAppRepository(conn, "j64 Alarm", $"{myEnv.WebRootPath}/../SmartThingApps/j64AlarmSmartApp.groovy"); // Save the client/secret keys var oauth = OauthRepository.Get(); oauth.clientKey = jal.clientKey; oauth.secretKey = jal.secretKey; OauthRepository.Save(oauth); return(View("Index", oauth)); }
public async Task <IActionResult> CreateSmartApp(OauthViewModel authInfo) { if (ModelState.IsValid == false) { return(View(authInfo)); } var conn = new SmartThingsConnection(); if (await conn.Login(authInfo.STUserId, authInfo.STPassword) == false) { ModelState.AddModelError("STPassword", "Could not connect to smart things using the supplied credentials"); return(View("Index", authInfo)); } var cs = new DeviceTypeRepository(conn, "j64 Channel Switch", $"{myEnv.WebRootPath}/../SmartThingApps/j64ChannelSwitchDevice.groovy"); var ss = new DeviceTypeRepository(conn, "j64 Surfing Switch", $"{myEnv.WebRootPath}/../SmartThingApps/j64SurfingSwitchDevice.groovy"); var vs = new DeviceTypeRepository(conn, "j64 VCR Switch", $"{myEnv.WebRootPath}/../SmartThingApps/j64VcrSwitchDevice.groovy"); var os = new DeviceTypeRepository(conn, "j64 Volume Switch", $"{myEnv.WebRootPath}/../SmartThingApps/j64VolumeSwitchDevice.groovy"); var cc = new DeviceTypeRepository(conn, "j64 Custom Command Switch", $"{myEnv.WebRootPath}/../SmartThingApps/j64CustomCommandSwitchDevice.groovy"); var har = new SmartAppRepository(conn, "j64 Harmony", $"{myEnv.WebRootPath}/../SmartThingApps/j64HarmonySmartApp.groovy"); // Save the client/secret keys var oauth = OauthRepository.Get(); oauth.clientKey = har.clientKey; oauth.secretKey = har.secretKey; OauthRepository.Save(oauth); var ovm = new OauthViewModel() { ClientKey = oauth.clientKey, SecretKey = oauth.secretKey }; return(View("Index", ovm)); }