public HueLightButton(IGameBox gameBox, IHueClient hueClient, Light light, ILightableButton lightableButton)
 {
     this.gameBox         = gameBox;
     this.hueClient       = hueClient;
     this.light           = light;
     this.lightableButton = lightableButton;
 }
Example #2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="hueClient">The client to use for communication with the Philips Hue</param>
 public VisualNotificationController(IHueClient hueClient)
 {
     _hueClient = hueClient;
     _lamps     = new List <string> {
         "1"
     };
 }
Example #3
0
        public void Initialize()
        {
            string ip  = ConfigurationManager.AppSettings["ip"].ToString();
            string key = ConfigurationManager.AppSettings["key"].ToString();

            _client = new HueClient(ip, key);
        }
    public void Initialize()
    {
      string ip = ConfigurationManager.AppSettings["ip"].ToString();
      string key = ConfigurationManager.AppSettings["key"].ToString();

      _client = new HueClient(ip, key);
    }
Example #5
0
		public static void UpdateLights(IHueClient client, IList<Light> list)
		{
			Parallel.ForEach(list, light =>
			{
				Light initLight = client.GetLightAsync(light.Id).Result;
				initLight.Id = light.Id;
				list[list.IndexOf(light)] = initLight;
			});
		}
        //hue connection
        public async void InitializeHue()
        {
            string ip  = ConfigurationManager.AppSettings["ip"].ToString();
            string key = ConfigurationManager.AppSettings["key"].ToString();

            HueKey = key;

            if (ip.Length == 0 || key.Length == 0)
            {
                await GetConfig();
            }
            while (key.Length == 0)
            {
                //do nothing
            }
            _client = new LocalHueClient(ip, key);
        }
Example #7
0
        public async Task InitializeAsync()
        {
            List <LocatedBridge> bridges = await HueBridgeDiscovery.FastDiscoveryAsync(TimeSpan.FromSeconds(5));

            LocatedBridge locatedBridge = bridges.First();

            if (string.IsNullOrEmpty(_appKey))
            {
                throw new NotImplementedException("Registering application is not yet implemented");
            }

            LocalHueClient hueClient = new LocalHueClient(locatedBridge.IpAddress, _appKey);

            if (!await hueClient.CheckConnection())
            {
                throw new Exception("Could not establish connection to bridge");
            }

            _hueClient = hueClient;
        }
Example #8
0
 public LightsManager(IClient hueClient)
 {
     _hueClient = hueClient.GetClient();
 }
Example #9
0
		public HomeController(IHueClient hueClient)
		{
			_hueClient = hueClient;
		}
Example #10
0
 public LightsController(IHueClient hueClient, IList<Light> lightList)
 {
     _hueClient = hueClient;
     _lightList = lightList;
 }
Example #11
0
        protected async override void OnAppearing()
        {
            CrossDeviceMotion.Current.SensorValueChanged += (sender, e) => {
                CompassLabel.Text = "" + e.Value;
            };

            CrossCompass.Current.CompassChanged += async(sender, e) => {
                CompassLabel.Text = "" + e.Heading;

                if (Math.Abs(e.Heading - lastHeading) < 5)
                {
                    return;
                }
                lastHeading = e.Heading;

                try{
                    if (e.Heading > 180 && e.Heading < 360)
                    {
                        var quadracticValue = (e.Heading - 360) * (e.Heading - 180) * -1 / 8100.0;
                        var command         = GetBrightnesCommand((byte)(quadracticValue * 255));
                        var idx             = LightList.SelectedIndex;
                        await client.SendCommandAsync(command, new [] {
                            MyLights.ElementAt(idx).Id
                        });
                    }
                    else
                    {
                        var command = GetBrightnesCommand(0);
                        await client.SendCommandAsync(command, new [] { "4" });
                    }
                }catch (Exception ayy) {
                    CrossTextToSpeech.Current.Speak("Hey! Slow down. Bro.");
                }
            };

            if (client == null)
            {
                client = await GetClient();

                if (client == null)
                {
                    return;
                }
            }

                        #if !DEBUG
            if (MyScenes == null)
            {
                MyScenes = await client.GetScenesAsync();

                foreach (var light in MyScenes)
                {
                    SceneList.Items.Add(light.Name);
                }
                SceneList.SelectedIndex         = 0;
                SceneList.SelectedIndexChanged += async(object sender, EventArgs e) => {
                    var scene = MyScenes.ElementAt(SceneList.SelectedIndex);
                };
            }
                        #endif

            if (MyLights == null)
            {
                MyLights = await client.GetLightsAsync();

                foreach (var light in MyLights)
                {
                    LightList.Items.Add(light.Name);
                }
                LightList.SelectedIndex = 0;
                CrossCompass.Current.Start();
                //CrossDeviceMotion.Current.Start(MotionSensorType.Gyroscope, MotionSensorDelay.Ui);
            }
        }
Example #12
0
 public ReleaseNightScenario(IHueClient hueClient)
 {
     _hueClient = hueClient;
 }
Example #13
0
		public LightsController(IHueClient hueClient, IEnumerable<string> lightList)
		{
			_hueClient = hueClient;
			_lightList = lightList;
		}
Example #14
0
		public static void UpdateLight(IHueClient client, Light light)
		{
			light = client.GetLightAsync(light.Id).Result;
		}
Example #15
0
	public void InValidHueIpTest()
	{
		_client = new HueClient("//127.0.0@@.1in.v.alid");
	}
Example #16
0
	public void ValidHueIpTest()
	{
		_client = new HueClient("127.0.0.1");

		Assert.IsNotNull(_client);
	}
Example #17
0
 public RedAlertScenario(IHueClient hueClient)
 {
     _hueClient = hueClient;
 }
Example #18
0
 public ActionProcessor(IHueClient hueClient)
 {
     _hueClient = hueClient;
 }