Пример #1
0
        private void ConfigureDevice(IHomeAutomationAPI homeAutomationAPI, DeviceConfig deviceConfig)
        {
            var locations   = homeAutomationAPI.ApiLocationGet();
            var deviceTypes = homeAutomationAPI.ApiDeviceGet();
            var sensors     = homeAutomationAPI.ApiSensorGet();
            var devices     = homeAutomationAPI.ApiDeviceGet();

            LocationEntity location = null;

            if (!locations.Where(x => x.Name == deviceConfig.Location).Any())
            {
                // Create Location
            }

            DeviceTypeEntity deviceType = null;

            if (!deviceTypes.Where(x => x.Name == deviceConfig.DeviceTypeName).Any())
            {
                // Create DeviceType
            }

            List <SensorEntity> sensorList = new List <SensorEntity>();

            foreach (var sensor in deviceConfig.Sensors)
            {
                if (!sensors.Where(x => x.Name == sensor).Any())
                {
                    // Create Sensor
                }
            }
            if (!devices.Where(x => x.Name == deviceConfig.Name).Any())
            {
                // Create Device
            }
        }