private SmartThingsService GetSmartThingsService() { OauthInfo authInfo = OauthRepository.Get(); if (authInfo == null | authInfo.endpoints == null || authInfo.endpoints.Count == 0) { throw new Exception("OAuth endpoints have not been created. Cannot update smart things at this time"); } string url = authInfo.endpoints[0].uri; string token = authInfo.accessToken; SmartThingsService service = new SmartThingsService(token, url); return(service); }
public async Task <IActionResult> Devices() { OauthInfo authInfo = OauthRepository.Get(); if (authInfo == null | authInfo.endpoints == null || authInfo.endpoints.Count == 0) { throw new Exception("OAuth endpoints have not been created. Cannot update smart things at this time"); } string url = authInfo.endpoints[0].uri; string token = authInfo.accessToken; SmartThingsService service = new SmartThingsService(token, url); var devices = await service.ListDevices(); return(View(devices)); }