Esempio n. 1
0
        /// <summary>
        /// Process the search results.
        /// </summary>
        /// <param name="bridge">Bridge to process the search results from</param>
        /// <param name="results">Search result to process</param>
        /// <param name="type">Type of result to process. Lights or Sensors</param>
        /// <returns>A list of objects.</returns>
        private static List <HueObject> ProcessSearchResult(Bridge bridge, SearchResult results, bool type)
        {
            if (results == null)
            {
                return(new List <HueObject>());
            }
            List <HueObject> newlist = new List <HueObject>();

            if (type) // lights
            {
                foreach (KeyValuePair <string, string> kvp in results.listnewobjects)
                {
                    Light newlight = bridge.GetLight(kvp.Key);
                    if (newlight == null)
                    {
                        continue;
                    }
                    newlight.Id = kvp.Key;

                    if (bridge.lastMessages.SuccessCount == 1)
                    {
                        newlight.Image = GetImageForLight((bool)newlight.state.reachable ? (bool)newlight.state.on ? LightImageState.On : LightImageState.Off : LightImageState.Unr, newlight.modelid);
                    }

                    newlist.Add(newlight);
                }
            }
            else // sensors
            {
                foreach (KeyValuePair <string, string> kvp in results.listnewobjects)
                {
                    Sensor newSensor = bridge.GetSensor(kvp.Key);
                    if (newSensor == null)
                    {
                        continue;
                    }
                    newSensor.Id = kvp.Key;
                    switch (newSensor.type)
                    {
                    case "ZGPSwitch":
                        log.Debug("New sensor is Hue Tap.");
                        newSensor.Image = GDIManager.CreateImageSourceFromImage(Properties.Resources.huetap);
                        break;

                    case "ZLLSwitch":
                        log.Debug("New sensor is dimmer.");
                        newSensor.Image = GDIManager.CreateImageSourceFromImage(Properties.Resources.dimmer);
                        break;

                    default:
                        log.Debug("New sensor is generic.");
                        newSensor.Image = GDIManager.CreateImageSourceFromImage(Properties.Resources.sensor);
                        break;
                    }
                    newlist.Add(newSensor);
                }
            }

            return(newlist);
        }
Esempio n. 2
0
        /// <summary>
        /// Process a list of sensors
        /// </summary>
        /// <param name="listsensors">List of sensors to process.</param>
        /// <returns>A list of processed sensors.</returns>
        private static List <HueObject> ProcessSensors(Dictionary <string, Sensor> listsensors)
        {
            List <HueObject> newlist = new List <HueObject>();

            if (listsensors == null)
            {
                return(newlist);
            }

            foreach (KeyValuePair <string, Sensor> kvp in listsensors)
            {
                kvp.Value.Id = kvp.Key;
                log.Debug("Processing Sensor : " + kvp.Value);
                switch (kvp.Value.type)
                {
                case "ZGPSwitch":
                    log.Debug("Sensor is Hue Tap.");
                    kvp.Value.Image = GDIManager.CreateImageSourceFromImage(Properties.Resources.huetap);
                    break;

                case "ZLLSwitch":
                    log.Debug("Sensor is dimmer.");
                    kvp.Value.Image = GDIManager.CreateImageSourceFromImage(Properties.Resources.dimmer);
                    break;

                default:
                    log.Debug("Sensor is generic sensor.");
                    kvp.Value.Image = GDIManager.CreateImageSourceFromImage(Properties.Resources.sensor);
                    break;
                }
                newlist.Add(kvp.Value);
            }

            return(newlist);
        }
