Status data returned from the bridge
Exemple #1
0
        internal Bridge(BridgeState bridge)
        {
            if (bridge == null)
            {
                throw new ArgumentNullException(nameof(bridge));
            }

            Config = bridge.config;

            foreach (var light in bridge.Lights)
            {
                light.Value.Id = light.Key;
            }
            Lights = bridge.Lights.Select(l => l.Value).ToList();

            foreach (var group in bridge.Groups)
            {
                group.Value.Id = group.Key;
            }
            Groups = bridge.Groups.Select(l => l.Value).ToList();

            //Fix whitelist IDs
            if (bridge.config != null)
            {
                foreach (var whitelist in bridge.config.WhiteList ?? new Dictionary <string, WhiteList>())
                {
                    whitelist.Value.Id = whitelist.Key;
                }

                WhiteList = bridge.config.WhiteList.Select(l => l.Value).ToList();
            }
        }
        /// <summary>
        /// Get bridge info
        /// </summary>
        /// <returns></returns>
        public async Task <Bridge> GetBridgeAsync()
        {
            CheckInitialized();

            HttpClient client       = HueClient.GetHttpClient();
            var        stringResult = await client.GetStringAsync(new Uri(ApiBase)).ConfigureAwait(false);

            BridgeState jsonResult = DeserializeResult <BridgeState>(stringResult);

            return(new Bridge(jsonResult));
        }
Exemple #3
0
        internal Bridge(BridgeState bridge)
        {
            if (bridge == null)
            {
                throw new ArgumentNullException(nameof(bridge));
            }

            Config = bridge.Config;

            foreach (var light in bridge.Lights)
            {
                light.Value.Id = light.Key;
            }
            Lights = bridge.Lights.Select(l => l.Value).ToList();

            foreach (var sensor in bridge.Sensors)
            {
                sensor.Value.Id = sensor.Key;
            }
            Sensors = bridge.Sensors.Select(s => s.Value).ToList();

            foreach (var group in bridge.Groups)
            {
                group.Value.Id = group.Key;
            }
            Groups = bridge.Groups.Select(l => l.Value).ToList();

            foreach (var scene in bridge.Scenes)
            {
                scene.Value.Id = scene.Key;
            }
            Scenes = bridge.Scenes.Select(s => s.Value).ToList();

            foreach (var rule in bridge.Rules)
            {
                rule.Value.Id = rule.Key;
            }
            Rules = bridge.Rules.Select(r => r.Value).ToList();

            foreach (var schedule in bridge.Schedules)
            {
                schedule.Value.Id = schedule.Key;
            }
            Schedules = bridge.Schedules.Select(s => s.Value).ToList();

            foreach (var whitelist in bridge.Config.WhiteList)
            {
                whitelist.Value.Id = whitelist.Key;
            }
            WhiteList = bridge.Config.WhiteList.Select(l => l.Value).ToList();
        }
Exemple #4
0
    internal Bridge(BridgeState bridge)
    {
      if (bridge == null)
        throw new ArgumentNullException("bridge");

      Config = bridge.config;

      foreach (var light in bridge.lights)
        light.Value.Id = light.Key;
      Lights = bridge.lights.Select(l => l.Value).ToList();

      foreach (var whitelist in bridge.config.WhiteList)
        whitelist.Value.Id = whitelist.Key;
      WhiteList = bridge.config.WhiteList.Select(l => l.Value).ToList();
    }
Exemple #5
0
        internal Bridge(BridgeState bridge)
        {
            if (bridge == null)
            {
                throw new ArgumentNullException("bridge");
            }

            Config = bridge.config;

            foreach (var light in bridge.lights)
            {
                light.Value.Id = light.Key;
            }
            Lights = bridge.lights.Select(l => l.Value).ToList();

            foreach (var whitelist in bridge.config.WhiteList)
            {
                whitelist.Value.Id = whitelist.Key;
            }
            WhiteList = bridge.config.WhiteList.Select(l => l.Value).ToList();
        }