Exemplo n.º 1
0
        private static void ChangeValue(string light, int value, string valueName)
        {
            dynamic jsonValue = new ExpandoObject();
            var     jsonRef   = (IDictionary <string, object>)jsonValue;

            jsonRef[valueName] = value;

            Uri dataUri = new Uri(AddressBuild.LightState(light));

            TimePut(dataUri, JsonParser.Serialize(jsonValue));
            JsonParser.Modify(Storage.latestData, new string[] { "lights", light, "state", valueName }, (int)value);
        }
Exemplo n.º 2
0
        public static int ToggleLight(string light, bool isOn)
        {
            dynamic jsonToggle = new ExpandoObject();

            if (isOn == true)
            {
                jsonToggle.on = true;
            }
            else
            {
                jsonToggle.on = false;
            }

            Uri dataUri = new Uri(AddressBuild.LightState(light));

            JsonParser.Modify(Storage.latestData, new string[] { "lights", light, "state", "on" }, isOn);
            PutData(dataUri, JsonParser.Serialize(jsonToggle));
            return(0);
        }