Пример #1
0
        /// <summary>
        /// Gets all devices including their channels but without any data point or state data
        /// </summary>
        /// <returns>List containing devices with channels</returns>
        private List <HMDevice> GetDevices()
        {
            List <HMDevice> result = new List <HMDevice>();

            // requesting devices list from HomeMatic XmlApi
            XmlDocument xmlDevices = GetApiData(xmlApiMethodDevice);

            // iterating devices
            foreach (XmlElement devElement in xmlDevices.DocumentElement.ChildNodes)
            {
                HMDevice device = new HMDevice()
                {
                    Name       = devElement.GetAttribute("name"),
                    Address    = devElement.GetAttribute("address"),
                    InternalId = int.Parse(devElement.GetAttribute("ise_id")),
                    DeviceType = devElement.GetAttribute("device_type")
                };

                // iterating channels
                foreach (XmlElement chanElement in devElement.ChildNodes)
                {
                    HMDeviceChannel channel = new HMDeviceChannel()
                    {
                        Name       = chanElement.GetAttribute("name"),
                        Address    = chanElement.GetAttribute("address"),
                        InternalId = int.Parse(chanElement.GetAttribute("ise_id")),
                    };

                    device.AddChannel(channel);
                }

                result.Add(device);
            }

            return(result);
        }