Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public IActionResult Index()
        {
            if (myHub.hubConfig == null || String.IsNullOrEmpty(j64Config.ChannelDevice) || String.IsNullOrEmpty(j64Config.VolumeDevice))
                return RedirectToAction("Edit", "FirstTimeConfig");

            var oauth = OauthRepository.Get();
            var ovm = new OauthViewModel()
            {
                ClientKey = oauth.clientKey,
                SecretKey = oauth.secretKey
            };

            return View(ovm);
        }