public BridgeTests()
        {
            hueDotNetconfigurationReader = new Implementation.HueDotNetConfigurationReader();

            bridgeQuery = new Implementation.BridgeQuery();
            bridgeCommand = new Implementation.BridgeCommand(hueDotNetconfigurationReader);

            lightQuery = new Implementation.LightQuery(hueDotNetconfigurationReader);
            lightSwitch = new Implementation.LightSwitch(hueDotNetconfigurationReader, lightQuery);
            colourQuery = new Implementation.ColourQuery();
            lightColourSwitch = new Implementation.LightColourSwitch(hueDotNetconfigurationReader, lightQuery, colourQuery);
            lightDimmerSwitch = new Implementation.LightDimmerSwitch(hueDotNetconfigurationReader, lightQuery);
            lightFlashSwitch = new Implementation.LightFlashSwitch(hueDotNetconfigurationReader);
            lightColourLoopSwitch = new Implementation.LightColourLoopSwitch(hueDotNetconfigurationReader);

            groupQuery = new Implementation.GroupQuery(hueDotNetconfigurationReader);
        }
Exemplo n.º 2
0
 public LightSwitch( IHueDotNetConfigurationReader hueConfiguration, ILightQuery lightQuery)
 {
     HueConfiguration = hueConfiguration;
     LightQuery = lightQuery;
 }
Exemplo n.º 3
0
 public LightQuery(IHueDotNetConfigurationReader hueConfiguration)
 {
     HueConfiguration = hueConfiguration;
 }
Exemplo n.º 4
0
 public List<Light> FindNewLightsAsync(IHueDotNetConfigurationReader hueDotNetconfigurationReader)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 5
0
 public GroupQuery(IHueDotNetConfigurationReader hueConfiguration)
 {
     HueConfiguration = hueConfiguration;
 }
Exemplo n.º 6
0
        public async Task<bool> TurnAllOffAsync(IHueDotNetConfigurationReader hueDotNetconfigurationReader)
        {
            using (var client = new HttpClient())
            {
                Uri RequestUri = new Uri("http://" + hueDotNetconfigurationReader.BridgeAddress + "/api/" + hueDotNetconfigurationReader.UserName + "/groups/0/action");

                StringContent requestContent = new StringContent("{\"on\" : false}");

                HttpRequestMessage request = new HttpRequestMessage { Method = HttpMethod.Put, RequestUri = RequestUri, Content = requestContent };
                HttpResponseMessage response = await client.SendAsync(request);
            }

            return true;
        }
Exemplo n.º 7
0
 public Task<bool> RenameLightAsync(IHueDotNetConfigurationReader hueDotNetconfigurationReader, string oldLightName, string newLightName)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 8
0
        public async Task<Dictionary<string, Light>> GetLightsAsync(IHueDotNetConfigurationReader hueDotNetconfigurationReader)
        {
            Dictionary<string, Light> lights = new Dictionary<string, Light>();

            using (var client = new HttpClient())
            {
                client.BaseAddress = new System.Uri("http://" + hueDotNetconfigurationReader.BridgeAddress);

                HttpResponseMessage response = await client.GetAsync("/api/" + hueDotNetconfigurationReader.UserName + "/lights");

                if (response.IsSuccessStatusCode)
                {
                    string responseString = await response.Content.ReadAsStringAsync();

                    lights = JsonConvert.DeserializeObject<Dictionary<string, Light>>(responseString);

                    // assign id property to each light
                    foreach (var keyvalue in lights)
                    {
                        ((Light)(keyvalue.Value)).ID = keyvalue.Key;
                    }
                }

            }


            return lights;
        }
Exemplo n.º 9
0
        public async Task<bool> TurnOffAsync(IHueDotNetConfigurationReader hueDotNetconfigurationReader, string lightName)
        {
            bool isOff = false;

            Light light = await this.GetLightAsync(hueDotNetconfigurationReader, lightName);

            if (light != null)
            {
                if (!light.State.On)
                {
                    return true;
                }

                using (var client = new HttpClient())
                {
                    Uri RequestUri = new Uri("http://" + hueDotNetconfigurationReader.BridgeAddress + "/api/" + hueDotNetconfigurationReader.UserName + "/lights/" + light.ID + "/state");

                    StringContent requestContent = new StringContent("{\"on\" : false}");

                    HttpRequestMessage request = new HttpRequestMessage { Method = HttpMethod.Put, RequestUri = RequestUri, Content = requestContent };
                    HttpResponseMessage response = await client.SendAsync(request);

                    if (response.IsSuccessStatusCode)
                    {
                        light = await this.GetLightAsync(hueDotNetconfigurationReader,  lightName);
                        if (light != null)
                        {
                            isOff = !light.State.On;
                        }
                    }
                }
            }

            return isOff;
        }
Exemplo n.º 10
0
        public async Task<Light> GetLightAsync(IHueDotNetConfigurationReader hueDotNetconfigurationReader, string lightName)
        {
            Light light = new Light();
            Dictionary<string, Light> lights = await this.GetLightsAsync(hueDotNetconfigurationReader);

            foreach (Light candidateLight in lights.Values)
            {
                if (candidateLight.Name.Equals(lightName, StringComparison.CurrentCultureIgnoreCase))
                {
                    light = candidateLight;
                    break;
                }
            }

            return light;
        }
 public LightColourLoopSwitch(IHueDotNetConfigurationReader hueConfiguration)
 {
     HueConfiguration = hueConfiguration;
 }
Exemplo n.º 12
0
 public BridgeCommand(IHueDotNetConfigurationReader hueConfiguration)
 {
     HueConfiguration = hueConfiguration;
 }
Exemplo n.º 13
0
 public LightFlashSwitch(IHueDotNetConfigurationReader hueConfiguration)
 {
     HueConfiguration = hueConfiguration;
 }
Exemplo n.º 14
0
 public LightColourSwitch(IHueDotNetConfigurationReader hueConfiguration, ILightQuery lightQuery, IColourQuery colourQuery)
 {
     HueConfiguration = hueConfiguration;
     LightQuery = lightQuery;
     ColourQuery = colourQuery;
 }