Esempio n. 3
0
        /// <summary>
        /// Process a list of schedules
        /// </summary>
        /// <param name="listschedules">List of schedules to process.</param>
        /// <returns>A list of processed schedules.</returns>
        public static List <HueObject> ProcessSchedules(Dictionary <string, Schedule> listschedules)
        {
            List <HueObject> newlist = new List <HueObject>();

            if (listschedules == null)
            {
                log.Debug("List of schedule is null.");
                return(newlist);
            }

            foreach (KeyValuePair <string, Schedule> kvp in listschedules)
            {
                log.Debug("Assigning id to schedule ");
                kvp.Value.Id = kvp.Key;
                ImageSource imgsource;
                log.Debug("Processing schedule : " + kvp.Value);
                string Time = string.Empty;
                if (kvp.Value.localtime == null)
                {
                    log.Debug("LocalTime does not exists try to use Time instead.");
                    if (kvp.Value.time == null)
                    {
                        continue;
                    }
                    Time = kvp.Value.time;
                }
                else
                {
                    log.Debug("Using LocalTime as schedule time.");
                    Time = kvp.Value.time;
                }

                if (Time.Contains("PT"))
                {
                    log.Debug("Schedule is type Timer.");
                    imgsource = GDIManager.CreateImageSourceFromImage(Properties.Resources.timer_clock);
                }
                else if (Time.Contains('W'))
                {
                    log.Debug("Schedule is type Alarm.");
                    imgsource = GDIManager.CreateImageSourceFromImage(Properties.Resources.stock_alarm);
                }
                else if (Time.Contains('T'))
                {
                    log.Debug("Schedule is type Schedule.");
                    imgsource = GDIManager.CreateImageSourceFromImage(Properties.Resources.SchedulesLarge);
                }
                else
                {
                    log.Debug("Schedule is unknown type.");
                    imgsource = GDIManager.CreateImageSourceFromImage(Properties.Resources.schedules);
                }

                kvp.Value.Image = imgsource;
                newlist.Add(kvp.Value);
            }

            return(newlist);
        }
Esempio n. 4
0
 public ColorFromImageView()
 {
     _imagesource   = GDIManager.CreateImageSourceFromImage(Properties.Resources.rgbcolor);
     _selectedColor = new System.Windows.Media.Color()
     {
         R = 255, G = 255, B = 255
     };
 }
