diff --git a/app/campaign/views.py b/app/campaign/views.py index c7da5c0..33feb30 100644 --- a/app/campaign/views.py +++ b/app/campaign/views.py @@ -337,15 +337,14 @@ def get_current_mean(dimension): # Temperatur current_temperature = get_current_mean(Dimension.TEMPERATURE) - temperature_color = Dimension.get_color(Dimension.TEMPERATURE, current_temperature) if current_temperature else None + temperature_color = Dimension.get_color(Dimension.TEMPERATURE, current_temperature) if current_temperature is not None else None # VOC Index - current_uvi = get_current_mean(Dimension.UVS) - uvi_color = Dimension.get_color(Dimension.UVS, current_uvi) if current_uvi else None - + current_uvi = get_current_mean(Dimension.UVI) + uvi_color = Dimension.get_color(Dimension.UVI, current_uvi) if current_uvi is not None else None # dimensions to be displayed - target_dimensions = (Dimension.TEMPERATURE, Dimension.UVS) + target_dimensions = (Dimension.TEMPERATURE, Dimension.UVI) time_range = timedelta(days=1) start_time = datetime.now(timezone.utc) - time_range @@ -374,10 +373,10 @@ def get_current_mean(dimension): labels = [(start_time + timedelta(minutes=i)).strftime("%H:%M") for i in range(int(time_range.total_seconds() // 60))] # Werte ins Context-Objekt packen - context['current_temperature'] = f'{current_temperature:.2f}' if current_temperature else None + context['current_temperature'] = f'{current_temperature:.2f}' if current_temperature is not None else None context['temperature_color'] = temperature_color - context['current_tvoc'] = f'{current_uvi:.2f}' if current_uvi else None - context['tvoc_color'] = uvi_color + context['current_uvi'] = f'{current_uvi:.2f}' if current_uvi is not None else None + context['uvi_color'] = uvi_color context['data_24h'] = np.nan_to_num(data_24h, nan=0).tolist() context['labels'] = labels diff --git a/app/main/enums.py b/app/main/enums.py index f973e5a..6651014 100644 --- a/app/main/enums.py +++ b/app/main/enums.py @@ -35,6 +35,10 @@ class SensorModel(): PMS5003 = 16 PMS7003 = 17 VIRTUAL_SENSOR = 18 + LTR390 = 19 + BMP388 = 20 + BMP390 = 21 + LSM6DS = 22 _names = { SEN5X: "SEN5X", @@ -55,6 +59,10 @@ class SensorModel(): PMS5003: "PMS5003", PMS7003: "PMS7003", VIRTUAL_SENSOR: "VIRTUAL_SENSOR", + LTR390: "LTR390", + BMP388: 'BMP388', + BMP390: 'BMP390', + LSM6DS: 'lsm6ds', } _manufacturer = { @@ -125,10 +133,15 @@ class Dimension(): ADJUSTED_TEMP_CUBE = 19 UVS = 20 LIGHT = 21 - ACCELERATION = 22 - GYRO = 23 - ALTITUDE = 24 - + ALTITUDE = 22 + UVI = 23 + LUX = 24 + ACCELERATION_X = 25 + ACCELERATION_Y = 26 + ACCELERATION_Z = 27 + GYRO_X = 28 + GYRO_Y = 29 + GYRO_Z = 30 thresholds = { TEMPERATURE: ([18, 24], [Color.BLUE, Color.GREEN, Color.RED]), @@ -136,6 +149,7 @@ class Dimension(): TVOC: ([220, 1430], [Color.GREEN, Color.YELLOW, Color.RED]), CO2: ([800, 1000, 1400], [Color.GREEN, Color.YELLOW, Color.ORANGE, Color.RED]), ADJUSTED_TEMP_CUBE: ([18, 24], [Color.BLUE, Color.GREEN, Color.RED]), + UVI: ([3, 6, 8, 11], [Color.GREEN, Color.YELLOW, Color.ORANGE, Color.RED, Color.PURPLE]) } # Dictionary für die Einheiten der Dimensionen @@ -159,8 +173,14 @@ class Dimension(): SGP40_RAW_GAS: "Ω", SGP40_ADJUSTED_GAS: "Ω", ADJUSTED_TEMP_CUBE: "°C", - ACCELERATION: "m/s²", - GYRO: "radians/s" + ACCELERATION_X: "m/s²", + ACCELERATION_Y: "m/s²", + ACCELERATION_Z: "m/s²", + GYRO_X: "radians/s", + GYRO_Y: "radians/s", + GYRO_Z: "radians/s", + UVI: "UV Index", + LUX: "lx" } _names = { @@ -185,12 +205,18 @@ class Dimension(): ADJUSTED_TEMP_CUBE: "Adjusted Temperature Air Cube", UVS: "UVS", LIGHT: "Light", - ACCELERATION: "acceleration", - GYRO: "gyro" + ACCELERATION_X: "acceleration X", + ACCELERATION_Y: "acceleration Y", + ACCELERATION_Z: "acceleration Z", + GYRO_X: "gyro X", + GYRO_Y: "gyro Y", + GYRO_Z: "gyro Z", + UVI: "UV Index", + LUX: "Lux" } _required_sensors = { - ADJUSTED_TEMP_CUBE: set([SensorModel.AHT20, SensorModel.SHT4X, SensorModel.SEN5X]) + ADJUSTED_TEMP_CUBE: set([SensorModel.SHT4X, SensorModel.SEN5X]) } _sensor_community_names = {