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; } }
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); }
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; }
public Gateway(DiscoverDeviceRsp response, string name, IMiCommunication communication) : base(response.sid, DeviceTypes.Gateway, response.short_id, name, response.model, communication) { }
public TemperatureSensor(DiscoverDeviceRsp response, string name, IMiCommunication communication) : base(response.sid, DeviceTypes.TemperatureHumiditySensor, response.short_id, name, response.model, communication) { }