Exemplo n.º 1
0
        public static HueLight Map(Light light)
        {
            State state = light.State;

            HueLightState lightState = new HueLightState(
                state.On,
                state.Brightness,
                state.Hue,
                state.Saturation,
                state.ColorCoordinates,
                state.ColorTemperature,
                (HueAlert?)state.Alert,
                (HueEffect?)state.Effect,
                state.ColorMode,
                state.IsReachable,
                state.TransitionTime,
                state.Mode
                );

            return(new HueLight(
                       light.Id,
                       lightState,
                       light.Type,
                       light.Name,
                       light.ModelId,
                       light.ProductId,
                       light.SwConfigId,
                       light.UniqueId,
                       light.LuminaireUniqueId,
                       light.ManufacturerName,
                       light.SoftwareVersion
                       ));
        }
Exemplo n.º 2
0
        public string JsonDiff(HueLightState update)
        {
            var result = "{";

            if (bri != update.bri)
            {
                result += "\"bri\": " + update.bri + ", ";
            }
            if (on != update.on)
            {
                result += "\"on\": " + update.on.ToString().ToLowerInvariant() + ", ";
            }
            //if (hue != update.hue) result += "\"hue\": " + update.hue + ", ";
            //if (sat != update.sat) result += "\"sat\": " + update.sat + ", ";
            //if (alert != update.alert) result += "\"alert\": " + update.alert + ", ";
            //instance.xy = new decimal[] { d["xy"][0], d["xy"][1] };
            //instance.alert = d["alert"];
            //instance.effect = d["effect"];
            //instance.colormode = d["colormode"];
            //instance.reachable = d["reachable"];

            result  = result.TrimEnd(',', ' ');
            result += "}";

            if (result == "{}")
            {
                return("");
            }
            return(result);
        }
Exemplo n.º 3
0
        public static HueLight Parse(dynamic d)
        {
            var instance = new HueLight();

            instance.state     = HueLightState.Parse(d["state"]);
            instance.type      = d["type"];
            instance.name      = d["name"];
            instance.modelid   = d["modelid"];
            instance.swversion = long.Parse(d["swversion"]);
            return(instance);
        }
Exemplo n.º 4
0
 public HueLight(string id, HueLightState state, string type, string name, string modelId, string productId, string swConfigId, string uniqueId, string luminaireUniqueId, string manufacturerName, string softwareVersion)
 {
     Id                = id;
     State             = state;
     Type              = type;
     Name              = name;
     ModelId           = modelId;
     ProductId         = productId;
     SwConfigId        = swConfigId;
     UniqueId          = uniqueId;
     LuminaireUniqueId = luminaireUniqueId;
     ManufacturerName  = manufacturerName;
     SoftwareVersion   = softwareVersion;
 }
Exemplo n.º 5
0
        public static HueLightState Parse(dynamic d)
        {
            var instance = new HueLightState();

            instance.on = d["on"];
            instance.bri = d["bri"];
            instance.hue = d["hue"];
            instance.sat = d["sat"];
            instance.xy = new decimal[] { d["xy"][0], d["xy"][1] };
            instance.alert = d["alert"];
            instance.effect = d["effect"];
            instance.colormode = d["colormode"];
            instance.reachable = d["reachable"];
            return instance;
        }
Exemplo n.º 6
0
        public static HueLightState Parse(dynamic d)
        {
            var instance = new HueLightState();

            instance.on        = d["on"];
            instance.bri       = d["bri"];
            instance.hue       = d["hue"];
            instance.sat       = d["sat"];
            instance.xy        = new decimal[] { d["xy"][0], d["xy"][1] };
            instance.alert     = d["alert"];
            instance.effect    = d["effect"];
            instance.colormode = d["colormode"];
            instance.reachable = d["reachable"];
            return(instance);
        }
Exemplo n.º 7
0
        public string JsonDiff(HueLightState update)
        {
            var result = "{";

            if (bri != update.bri) result += "\"bri\": " + update.bri + ", ";
            if (on != update.on) result += "\"on\": " + update.on.ToString().ToLowerInvariant() + ", ";
            //if (hue != update.hue) result += "\"hue\": " + update.hue + ", ";
            //if (sat != update.sat) result += "\"sat\": " + update.sat + ", ";
            //if (alert != update.alert) result += "\"alert\": " + update.alert + ", ";
            //instance.xy = new decimal[] { d["xy"][0], d["xy"][1] };
            //instance.alert = d["alert"];
            //instance.effect = d["effect"];
            //instance.colormode = d["colormode"];
            //instance.reachable = d["reachable"];

            result = result.TrimEnd(',', ' ');
            result += "}";

            if (result == "{}")
                return "";
            return result;
        }
Exemplo n.º 8
0
 internal static string JsonCommand(HueLightState hueLightState1, HueLightState hueLightState2)
 {
     return hueLightState1.JsonDiff(hueLightState2);
 }
Exemplo n.º 9
0
 internal static string JsonCommand(HueLightState hueLightState1, HueLightState hueLightState2)
 {
     return(hueLightState1.JsonDiff(hueLightState2));
 }