Пример #1
0
        public async Task UpdateDevicesList(DiscoverDeviceRsp response, IMiCommunication communication)
        {
            var device = _devices.FirstOrDefault(x => x.Sid == response.sid);

            if (device != null)
            {
                device.UpdateDevice(response.data);
                return;
            }

            if (response.model == "gateway")
            {
                Gateway g = new Gateway(response, null, communication);
                g.UpdateDevice(response.data);
                _devices.Add(g);
                return;
            }

            if (response.model == "sensor_ht")
            {
                TemperatureSensor g = new TemperatureSensor(response, null, communication);
                g.UpdateDevice(response.data);
                _devices.Add(g);
                return;
            }
        }
Пример #2
0
        public MiHomeManager(
            IMiCommunicationFactory communicationFactory,
            IDevicesKeeper devicesKeeper,
            ITokenKeeper tokenKeeper,
            IDevicesMap devicesMap,
            IKeyGeneratorFactory keyGeneratorFactory)
        {
            _devicesKeeper = devicesKeeper;
            _tokenKeeper   = tokenKeeper;
            _devicesMap    = devicesMap;
            var keyGenerator = keyGeneratorFactory.Build(_devicesMap, _tokenKeeper);

            _communication = communicationFactory.Build(CommandListener, keyGenerator);
        }
Пример #3
0
 protected BaseDevice(
     string sid,
     DeviceTypes type,
     string shortId,
     string name,
     string model,
     IMiCommunication communication)
 {
     Sid            = sid;
     Type           = type;
     ShortId        = shortId;
     Name           = string.IsNullOrWhiteSpace(name) ? sid : name;
     Model          = model;
     _communication = communication;
 }
Пример #4
0
 public Gateway(DiscoverDeviceRsp response, string name, IMiCommunication communication)
     : base(response.sid, DeviceTypes.Gateway, response.short_id, name, response.model, communication)
 {
 }
Пример #5
0
 public TemperatureSensor(DiscoverDeviceRsp response, string name, IMiCommunication communication)
     : base(response.sid, DeviceTypes.TemperatureHumiditySensor, response.short_id, name, response.model, communication)
 {
 }