public AqaraDevice(AqaraClient connector, AqaraGateway gateway, string sid, AqaraDeviceConfig config)
 {
     this.connector = connector;
     this.gateway   = gateway;
     this.Id        = sid;
     this.config    = config;
 }
Exemple #2
0
        public AqaraGateway(AqaraClient client, string sid, string password, AqaraDeviceConfig[] devices)
        {
            this.client   = client;
            this.sid      = sid;
            this.password = password;
            if (devices != null)
            {
                foreach (var item in devices)
                {
                    string systemid = item.DeviceId;
                    if (systemid.StartsWith("lumi.", StringComparison.OrdinalIgnoreCase))
                    {
                        systemid = systemid.Substring(5);
                    }

                    if (dicDevices.ContainsKey(systemid))
                    {
                        throw new ArgumentException("设备清单中已存在具有相同键的元素");
                    }

                    var device = new AqaraDevice(client, this, systemid, item);
                    device.Name = item.Name;
                    dicDevices.Add(systemid, device);
                }
            }
        }
 public AqaraDevice(AqaraClient connector, AqaraGateway gateway, string sid, AqaraDeviceConfig config)
 {
     this.connector = connector;
     this.gateway   = gateway;
     this.Id        = sid;
     this.config    = config;
     this.model     = DeviceModel.GetModelByName(config.Model);
     description    = DeviceModel.GetDescription(config.Model);
 }
 public PlugDevice(AqaraClient connector, AqaraGateway gateway, string sid, AqaraDeviceConfig config) : base(connector, gateway, sid, config)
 {
     timer.Elapsed += Timer_Elapsed;
     timer.Start();
 }
Exemple #5
0
 public MiJiaGatewayDevice(AqaraClient connector, AqaraGateway gateway, string sid, AqaraDeviceConfig config) : base(connector, gateway, sid, config)
 {
 }
 public CtrlNeutral2Device(AqaraClient connector, AqaraGateway gateway, string sid, AqaraDeviceConfig config)
     : base(connector, gateway, sid, config)
 {
 }
Exemple #7
0
        public AqaraGateway(AqaraClient client, string sid, string password, AqaraDeviceConfig[] devices)
        {
            this.client   = client;
            this.sid      = sid;
            this.password = password;
            if (devices != null)
            {
                foreach (var item in devices)
                {
                    string systemid = item.DeviceId;
                    if (systemid.StartsWith("lumi.", StringComparison.OrdinalIgnoreCase))
                    {
                        systemid = systemid.Substring(5);
                    }

                    if (dicDevices.ContainsKey(systemid))
                    {
                        throw new ArgumentException("设备清单中已存在具有相同键的元素");
                    }

                    //var device = new AqaraDevice(client, this, systemid, item);

                    AqaraDevice device = new AqaraDevice(client, this, systemid, item);
                    if (device.Model is DeviceModel)
                    {
                        switch (device.Model.Name)
                        {
                        case "cube":    //a.窗磁传感器
                            device = new CubeDevice(client, this, systemid, item);
                            break;

                        case "magnet":    //a.窗磁传感器
                            device = new MagnetDevice(client, this, systemid, item);
                            break;

                        case "motion":    //人体传感器
                            device = new MotionDevice(client, this, systemid, item);
                            break;

                        case "switch":    //无线开关传感器
                            device = new SwitchDevice(client, this, systemid, item);
                            break;

                        case "plug":    //智能插座
                            device = new PlugDevice(client, this, systemid, item);
                            break;

                        case "ctrl_neutral1":    //单火开关单键
                            break;

                        case "ctrl_neutral2":    //单火开关双键
                            device = new CtrlNeutral2Device(client, this, systemid, item);
                            break;

                        case "86sw1":    //无线开关单键
                            break;

                        case "86sw2":    //无线开关双键
                            break;

                        case "sensor_ht":    //温湿度传感器
                            device = new SensorHTDevice(client, this, systemid, item);
                            break;

                        case "rgbw_light":    //j.LUMI.LIGHT.RGBW
                            break;

                        case "gateway":    //MiJia/XiaoMi/Aqara Gateway
                            device = new MiJiaGatewayDevice(client, this, systemid, item);
                            break;

                        default:
                            break;
                        }
                    }
                    device.Name = item.Name;
                    dicDevices.Add(systemid, device);
                }
            }
        }