-
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e40c5fa
commit c7100f7
Showing
6 changed files
with
197 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Linq; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System.Configuration; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Q42.HueApi.Interfaces; | ||
|
||
namespace Q42.HueApi.Tests | ||
{ | ||
[TestClass] | ||
public class CapabilitiesTest | ||
{ | ||
private IHueClient _client; | ||
|
||
[TestInitialize] | ||
public void Initialize() | ||
{ | ||
string ip = ConfigurationManager.AppSettings["ip"].ToString(); | ||
string key = ConfigurationManager.AppSettings["key"].ToString(); | ||
|
||
_client = new LocalHueClient(ip, key); | ||
} | ||
|
||
[TestMethod] | ||
public async Task GetCapabilitiesTest() | ||
{ | ||
var result = await _client.GetCapabilitiesAsync(); | ||
|
||
Assert.IsNotNull(result); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
using Q42.HueApi.Models; | ||
using Q42.HueApi.Models.Groups; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net.Http; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Q42.HueApi | ||
{ | ||
/// <summary> | ||
/// Partial HueClient, contains requests to the /config/ url | ||
/// </summary> | ||
public partial class HueClient | ||
{ | ||
|
||
/// <summary> | ||
/// Get bridge capabilities | ||
/// </summary> | ||
/// <returns></returns> | ||
public async Task<BridgeCapabilities> GetCapabilitiesAsync() | ||
{ | ||
CheckInitialized(); | ||
|
||
HttpClient client = await GetHttpClient().ConfigureAwait(false); | ||
var stringResult = await client.GetStringAsync(new Uri(ApiBase + "capabilities")).ConfigureAwait(false); | ||
|
||
BridgeCapabilities capabilities = DeserializeResult<BridgeCapabilities>(stringResult); | ||
|
||
return capabilities; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Q42.HueApi.Models | ||
{ | ||
public class BridgeCapabilities | ||
{ | ||
public LightsCapability Lights { get; set; } | ||
public SensorsCapability Sensors { get; set; } | ||
public GroupsCapability Groups { get; set; } | ||
public ScenesCapability Scenes { get; set; } | ||
public SchedulesCapability Schedules { get; set; } | ||
public RulesCapability Rules { get; set; } | ||
public ResourceLinksCapability Resourcelinks { get; set; } | ||
public Timezones Timezones { get; set; } | ||
|
||
} | ||
|
||
public class LightsCapability : Capability | ||
{ | ||
} | ||
|
||
public class ClipCapability : Capability | ||
{ | ||
} | ||
|
||
public class ZllCapability : Capability | ||
{ | ||
} | ||
|
||
public class ZgpCapability : Capability | ||
{ | ||
} | ||
|
||
public class SensorsCapability : Capability | ||
{ | ||
/// <summary> | ||
/// Capability information of resources which are directly created by POST | ||
/// </summary> | ||
public ClipCapability Clip { get; set; } | ||
|
||
/// <summary> | ||
/// Capability information of Zigbee resources which are discovered by POST | ||
/// </summary> | ||
public ZllCapability Zll { get; set; } | ||
|
||
/// <summary> | ||
/// Capability information of ZGP resources which are discovered by POST | ||
/// </summary> | ||
public ZgpCapability Zgp { get; set; } | ||
} | ||
|
||
public class GroupsCapability : Capability | ||
{ | ||
} | ||
|
||
public class LightstatesCapability : Capability | ||
{ | ||
} | ||
|
||
public class ScenesCapability : Capability | ||
{ | ||
/// <summary> | ||
/// Represents the total pool of individual lightsstates (scene setting per lamp) which can be used across all scenes in /scenes/lightstates | ||
/// </summary> | ||
public LightstatesCapability Lightstates { get; set; } | ||
} | ||
|
||
public class SchedulesCapability : Capability | ||
{ | ||
} | ||
|
||
public class ConditionsCapability : Capability | ||
{ | ||
} | ||
|
||
public class ActionsCapability : Capability | ||
{ | ||
} | ||
|
||
public class RulesCapability : Capability | ||
{ | ||
public ConditionsCapability Conditions { get; set; } | ||
|
||
/// <summary> | ||
/// Represents the total pool of individual actions which can be used across all rules in /rules/actions | ||
/// </summary> | ||
public ActionsCapability Actions { get; set; } | ||
} | ||
|
||
public class ResourceLinksCapability : Capability | ||
{ | ||
|
||
} | ||
|
||
public class Timezones | ||
{ | ||
/// <summary> | ||
/// List of supported time zones represented as tz database strings. Each value can be set in /config/timezone. Other values are not supported. | ||
/// </summary> | ||
public List<string> Values { get; set; } | ||
} | ||
|
||
public abstract class Capability | ||
{ | ||
/// <summary> | ||
/// Total (maximum) number of resources which still can be created by POST on this resource path. The number of creatable resources for a specific subresource type might be lower. | ||
/// </summary> | ||
public int Available { get; set; } | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters