Beispiel #1
0
        public void SendMessage(Lamp lampState)
        {
            WebClient webClient = new WebClient();
            webClient.BaseAddress = "http://" + bridgeIP + "/api/" + username + "/lights/" + lampState.GetLampNumber() + "/state";

            Stream writeData = webClient.OpenWrite(webClient.BaseAddress, "PUT");
            writeData.Write(Encoding.ASCII.GetBytes(lampState.GetJson()), 0, lampState.GetJson().Length);
            writeData.Close();
        }
Beispiel #2
0
        public void ChangeLampState(Lamp lamp, Delegate stateChange)
        {
            if (lamp == null)
            {
                return;
            }

            stateChange.DynamicInvoke(lamp);

            messaging.SendMessage(lamp);
        }
Beispiel #3
0
        public Lamp ConvertToHueLamp(int lampNumber)
        {
            JsonLamp jsonLamp = null;
            lights.TryGetValue(lampNumber, out jsonLamp);

            if (jsonLamp != null)
            {
                Lamp lamp = new Lamp(lampNumber, jsonLamp.name, jsonLamp.state.on, jsonLamp.state.GetHueAsDegree(), jsonLamp.state.GetSaturation(), jsonLamp.state.GetBrightness());
                return lamp;
            }

            return null;
        }