Ejemplo n.º 1
0
        public AqaraClient(AqaraConfig config)
        {
            dicGateways = new Dictionary <string, AqaraGateway>(StringComparer.OrdinalIgnoreCase);
            if (config is AqaraConfig && config.Gateways != null)
            {
                foreach (var gateway in config.Gateways)
                {
                    if (gateway?.MacAddress == null || dicGateways.ContainsKey(gateway.MacAddress))
                    {
                        continue;
                    }

                    var sid             = gateway.MacAddress.Replace(":", "").ToLower();
                    var gateway_devices = gateway.Devices.ToList();
                    gateway_devices.Insert(0, new AqaraDeviceConfig()
                    {
                        Name = gateway.Name, Model = gateway.Model, DeviceId = sid
                    });
                    gateway.Devices = gateway_devices.ToArray();
                    AqaraGateway entry = new AqaraGateway(this, sid, gateway.Password, gateway.Devices)
                    {
                        Model = gateway.Model, Name = gateway.Name
                    };
                    dicGateways.Add(entry.Id, entry);
                }
            }
        }
Ejemplo n.º 2
0
        public AqaraClient(AqaraConfig config)
        {
            dicGateways = new Dictionary <string, AqaraGateway>(StringComparer.OrdinalIgnoreCase);
            if (config.Gateways != null)
            {
                foreach (var gateway in config.Gateways)
                {
                    if (gateway?.MacAddress == null || dicGateways.ContainsKey(gateway.MacAddress))
                    {
                        continue;
                    }

                    var          sid   = gateway.MacAddress.Replace(":", "").ToLower();
                    AqaraGateway entry = new AqaraGateway(this, sid, gateway.Password, gateway.Devices);
                    dicGateways.Add(entry.Id, entry);
                }
            }
        }