Esempio n. 5
0
        private void LoadRGB()
        {
            if (MessageBox.Show(GlobalStrings.Scene_Load_RGB, GlobalStrings.Warning, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                ImageSource = GDIManager.CreateImageSourceFromImage(Properties.Resources.rgbcolor);
                CanLoadRGB  = false;
            }

            ImageSource = GDIManager.CreateImageSourceFromImage(Properties.Resources.rgbcolor);
        }
Esempio n. 6
0
        /// <summary>
        /// Get a sensor with ID, name and image populated from the selected bridge.
        /// </summary>
        /// <param name="bridge">Bridge to get the sensor from.</param>
        /// <param name="id">Id of the sensor on the bridge.</param>
        /// <returns>The sensor</returns>
        public static HueObject GetBridgeSensor(Bridge bridge, string id)
        {
            if (bridge == null)
            {
                return(null);
            }
            log.Debug($@"Getting sensor ID : {id} from bridge : {bridge.IpAddress}");
            Sensor sensor = bridge.GetSensor(id);

            log.Debug("Sensor : " + sensor);
            sensor.Id    = id;
            sensor.Image = GDIManager.CreateImageSourceFromImage(sensor.type == "ZGPSwitch" ? Properties.Resources.huetap : Properties.Resources.sensor);
            return(sensor);
        }
Esempio n. 7
0
        /// <summary>
        /// Get a rule with ID, name and image populated from the selected bridge.
        /// </summary>
        /// <param name="bridge">Bridge to get the rule from.</param>
        /// <param name="id">Id of the rule on the bridge.</param>
        /// <returns>The Rule</returns>
        public static HueObject GetBridgeRule(Bridge bridge, string id)
        {
            if (bridge == null)
            {
                return(null);
            }
            log.Debug($@"Getting rule ID : {id} from bridge {bridge.IpAddress}");
            Rule rule = bridge.GetRule(id);

            log.Debug("Rule : " + rule);
            rule.Id    = id;
            rule.Image = GDIManager.CreateImageSourceFromImage(Properties.Resources.rules);
            return(rule);
        }
Esempio n. 8
0
        /// <summary>
        /// Get a scene with ID, name and image populated from the selected bridge.
        /// </summary>
        /// <param name="bridge">Bridge to get the scene from.</param>
        /// <param name="id">Id of the scene on the bridge.</param>
        /// <returns>The requested scene.</returns>
        public static HueObject GetBridgeScene(Bridge bridge, string id)
        {
            if (bridge == null)
            {
                return(null);
            }
            log.Debug($@"Getting scene ID : {id} from bridge : {bridge.IpAddress}");
            Scene scene = bridge.GetScene(id);

            log.Debug("Scene : " + scene);
            scene.Id    = id;
            scene.Image = GDIManager.CreateImageSourceFromImage(Properties.Resources.SceneLarge);
            return(scene);
        }
Esempio n. 9
0
        /// <summary>
        /// Get a group with ID, name and image populated from the selected bridge.
        /// </summary>
        /// <param name="bridge">Bridge to get the group from.</param>
        /// <param name="id">Id of the group on the bridge.</param>
        /// <returns></returns>
        public static HueObject GetBridgeGroup(Bridge bridge, string id)
        {
            if (bridge == null)
            {
                return(null);
            }
            log.Debug($@"Getting group ID : {id} from bridge : {bridge.IpAddress}");
            Group group = bridge.GetGroup(id);

            log.Debug("Group : " + group);
            group.Id    = id;
            group.Image = GDIManager.CreateImageSourceFromImage((bool)group.action.on ? Properties.Resources.HueGroupOn_Large : Properties.Resources.HueGroupOff_Large);
            return(group);
        }
Esempio n. 10
0
        /// <summary>
        /// Process groups
        /// </summary>
        /// <param name="listgroups">List of group t</param>
        /// <returns>A list of processed group with image and id.</returns>
        private static List <HueObject> ProcessGroups(Dictionary <string, Group> listgroups)
        {
            List <HueObject> newlist = new List <HueObject>();

            foreach (KeyValuePair <string, Group> kvp in listgroups)
            {
                log.Debug("Processing group : " + kvp.Value);
                kvp.Value.Id    = kvp.Key;
                kvp.Value.Image = GDIManager.CreateImageSourceFromImage((bool)kvp.Value.action.on ? Properties.Resources.HueGroupOn_Large : Properties.Resources.HueGroupOff_Large);
                newlist.Add(kvp.Value);
            }

            return(newlist);
        }
Esempio n. 11
0
        /// <summary>
        /// Process a list of rules.
        /// </summary>
        /// <param name="listrules">List of rules to process.</param>
        /// <returns>A processed list of rules.</returns>
        private static List <HueObject> ProcessRules(Dictionary <string, Rule> listrules)
        {
            List <HueObject> newlist = new List <HueObject>();

            foreach (KeyValuePair <string, Rule> kvp in listrules)
            {
                kvp.Value.Id = kvp.Key;

                log.Debug("Processing rule : " + kvp.Value);
                kvp.Value.Image = GDIManager.CreateImageSourceFromImage(Properties.Resources.rules);
                newlist.Add(kvp.Value);
            }

            return(newlist);
        }
Esempio n. 12
0
        private static List <HueObject> ProcessRessourceLinks(Dictionary <string, Resourcelink> listrl)
        {
            if (listrl == null)
            {
                return(new List <HueObject>());
            }
            List <HueObject> newlist = new List <HueObject>();

            foreach (KeyValuePair <string, Resourcelink> kvp in listrl)
            {
                kvp.Value.Id = kvp.Key;
                log.Debug("Processing resource links : " + kvp.Value);
                kvp.Value.Image = GDIManager.CreateImageSourceFromImage(Properties.Resources.resource);
                newlist.Add(kvp.Value);
            }
            return(newlist);
        }
Esempio n. 13
0
        /// <summary>
        /// Process a list of scenes.
        /// </summary>
        /// <param name="listscenes">List of scenes to process.</param>
        /// <returns>A list of processed scenes.</returns>
        private static List <HueObject> ProcessScenes(Dictionary <string, Scene> listscenes)
        {
            List <HueObject> newlist = new List <HueObject>();

            foreach (KeyValuePair <string, Scene> kvp in listscenes)
            {
                kvp.Value.Id = kvp.Key;

                log.Debug("Processing scene : " + kvp.Value);
                kvp.Value.Image = GDIManager.CreateImageSourceFromImage(Properties.Resources.SceneLarge);
                if (kvp.Value.name.Contains("HIDDEN") && !WinHueSettings.settings.ShowHiddenScenes)
                {
                    continue;
                }
                newlist.Add(kvp.Value);
            }

            return(newlist);
        }
Esempio n. 14
0
        /// <summary>
        /// Get a schedule with ID, name and image populated from the selected bridge.
        /// </summary>
        /// <param name="bridge">Bridge to get the schedule from.</param>
        /// <param name="id">Id of the schedule on the bridge.</param>
        /// <returns>The requested schedule.</returns>
        public static HueObject GetBridgeSchedule(Bridge bridge, string id)
        {
            if (bridge == null || id == null)
            {
                return(null);
            }
            log.Debug($@"Getting schedule ID : {id} from bridge : {bridge.IpAddress}");
            Schedule schedule = bridge.GetSchedule(id);

            log.Debug("Schedule : " + schedule);
            schedule.Id = id;
            ImageSource imgsource;

            if (schedule.localtime.Contains("PT"))
            {
                log.Debug("Schedule is type Timer.");
                imgsource = GDIManager.CreateImageSourceFromImage(Properties.Resources.timer_clock);
            }
            else if (schedule.localtime.Contains('W'))
            {
                log.Debug("Schedule is type Alarm.");
                imgsource = GDIManager.CreateImageSourceFromImage(Properties.Resources.stock_alarm);
            }
            else if (schedule.localtime.Contains('T'))
            {
                log.Debug("Schedule is type Schedule.");
                imgsource = GDIManager.CreateImageSourceFromImage(Properties.Resources.SchedulesLarge);
            }
            else
            {
                log.Debug("Schedule is unknown type.");
                imgsource = GDIManager.CreateImageSourceFromImage(Properties.Resources.schedules);
            }

            schedule.Image = imgsource;
            return(schedule);
        }
Esempio n. 15
0
        /// <summary>
        /// Toggle the state of an object on and off (Light or group)
        /// </summary>
        /// <param name="bridge">Bridge to get the information from.</param>
        /// <param name="id">ID of the object to toggle.</param>
        /// <returns>The new image of the object.</returns>
        public static HelperResult ToggleObjectOnOffState(Bridge bridge, HueObject obj)
        {
            if (obj == null)
            {
                return new HelperResult()
                       {
                           Success = false, Hrobject = "The object cannot be null"
                       }
            }
            ;
            if (bridge == null)
            {
                return new HelperResult()
                       {
                           Success = false, Hrobject = "The bridge cannot be null"
                       }
            }
            ;
            if (!(obj is Light) && !(obj is Group))
            {
                return new HelperResult()
                       {
                           Success = false, Hrobject = "Object must be of type group or light"
                       }
            }
            ;
            HelperResult hr = new HelperResult()
            {
                Success = false, Hrobject = obj.Image
            };

            if (obj is Light)
            {
                CommandResult bresult = bridge.GetObject <Light>(obj.Id);

                if (bresult.Success)
                {
                    Light currentState = (Light)bresult.resultobject;

                    if (currentState.state.reachable == false)
                    {
                        hr.Success  = true;
                        hr.Hrobject = GetImageForLight(LightImageState.Unr, currentState.modelid);
                    }
                    else
                    {
                        if (currentState.state.on == true)
                        {
                            log.Debug("Toggling light state : OFF");
                            CommandResult bsetlightstate = bridge.SetState <Light>(new State()
                            {
                                on = false
                            }, obj.Id);

                            if (bsetlightstate.Success)
                            {
                                hr.Success  = true;
                                hr.Hrobject = GetImageForLight(LightImageState.Off, currentState.modelid);
                            }
                            else
                            {
                                hr.Hrobject = bresult.resultobject;
                            }
                        }
                        else
                        {
                            log.Debug("Toggling light state : ON");
                            CommandResult bsetlightstate = bridge.SetState <Light>(new State()
                            {
                                on = true
                            }, obj.Id);

                            if (bsetlightstate.Success)
                            {
                                hr.Success  = true;
                                hr.Hrobject = GetImageForLight(LightImageState.On, currentState.modelid);
                            }
                            else
                            {
                                hr.Hrobject = bresult.resultobject;
                            }
                        }
                    }
                }
                else
                {
                    hr.Hrobject = bresult.resultobject;
                }
            }
            else
            {
                CommandResult bresult = bridge.GetObject <Group>(obj.Id);

                if (bresult.Success)
                {
                    Group currentstate = (Group)bresult.resultobject;
                    if (currentstate.action.on == true)
                    {
                        log.Debug("Toggling group state : ON");
                        CommandResult bsetgroupstate = bridge.SetState <Group>(new HueLib2.Action()
                        {
                            on = false
                        }, obj.Id);

                        if (bsetgroupstate.Success)
                        {
                            hr.Success  = true;
                            hr.Hrobject = GDIManager.CreateImageSourceFromImage(Properties.Resources.HueGroupOff_Large);
                        }
                        else
                        {
                            hr.Hrobject = bresult.resultobject;
                        }
                    }
                    else
                    {
                        log.Debug("Toggling group state : OFF");
                        CommandResult bsetgroupstate = bridge.SetState <Group>(new HueLib2.Action()
                        {
                            on = true
                        }, obj.Id);
                        if (bsetgroupstate.Success)
                        {
                            hr.Success  = true;
                            hr.Hrobject = GDIManager.CreateImageSourceFromImage(Properties.Resources.HueGroupOn_Large);
                        }
                        else
                        {
                            hr.Hrobject = bresult.resultobject;
                        }
                    }
                }
                else
                {
                    hr.Hrobject = bresult.resultobject;
                }
            }

            return(hr);
        }
Esempio n. 16
0
        public static HelperResult GetObject <T>(Bridge bridge, string id) where T : HueObject
        {
            CommandResult bresult = bridge.GetObject <T>(id);
            HelperResult  hr      = new HelperResult()
            {
                Success = bresult.Success
            };

            if (bresult.Success)
            {
                if (typeof(T) == typeof(Light))
                {
                    Light light = (Light)bresult.resultobject;

                    log.Debug("Light : " + light);
                    light.Id    = id;
                    light.Image =
                        GetImageForLight(
                            (bool)light.state.reachable
                                ? (bool)light.state.on ? LightImageState.On : LightImageState.Off
                                : LightImageState.Unr, light.modelid);
                    hr.Hrobject = light;
                }
                else if (typeof(T) == typeof(Group))
                {
                    Group group = (Group)bresult.resultobject;
                    log.Debug("Group : " + group);
                    group.Id    = id;
                    group.Image = GDIManager.CreateImageSourceFromImage((bool)group.action.on ? Properties.Resources.HueGroupOn_Large : Properties.Resources.HueGroupOff_Large);
                    hr.Hrobject = group;
                }
                else if (typeof(T) == typeof(Sensor) || typeof(T).BaseType == typeof(Sensor))
                {
                    Sensor sensor = (Sensor)bresult.resultobject;
                    sensor.Id    = id;
                    sensor.Image = GDIManager.CreateImageSourceFromImage(sensor.type == "ZGPSwitch" ? Properties.Resources.huetap : Properties.Resources.sensor);
                    hr.Hrobject  = sensor;
                }
                else if (typeof(T) == typeof(Rule))
                {
                    Rule rule = (Rule)bresult.resultobject;
                    log.Debug("Rule : " + rule);
                    rule.Id     = id;
                    rule.Image  = GDIManager.CreateImageSourceFromImage(Properties.Resources.rules);
                    hr.Hrobject = rule;
                }
                else if (typeof(T) == typeof(Scene))
                {
                    Scene scene = (Scene)bresult.resultobject;
                    log.Debug("Scene : " + scene);
                    scene.Id    = id;
                    scene.Image = GDIManager.CreateImageSourceFromImage(Properties.Resources.SceneLarge);
                    hr.Hrobject = scene;
                }
                else if (typeof(T) == typeof(Schedule))
                {
                    Schedule schedule = (Schedule)bresult.resultobject;
                    schedule.Id = id;
                    ImageSource imgsource;
                    if (schedule.localtime.Contains("PT"))
                    {
                        log.Debug("Schedule is type Timer.");
                        imgsource = GDIManager.CreateImageSourceFromImage(Properties.Resources.timer_clock);
                    }
                    else if (schedule.localtime.Contains('W'))
                    {
                        log.Debug("Schedule is type Alarm.");
                        imgsource = GDIManager.CreateImageSourceFromImage(Properties.Resources.stock_alarm);
                    }
                    else if (schedule.localtime.Contains('T'))
                    {
                        log.Debug("Schedule is type Schedule.");
                        imgsource = GDIManager.CreateImageSourceFromImage(Properties.Resources.SchedulesLarge);
                    }
                    else
                    {
                        log.Debug("Schedule is unknown type.");
                        imgsource = GDIManager.CreateImageSourceFromImage(Properties.Resources.schedules);
                    }

                    schedule.Image = imgsource;
                    hr.Hrobject    = schedule;
                }
                else if (typeof(T) == typeof(Resourcelink))
                {
                    Resourcelink rl = (Resourcelink)bresult.resultobject;
                    rl.Id       = id;
                    rl.Image    = GDIManager.CreateImageSourceFromImage(Properties.Resources.resource);
                    hr.Hrobject = rl;
                }
            }
            else
            {
                hr.Hrobject = bresult.resultobject;
            }
            return(hr);
        }
Esempio n. 17
0
        /// <summary>
        /// Toggle the state of an object on and off (Light or group)
        /// </summary>
        /// <param name="bridge">Bridge to get the information from.</param>
        /// <param name="id">ID of the object to toggle.</param>
        /// <returns>The new image of the object.</returns>
        public static ImageSource ToggleObjectOnOffState(Bridge bridge, HueObject obj)
        {
            if (obj == null)
            {
                return(null);
            }
            if (bridge == null)
            {
                return(obj.Image);
            }
            if (!(obj is Light) && !(obj is Group))
            {
                return(obj.Image);
            }
            if (obj is Light)
            {
                Light currentState = bridge.GetLight(obj.Id);
                if (currentState?.state == null)
                {
                    return(obj.Image);
                }
                if (currentState.state.reachable == false)
                {
                    return(GetImageForLight(LightImageState.Unr, currentState.modelid));
                }
                if (currentState.state.on == true)
                {
                    log.Debug("Toggling light state : OFF");
                    bridge.SetLightState(obj.Id, new State()
                    {
                        on = false
                    });

                    if (bridge.lastMessages.SuccessCount == 1)
                    {
                        currentState.Image = GetImageForLight(LightImageState.Off, currentState.modelid);
                    }
                    return(currentState.Image);
                }
                else
                {
                    log.Debug("Toggling light state : ON");
                    bridge.SetLightState(obj.Id, new State()
                    {
                        on = true
                    });

                    if (bridge.lastMessages.SuccessCount == 1)
                    {
                        currentState.Image = GetImageForLight(LightImageState.On, currentState.modelid);
                    }
                    return(currentState.Image);
                }
            }
            else
            {
                Group currentState = bridge.GetGroup(obj.Id);
                if (currentState?.action == null)
                {
                    return(obj.Image);
                }
                if (currentState.action.on == true)
                {
                    log.Debug("Toggling group state : ON");
                    bridge.SetGroupAction(obj.Id, new HueLib_base.Action()
                    {
                        on = false
                    });
                    return(bridge.lastMessages.SuccessCount == 1 ? GDIManager.CreateImageSourceFromImage(Properties.Resources.HueGroupOff_Large) : obj.Image);
                }
                else
                {
                    log.Debug("Toggling group state : OFF");
                    bridge.SetGroupAction(obj.Id, new HueLib_base.Action()
                    {
                        on = true
                    });
                    return(bridge.lastMessages.SuccessCount == 1 ? GDIManager.CreateImageSourceFromImage(Properties.Resources.HueGroupOn_Large) : obj.Image);
                }
            }
        }
Esempio n. 18
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            JObject obj = (JObject)serializer.Deserialize(reader);

            Supportedlight supportedlight = new Supportedlight();


            if (obj["modelid"] != null)
            {
                supportedlight.modelid = obj["modelid"].Value <string>();
            }
            if (obj["name"] != null)
            {
                supportedlight.name = obj["name"].Value <string>();
            }
            if (obj["type"] != null)
            {
                supportedlight.type = obj["type"].Value <string>();
            }

            if (obj["hue"] != null)
            {
                if (obj["hue"]["max"] != null && obj["hue"]["min"] != null)
                {
                    supportedlight.hue = new MaxMin <ushort>()
                    {
                        max = obj["hue"]["max"].Value <ushort>(),
                        min = obj["hue"]["min"].Value <ushort>()
                    }
                }
                ;
            }

            if (obj["sat"] != null)
            {
                if (obj["sat"]["max"] != null && obj["sat"]["min"] != null)
                {
                    supportedlight.sat = new MaxMin <byte>()
                    {
                        max = obj["sat"]["max"].Value <byte>(),
                        min = obj["sat"]["min"].Value <byte>()
                    }
                }
                ;
            }

            if (obj["bri"] != null)
            {
                if (obj["bri"]["max"] != null && obj["bri"]["min"] != null)
                {
                    supportedlight.bri = new MaxMin <byte>()
                    {
                        max = obj["bri"]["max"].Value <byte>(),
                        min = obj["bri"]["min"].Value <byte>()
                    }
                }
                ;
            }

            if (obj["ct"] != null)
            {
                if (obj["ct"]["max"] != null && obj["ct"]["min"] != null)
                {
                    supportedlight.ct = new MaxMin <ushort>()
                    {
                        max = obj["hue"]["max"].Value <ushort>(),
                        min = obj["hue"]["min"].Value <ushort>()
                    }
                }
                ;
            }

            if (obj["img"] != null)
            {
                if (obj["img"]["on"] != null && obj["img"]["off"] != null && obj["img"]["unr"] != null)
                {
                    string path = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);
                    supportedlight.img = new Dictionary <string, ImageSource>();

                    if (File.Exists(path + @"\lights\images\" + obj["img"]["on"].Value <string>()) &&
                        File.Exists(path + @"\lights\images\" + obj["img"]["off"].Value <string>()) &&
                        File.Exists(path + @"\lights\images\" + obj["img"]["unr"].Value <string>()))
                    {
                        supportedlight.img.Add("on",
                                               new BitmapImage(new Uri(path + @"\lights\images\" + obj["img"]["on"].Value <string>())));
                        supportedlight.img.Add("off",
                                               new BitmapImage(new Uri(path + @"\lights\images\" + obj["img"]["off"].Value <string>())));
                        supportedlight.img.Add("unr",
                                               new BitmapImage(new Uri(path + @"\lights\images\" + obj["img"]["unr"].Value <string>())));
                    }
                    else
                    {
                        supportedlight.img.Add("on", GDIManager.CreateImageSourceFromImage(Properties.Resources.DefaultLight_on));
                        supportedlight.img.Add("off", GDIManager.CreateImageSourceFromImage(Properties.Resources.DefaultLight_off));
                        supportedlight.img.Add("unr", GDIManager.CreateImageSourceFromImage(Properties.Resources.DefaultLight_unr));
                    }
                }
            }

            return(supportedlight);
        }