Exemplo n.º 1
0
        /// <summary>
        /// Das zusammen gefügte Json-Kommando and die Bridge senden
        /// D.h.: on/off,Brightness,.........lampState..)
        /// </summary>
        /// <param name="lampState"></param>
        public void SendMessage(HueLamp lampState)
        {
            WebClient webClient = new WebClient();
            webClient.BaseAddress = "http://" + bridgeIP + "/api/" + username + "/lights/" + lampState.GetLampNumber() + "/state";
            String json = lampState.GetJson();

            Stream writeData = webClient.OpenWrite(webClient.BaseAddress, "PUT");
            writeData.Write(Encoding.ASCII.GetBytes(lampState.GetJson()), 0, lampState.GetJson().Length);
            writeData.Close();
        }
Exemplo n.º 2
0
        public HueLamp ConvertToHueLamp(int lampNumber)
        {
            JsonLamp jsonLamp = null;
            lights.TryGetValue(lampNumber, out jsonLamp);

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

            return null;
        }