private void DeviceFound(Device dev) { var ip = IpUtil.GetIpFromHost(dev.Hostname); var ipString = ip == null ? "" : ip.ToString(); var yd = new YeelightData { Id = dev.Id, IpAddress = ipString, Name = dev.Name }; _controlService.AddDevice(yd).ConfigureAwait(false); }
public YeelightDevice(YeelightData yd, ColorService cs) : base(cs) { _data = yd; Id = _data.Id; IpAddress = _data.IpAddress; Enable = _data.Enable; LoadData(); Log.Debug("Created new yee device at " + yd.IpAddress); cs.ColorSendEventAsync += SetColors; _colorService = cs; _data.LastSeen = DateTime.Now.ToString(CultureInfo.InvariantCulture); DataUtil.AddDeviceAsync(_data, false).ConfigureAwait(false); _yeeDevice = new Device(IpAddress); _colorService.ColorSendEventAsync += SetColors; }