Example #1
0
        public Light(JObject jObject, HueConnection context, string id) : this(context, id)
        {
            if (jObject["state"] != null)
            {
                var lightState = HueObjectFactory.CreateHueObject(jObject["state"].ToString(), HueObjectType.LightState) as State;
                if (lightState != null)
                {
                    State = lightState;
                }
            }

            Type = (string)jObject["type"];

            LightType = EnumHelper.GetEnumWithDescription <LightType>(Type);
            SupportsColorModeAttribute supportsColorModeAttribute = LightType.GetEnumAttribute <SupportsColorModeAttribute>();

            if (supportsColorModeAttribute != null)
            {
                SupportedColorModes = supportsColorModeAttribute.Modes;
            }
            else
            {
                SupportedColorModes = new List <ColorMode>();
            }

            Name            = (string)jObject["name"];
            ModelID         = (string)jObject["modelid"];
            SoftwareVersion = (string)jObject["swversion"];
        }
Example #2
0
        public Bridge(JObject jObject, HueConnection hueConnection) : base(hueConnection, (string)jObject["id"])
        {
            InternalIPAddress = (string)jObject["internalipaddress"];
            MACAddress        = (string)jObject["macaddress"];

            _groups = new HueObjectCollectionBase <Group>();
            _lights = new HueObjectCollectionBase <Light>();
        }
Example #3
0
        public Schedule(JObject jObject, HueConnection connection, string id)
            : base(connection, id)
        {
            Name        = (string)jObject["name"];
            Description = (string)jObject["description"];

            if (jObject["command"] != null)
            {
                var command = HueObjectFactory.CreateHueObject(jObject["command"].ToString(), HueObjectType.Command) as Command;
                if (command != null)
                {
                    Command = command;
                }
            }

            Time = (DateTime?)jObject["time"];
        }
Example #4
0
        public Group(JObject jObject, HueConnection context, string id) : base(context, id)
        {
            Name = (string)jObject["name"];

            if (jObject["action"] != null)
            {
                var lightState = HueObjectFactory.CreateHueObject(jObject["action"].ToString(), HueObjectType.LightState) as State;
                if (lightState != null)
                {
                    State = lightState;
                }
            }

            Lights = new HueObjectCollectionBase <Light>();

            if (jObject["lights"] != null)
            {
                LightsIDs = jObject["lights"].ToObject <List <string> >();
            }
        }
Example #5
0
 public Light(HueConnection context, string id) : base(context, id)
 {
 }
Example #6
0
        public async Task <HueObjectBase> GetBridgesAsync(HueConnection connection)
        {
            // ToDo Implement UPnP code here

            return(await GetBridgesFromPortalAPIAsync(connection));
        }
Example #7
0
        private async Task <HueObjectBase> GetBridgesFromPortalAPIAsync(HueConnection connection)
        {
            string returnString = await connection.GetAsync(Resources.BridgeUPNPURI);

            return(HueObjectFactory.CreateHueObject(returnString, connection, HueObjectType.Bridge) as HueObjectCollectionBase <Bridge> ?? (HueObjectBase) new Error(-1, "", "No Hue Bridge Found"));
        }