public Program(ConsoleLogger logger) { _smartHub = new SmartHub(logger, new List <ISmartHouseFramework> { new ZWaveFramework() }, new FileStorage <DeviceWrapper>("DeviceWrappers.txt")); _smartHub.SaveDeviceWrappers(); foreach (var smartLifeDeviceWrapper in _smartHub.DeviceWrappers.Where(x => x.Device is UnknownDevice)) { logger.Log($"Found a unknown device! {smartLifeDeviceWrapper.DeviceId} {smartLifeDeviceWrapper.Device}"); } var zone = _smartHub.Zones.Where(x => x.Key == "#1").SelectMany(x => x.Value).Select(x => x.Device); var powerPlug = zone.FirstOrDefault(x => x is ISwitch); var motionSensor = zone.FirstOrDefault(x => x is IMotionSensor); if (powerPlug != null && motionSensor != null) { _smartHub.AddOperation(new TemperatureSensorPowerPlug((ITemperatureMeasure)motionSensor, (ISwitch)powerPlug, 18)); //var plugs = _smartHub.DeviceWrappers.Where(x => !x.Zones.Any()).Where(x => x is ILedRing).Select(x => x.Device).ToList(); //_smartHub.AddOperation(new LuxSensorPowerPlugs((ILuxMeasure)motionSensor, plugs)); } var temp = _smartHub.DeviceWrappers.Select(x => x.Device).Where(x => x is IColorLight); foreach (var device in temp) { _bulbs.Add((IColorLight)device); } }
private void DoStandard() { _smartHub.SaveDeviceWrappers(); var zone = _smartHub.Zones.Where(x => x.Key == "#1").SelectMany(x => x.Value).Select(x => x.Device); var powerPlug = zone.FirstOrDefault(x => x is ISwitch); var motionSensor = zone.FirstOrDefault(x => x is IMotionSensor); if (powerPlug != null && motionSensor != null) { _smartHub.AddOperation(new TemperatureSensorPowerPlug((ITemperatureMeasure)motionSensor, (ISwitch)powerPlug, 18)); //var plugs = _smartHub.DeviceWrappers.Where(x => !x.Zones.Any()).Where(x => x is ILedRing).Select(x => x.Device).ToList(); //_smartHub.AddOperation(new LuxSensorPowerPlugs((ILuxMeasure)motionSensor, plugs)); } var temp = _smartHub.DeviceWrappers.Select(x => x.Device).Where(x => x is IColorLight); foreach (var device in temp) { _bulbs.Add((IColorLight)device); } }