/// <summary> /// Get the specified object freom the bridge in async. /// </summary> /// <typeparam name="T">Type of object to deserialize to</typeparam> /// <param name="id">Id of the object to get</param> /// <returns>BridgeCommResult</returns> public async Task <T> GetObjectAsync <T>(string id) where T : IHueObject { string typename = typeof(T).Name.ToLower() + "s"; if (typename == string.Empty || typename == "s") { return(default(T)); } string url = BridgeUrl + $"/{typename}/{id}"; HttpResult comres = await HueHttpClient.SendRequestAsyncTask(new Uri(url), WebRequestType.Get); if (comres.Success) { T data = Serializer.DeserializeToObject <T>(comres.Data); if (data != null) { data.Id = id; return(data); } LastCommandMessages.AddMessage(Serializer.DeserializeToObject <List <IMessage> >(comres.Data)); return(default(T)); } BridgeNotResponding?.Invoke(this, new BridgeNotRespondingEventArgs(this, url, WebExceptionStatus.NameResolutionFailure)); return(default(T)); }
public async Task <bool> SetPowerCustomSettingsAsyncTask(PowerCustomSettings state, string id) { HttpResult comres; string url = BridgeUrl + $"/lights/{id}/config/"; if (!Virtual) { comres = await HueHttpClient.SendRequestAsyncTask(new Uri(url), WebRequestType.Put, "{\"startup\": { \"customsettings\" : " + Serializer.SerializeJsonObject(state) + "}}"); if (comres.Success) { LastCommandMessages.AddMessage(Serializer.DeserializeToObject <List <IMessage> >(comres.Data)); return(LastCommandMessages.Success); } } else { LastCommandMessages.AddMessage(new Success() { Address = url, value = state.ToString() }); return(LastCommandMessages.Success); } return(false); }
/// <summary> /// Set the Power configuration mode of the light. /// </summary> /// <param name="powermode">Power mode : powerfail or Safety</param> /// <param name="id">Id of the bulb</param> /// <returns>True or false</returns> public async Task <bool> SetPowerConfigAsyncTask(string powermode, string id) { HttpResult comres; string url = BridgeUrl + $"/lights/{id}/config"; if (!Virtual) { comres = await HueHttpClient.SendRequestAsyncTask(new Uri(url), WebRequestType.Put, "{\"startup\" : {\"mode\" : \"" + powermode + "\"}}"); if (comres.Success) { LastCommandMessages.AddMessage(Serializer.DeserializeToObject <List <IMessage> >(comres.Data)); return(LastCommandMessages.Success); } } else { LastCommandMessages.AddMessage(new Success() { Address = url, value = powermode }); return(LastCommandMessages.Success); } return(false); }
/// <summary> /// Get all the timezones that are supported by the bridge. /// </summary> /// <returns>a list of all the timezones supported by the bridge.</returns> public async Task <List <string> > GetTimeZonesAsyncTask() { Version api = Version.Parse(ApiVersion); Version limit = Version.Parse("1.15.0"); if (api > limit) { Capabilities cap = await GetBridgeCapabilitiesAsyncTask(); return(cap?.timezones.values); } else { HttpResult comres = await HueHttpClient.SendRequestAsyncTask(new Uri(BridgeUrl + "/info/timezones"), WebRequestType.Get); if (comres.Success) { List <string> timezones = Serializer.DeserializeToObject <List <string> >(comres.Data); if (timezones != null) { return(timezones); } LastCommandMessages.AddMessage(Serializer.DeserializeToObject <List <IMessage> >(comres.Data)); return(null); } BridgeNotResponding?.Invoke(this, new BridgeNotRespondingEventArgs(this, BridgeUrl + "/info/timezones", WebExceptionStatus.NameResolutionFailure)); return(null); } }
/// <summary> /// Activate a scene async. /// </summary> /// <param name="id">Id of the scene.</param> /// <returns>BridgeHttpResult</returns> public async Task <bool> ActivateSceneAsyncTask(string id) { string url = BridgeUrl + "/groups/0/action"; HttpResult comres; if (!Virtual) { comres = await HueHttpClient.SendRequestAsyncTask(new Uri(url), WebRequestType.Put, "{\"scene\":\"" + id + "\"}"); if (comres.Success) { LastCommandMessages.AddMessage(Serializer.DeserializeToObject <List <IMessage> >(comres.Data)); return(LastCommandMessages.Success); } } else { LastCommandMessages.AddMessage(new Success() { Address = url, value = $"Set Virtual scene : {id}" }); return(LastCommandMessages.Success); } BridgeNotResponding?.Invoke(this, new BridgeNotRespondingEventArgs(this, url, WebExceptionStatus.NameResolutionFailure)); return(false); }
/// <summary> /// Set the light state of a scene async. /// </summary> /// <param name="sceneid">Id of the scene.</param> /// <param name="lightid">Id of the light.</param> /// <param name="state">State of the light.</param> /// <returns>BrideHttpResult</returns> public async Task <bool> SetSceneLightStateAsyncTask(string sceneid, string lightid, IBaseProperties state) { string url = BridgeUrl + $"/scenes/{sceneid}/lightstates/{lightid}"; HttpResult comres; if (!Virtual) { comres = await HueHttpClient.SendRequestAsyncTask(new Uri(url), WebRequestType.Put, Serializer.ModifyJsonObject(state)); if (comres.Success) { LastCommandMessages.AddMessage(Serializer.DeserializeToObject <List <IMessage> >(comres.Data)); return(LastCommandMessages.Success); } } else { LastCommandMessages.AddMessage(new Success() { Address = url, value = $"Set Virtual scene state : {sceneid}, {lightid}, {state.ToString()}" }); return(LastCommandMessages.Success); } BridgeNotResponding?.Invoke(this, new BridgeNotRespondingEventArgs(this, url, WebExceptionStatus.NameResolutionFailure)); return(false); }
/// <summary> /// Remove the specified object from the bridge async. /// </summary> /// <typeparam name="T">HueObject (Light,Group,Sensor,Rule,Schedule,Scene)</typeparam> /// <param name="obj">Object to modify</param> /// <returns>HueObject (Light,Group,Sensor,Rule,Schedule,Scene)</returns> public async Task <bool> RemoveObjectAsyncTask(IHueObject obj) { string typename = obj.GetType().Name.ToLower() + "s"; string url = BridgeUrl + $@"/{typename}/{obj.Id}"; HttpResult comres; if (!Virtual) { comres = await HueHttpClient.SendRequestAsyncTask(new Uri(url), WebRequestType.Delete); if (comres.Success) { return(LastCommandMessages.Success); } } else { LastCommandMessages.AddMessage(new Success() { Address = url, value = $"Deleted Virtual object : {obj.ToString()}" }); return(LastCommandMessages.Success); } BridgeNotResponding?.Invoke(this, new BridgeNotRespondingEventArgs(this, url, WebExceptionStatus.NameResolutionFailure)); return(false); }
/// <summary> /// Modify the specified object in the bridge. /// </summary> /// <typeparam name="T">HueObject (Light,Group,Sensor,Rule,Schedule,Scene)</typeparam> /// <param name="modifiedobject">The new modified object.</param> /// <param name="id">Id of the object.</param> /// <returns>BridgeHttpResult</returns> public async Task <bool> ModifyObjectAsyncTask(IHueObject modifiedobject) { string typename = modifiedobject.GetType().Name.ToLower() + "s"; IHueObject clone = (IHueObject)modifiedobject.Clone(); string url = BridgeUrl + $@"/{typename}/{modifiedobject.Id}"; if (typename == null) { return(false); } HttpResult comres; if (!Virtual) { comres = await HueHttpClient.SendRequestAsyncTask(new Uri(url), WebRequestType.Put, Serializer.ModifyJsonObject(modifiedobject)); if (comres.Success) { LastCommandMessages.AddMessage(Serializer.DeserializeToObject <List <IMessage> >(comres.Data)); return(LastCommandMessages.Success); } } else { LastCommandMessages.AddMessage(new Success() { Address = url, value = $"Modified Virtual object : {modifiedobject.ToString()}" }); return(LastCommandMessages.Success); } BridgeNotResponding?.Invoke(this, new BridgeNotRespondingEventArgs(this, url, WebExceptionStatus.NameResolutionFailure)); return(false); }
/// <summary> /// Change the sensor's state. /// </summary> /// <param name="id">id of the sensor</param> /// <param name="newstate">New state of the sensor</param> /// <returns>Success or error</returns> public async Task <bool> ChangeSensorStateAsyncTask(string id, object newstate) { string url = BridgeUrl + $@"/sensors/{id}/state"; HttpResult comres; if (!Virtual) { comres = await HueHttpClient.SendRequestAsyncTask(new Uri(url), WebRequestType.Put, Serializer.ModifyJsonObject(newstate)); if (comres.Success) { LastCommandMessages.AddMessage(Serializer.DeserializeToObject <List <IMessage> >(comres.Data)); return(LastCommandMessages.Success); } } else { LastCommandMessages.AddMessage(new Success() { Address = url, value = $"Modified Virtual sensor state : {id},{newstate.ToString()}" }); return(LastCommandMessages.Success); } BridgeNotResponding?.Invoke(this, new BridgeNotRespondingEventArgs(this, url, WebExceptionStatus.NameResolutionFailure)); return(false); }
/// <summary> /// Get a list of specified objects from the bridge async. /// </summary> /// <typeparam name="T">HueObject (Light,Group,Sensor,Rule,Schedule,Scene)</typeparam> /// <returns>BridgeCommResult</returns> public async Task <List <T> > GetListObjectsAsync <T>(bool showmyhidden = false, bool getgroupzero = false) where T : IHueObject { string typename = typeof(T).Name.ToLower() + "s"; string url = BridgeUrl + $"/{typename}"; HttpResult comres = await HueHttpClient.SendRequestAsyncTask(new Uri(url), WebRequestType.Get); if (comres.Success) { Dictionary <string, T> data = Serializer.DeserializeToObject <Dictionary <string, T> >(comres.Data); if (data != null) { List <T> listdata = data.Select(x => { x.Value.Id = x.Key; return(x.Value); }).ToList(); if (!showmyhidden) { RemoveHiddenObjects(ref listdata, WinHueSettings.bridges.BridgeInfo[Mac].hiddenobjects); } if (typeof(T) == typeof(Group) && getgroupzero) { listdata.Add(await GetObjectAsync <T>("0")); } if (typeof(T) == typeof(Scene) && !WinHueSettings.settings.ShowHiddenScenes) { listdata.RemoveAll(x => x.GetType() == typeof(Scene) && x.name.StartsWith("HIDDEN")); } return(data.Select(x => { x.Value.Id = x.Key; return x.Value; }).ToList()); } LastCommandMessages.AddMessage(Serializer.DeserializeToObject <List <IMessage> >(comres.Data)); return(null); } BridgeNotResponding?.Invoke(this, new BridgeNotRespondingEventArgs(this, url, WebExceptionStatus.NameResolutionFailure)); return(null); }
/// <summary> /// Set Entertrainment Group stream status /// </summary> /// <param name="id">ID of the group</param> /// <param name="status">Status of the stream</param> /// <returns></returns> public async Task <bool> SetEntertrainementGroupStreamStatus(string id, bool status) { string url = BridgeUrl + $@"/groups/{id}"; HttpResult comres; if (!Virtual) { comres = await HueHttpClient.SendRequestAsyncTask(new Uri(url), WebRequestType.Put, "{\"stream\":{\"active\":" + status.ToString().ToLower() + "}}"); if (comres.Success) { LastCommandMessages.AddMessage(Serializer.DeserializeToObject <List <IMessage> >(comres.Data)); return(LastCommandMessages.Success); } } else { LastCommandMessages.AddMessage(new Success() { Address = url, value = $"Update Light location for group : {id}" }); return(LastCommandMessages.Success); } BridgeNotResponding?.Invoke(this, new BridgeNotRespondingEventArgs(this, url, WebExceptionStatus.NameResolutionFailure)); return(false); }
public async Task <bool> TouchLink() { HttpResult comres = await HueHttpClient.SendRequestAsyncTask(new Uri(BridgeUrl + "/config"), WebRequestType.Put, "{\"touchlink\":true}"); if (comres.Success) { LastCommandMessages.AddMessage(Serializer.DeserializeToObject <List <IMessage> >(comres.Data)); return(true); } BridgeNotResponding?.Invoke(this, new BridgeNotRespondingEventArgs(this, BridgeUrl + "/config", WebExceptionStatus.NameResolutionFailure)); return(false); }
/// <summary> /// Allows the user to set some configuration values. /// </summary> /// <param name="settings">Settings of the bridge.</param> /// <return>The new settings of the bridge.</return> public async Task <bool> SetBridgeSettingsAsyncTask(BridgeSettings settings) { HttpResult comres = await HueHttpClient.SendRequestAsyncTask(new Uri(BridgeUrl + "/config"), WebRequestType.Put, Serializer.ModifyJsonObject(settings)); if (comres.Success) { LastCommandMessages.AddMessage(Serializer.DeserializeToObject <List <IMessage> >(comres.Data)); return(LastCommandMessages.Success); } BridgeNotResponding?.Invoke(this, new BridgeNotRespondingEventArgs(this, BridgeUrl + "/config", WebExceptionStatus.NameResolutionFailure)); return(false); }
/// <summary> /// Try to contact the specified bridge to get the basic config. /// </summary> /// <param name="BridgeIP">IP Address of the bridge.</param> /// <returns>The basic configuration of the bridge.</returns> public async Task <BasicConfig> GetBridgeBasicConfigAsyncTask() { string url = BridgeUrl + "/config"; HttpResult comres = await HueHttpClient.SendRequestAsyncTask(new Uri(url), WebRequestType.Get); if (comres.Success) { BasicConfig config = Serializer.DeserializeToObject <BasicConfig>(comres.Data); return(config); } BridgeNotResponding?.Invoke(this, new BridgeNotRespondingEventArgs(this, url, WebExceptionStatus.NameResolutionFailure)); return(null); }
public async Task <bool> RemoveUserAsyncTask(string username) { string url = BridgeUrl + "/config/whitelist/" + username; HttpResult comres = await HueHttpClient.SendRequestAsyncTask(new Uri(url), WebRequestType.Delete); if (comres.Success) { LastCommandMessages.AddMessage(Serializer.DeserializeToObject <List <IMessage> >(comres.Data)); return(LastCommandMessages.Success); } BridgeNotResponding?.Invoke(this, new BridgeNotRespondingEventArgs(this, url, WebExceptionStatus.NameResolutionFailure)); return(false); }
public async Task <bool> StartNewObjectsSearchAsyncTask(Type objecttype) { string typename = objecttype.Name.ToLower() + "s"; HttpResult comres = await HueHttpClient.SendRequestAsyncTask(new Uri(BridgeUrl + $"/{typename}"), WebRequestType.Post); if (comres.Success) { LastCommandMessages.AddMessage(Serializer.DeserializeToObject <List <IMessage> >(comres.Data)); return(true); } BridgeNotResponding?.Invoke(this, new BridgeNotRespondingEventArgs(this, BridgeUrl + $"/{typename}", WebExceptionStatus.NameResolutionFailure)); return(false); }
/// <summary> /// Send a raw json command to the bridge without altering the bridge lastmessages /// </summary> /// <param name="url">url to send the command to.</param> /// <param name="data">raw json data string</param> /// <param name="type">type of command.</param> /// <returns>json test resulting of the command.</returns> public async Task <string> SendRawCommandAsyncTask(string url, string data, WebRequestType type) { HttpResult comres = await HueHttpClient.SendRequestAsyncTask(new Uri(url), type, data); if (comres.Success) { if (type != WebRequestType.Get) { LastCommandMessages.AddMessage(Serializer.DeserializeToObject <List <IMessage> >(comres.Data)); } return(comres.Data); } BridgeNotResponding?.Invoke(this, new BridgeNotRespondingEventArgs(this, url, WebExceptionStatus.NameResolutionFailure)); return(null); }
/// <summary> /// Tell the bridge to store the current state of the lights of the scene. /// </summary> /// <param name="id">ID of the scene.</param> /// <returns>BrideHttpResult</returns> public async Task <bool> StoreCurrentLightStateAsyncTask(string id) { string url = BridgeUrl + $"/scenes/{id}"; HttpResult comres = await HueHttpClient.SendRequestAsyncTask(new Uri(url), WebRequestType.Put, Serializer.ModifyJsonObject(new Scene() { storelightstate = true })); if (comres.Success) { LastCommandMessages.AddMessage(Serializer.DeserializeToObject <List <IMessage> >(comres.Data)); return(LastCommandMessages.Success); } BridgeNotResponding?.Invoke(this, new BridgeNotRespondingEventArgs(this, url, WebExceptionStatus.NameResolutionFailure)); return(false); }
/// <summary> /// Creates a new user / Register a new user. The link button on the bridge must be pressed and this command executed within 30 seconds. /// </summary> /// <returns>Contains a list with a single item that details whether the user was added successfully along with the username parameter. Note: If the requested username already exists then the response will report a success.</returns> /// <param name="deviceType">Description of the type of device associated with this username. This field must contain the name of your app.</param> /// <return>The new API Key.</return> public async Task <string> CreateUserAsyncTask(string deviceType) { string url = "http://" + _ipAddress + "/api"; HttpResult comres = await HueHttpClient.SendRequestAsyncTask(new Uri(url), WebRequestType.Post, Serializer.CreateJsonObject(new User() { devicetype = deviceType })); if (comres.Success) { LastCommandMessages.AddMessage(Serializer.DeserializeToObject <List <IMessage> >(comres.Data)); return(LastCommandMessages.Success ? LastCommandMessages.LastSuccess.value : null); } BridgeNotResponding?.Invoke(this, new BridgeNotRespondingEventArgs(this, url, WebExceptionStatus.NameResolutionFailure)); return(null); }
/// <summary> /// Set the state of a light or group on the bridge. /// </summary> /// <typeparam name="T">Any class the derives from CommonProperties</typeparam> /// <param name="state">New state of the object.</param> /// <param name="id">ID of the specified object.</param> /// <returns>BridgeHttpResult</returns> public async Task <bool> SetStateAsyncTask(IBaseProperties state, string id) { string typename = null; string type = null; if (state is State) { typename = "lights"; type = "state"; } if (state is Action) { typename = "groups"; type = "action"; } if (typename == null) { return(false); } string url = BridgeUrl + $@"/{typename}/{id}/{type}"; HttpResult comres; if (!Virtual) { comres = await HueHttpClient.SendRequestAsyncTask(new Uri(url), WebRequestType.Put, Serializer.ModifyJsonObject(state)); if (comres.Success) { LastCommandMessages.AddMessage(Serializer.DeserializeToObject <List <IMessage> >(comres.Data)); return(LastCommandMessages.Success); } } else { LastCommandMessages.AddMessage(new Success() { Address = url, value = state.ToString() }); return(LastCommandMessages.Success); } BridgeNotResponding?.Invoke(this, new BridgeNotRespondingEventArgs(this, url, WebExceptionStatus.NameResolutionFailure)); return(false); }
/// <summary> /// Get the list of users. /// </summary> /// <returns>The List of user or null on error.</returns> public async Task <Dictionary <string, Whitelist> > GetUserListAsyncTask() { string url = BridgeUrl + "/config"; HttpResult comres = await HueHttpClient.SendRequestAsyncTask(new Uri(url), WebRequestType.Get); if (comres.Success) { BridgeSettings brs = Serializer.DeserializeToObject <BridgeSettings>(comres.Data); if (brs != null) { return(brs.whitelist); } LastCommandMessages.AddMessage(Serializer.DeserializeToObject <List <IMessage> >(comres.Data)); return(null); } BridgeNotResponding?.Invoke(this, new BridgeNotRespondingEventArgs(this, url, WebExceptionStatus.NameResolutionFailure)); return(null); }
public async Task <bool> SetAutoInstallAsyncTask(autoinstall autoinstall) { Version api = Version.Parse(ApiVersion); Version limit = Version.Parse("1.20.0"); if (api < limit) { return(false); } HttpResult comres = await HueHttpClient.SendRequestAsyncTask(new Uri(BridgeUrl + "/config"), WebRequestType.Put, "{\"swupdate2\": {\"autoinstall\" : " + Serializer.SerializeJsonObject(autoinstall) + "}}"); if (comres.Success) { LastCommandMessages.AddMessage(Serializer.DeserializeToObject <List <IMessage> >(comres.Data)); return(LastCommandMessages.Success); } BridgeNotResponding?.Invoke(this, new BridgeNotRespondingEventArgs(this, BridgeUrl + "/config", WebExceptionStatus.NameResolutionFailure)); return(false); }
/// <summary> /// Update the bridge firmware async. /// </summary> /// <returns>True or False command sent succesfully.</returns> public async Task <bool> UpdateBridgeAsyncTask() { Version api = Version.Parse(ApiVersion); Version limit = Version.Parse("1.20.0"); string updatestring = ""; updatestring = api > limit ? "{\"swupdate2\": {\"install\": true}}" : "{\"swupdate\":{\"updatestate\":3}}"; HttpResult comres = await HueHttpClient.SendRequestAsyncTask(new Uri(BridgeUrl + "/config"), WebRequestType.Put, updatestring); if (comres.Success) { LastCommandMessages.AddMessage(Serializer.DeserializeToObject <List <IMessage> >(comres.Data)); return(LastCommandMessages.Success); } BridgeNotResponding?.Invoke(this, new BridgeNotRespondingEventArgs(this, BridgeUrl + "/config", WebExceptionStatus.NameResolutionFailure)); return(false); }
/// <summary> /// Get Bridge Capabilities Async /// </summary> /// <returns></returns> public async Task <Capabilities> GetBridgeCapabilitiesAsyncTask() { Version api = Version.Parse(ApiVersion); Version limit = Version.Parse("1.15.0"); if (api < limit) { return(null); } string url = BridgeUrl + "/capabilities"; HttpResult comres = await HueHttpClient.SendRequestAsyncTask(new Uri(url), WebRequestType.Get); if (comres.Success) { Capabilities cap = Serializer.DeserializeToObject <Capabilities>(comres.Data); return(cap); } BridgeNotResponding?.Invoke(this, new BridgeNotRespondingEventArgs(this, url, WebExceptionStatus.NameResolutionFailure)); return(null); }
/// <summary> /// Force the bridge to check online for an update async. /// </summary> /// <returns>True or false if the operation is successful (does not return if there is an update)</returns> public async Task <bool> CheckOnlineForUpdateAsyncTask() { Version api = Version.Parse(ApiVersion); Version limit = Version.Parse("1.20.0"); string swu = "swupdate"; if (api > limit) { swu = swu + "2"; } HttpResult comres = await HueHttpClient.SendRequestAsyncTask(new Uri(BridgeUrl + "/config"), WebRequestType.Put, "{\"" + swu + "\": {\"checkforupdate\": true}}"); if (comres.Success) { LastCommandMessages.AddMessage(Serializer.DeserializeToObject <List <IMessage> >(comres.Data)); return(LastCommandMessages.Success); } BridgeNotResponding?.Invoke(this, new BridgeNotRespondingEventArgs(this, BridgeUrl + "/config", WebExceptionStatus.NameResolutionFailure)); return(false); }
/// <summary> /// Get All objects from the bridge /// </summary> /// <param name="showmyhidden">Show users hidden objects</param> /// <param name="getgroupzero">Show group zero</param> /// <returns></returns> public async Task <List <IHueObject> > GetAllObjectsAsync(bool showmyhidden = false, bool getgroupzero = false) { List <IHueObject> huelist = new List <IHueObject>(); string url = BridgeUrl + $"/"; HttpResult comres = await HueHttpClient.SendRequestAsyncTask(new Uri(url), WebRequestType.Get); if (comres.Success) { DataStore data = Serializer.DeserializeToObject <DataStore>(comres.Data); if (data != null) { List <IHueObject> listdata = data.ToList(); if (!showmyhidden) { RemoveHiddenObjects(ref listdata, WinHueSettings.bridges.BridgeInfo[Mac].hiddenobjects); } if (getgroupzero) { listdata.Add(await GetObjectAsync <Group>("0")); } if (!WinHueSettings.settings.ShowHiddenScenes) { listdata.RemoveAll(x => x.GetType() == typeof(Scene) && x.name.StartsWith("HIDDEN")); } return(listdata); } LastCommandMessages.AddMessage(Serializer.DeserializeToObject <List <IMessage> >(comres.Data)); return(null); } BridgeNotResponding?.Invoke(this, new BridgeNotRespondingEventArgs(this, url, WebExceptionStatus.NameResolutionFailure)); return(huelist); }
public async Task <bool> FindNewLightsAsync(string serialslist = null) { LightSearchSerial lsl = new LightSearchSerial(); if (serialslist != null) { string[] serials = serialslist.Split(','); foreach (string s in serials) { lsl.deviceid.Add(s); } } HttpResult comres = await HueHttpClient.SendRequestAsyncTask(new Uri(BridgeUrl + $"/lights"), WebRequestType.Post, lsl.deviceid.Count == 0? "" : Serializer.SerializeJsonObject(lsl)); if (comres.Success) { LastCommandMessages.AddMessage(Serializer.DeserializeToObject <List <IMessage> >(comres.Data)); return(true); } BridgeNotResponding?.Invoke(this, new BridgeNotRespondingEventArgs(this, BridgeUrl + $"/lights", WebExceptionStatus.NameResolutionFailure)); return(false); }
/// <summary> /// Check if there is an update available on the bridge async. (Does not force the bridge to check for an update) /// </summary> /// <returns>Software Update or null.</returns> public async Task <bool> CheckUpdateAvailableAsyncTask() { HttpResult comres = await HueHttpClient.SendRequestAsyncTask(new Uri(BridgeUrl + "/config"), WebRequestType.Get); if (comres.Success) { BridgeSettings brs = Serializer.DeserializeToObject <BridgeSettings>(comres.Data); if (brs != null) { if (brs.swupdate.updatestate == 2) { UpdateAvailable = true; return(true); } return(false); } else { LastCommandMessages.AddMessage(Serializer.DeserializeToObject <List <IMessage> >(HueHttpClient.LastJson)); } } BridgeNotResponding?.Invoke(this, new BridgeNotRespondingEventArgs(this, BridgeUrl + "/config", WebExceptionStatus.NameResolutionFailure)); return(false); }